Copyright © 2001 Qusay H. Mahmoud JavaBeans An introduction to component-based development in general Introduction to JavaBeans – Java components – client-side.

Slides:



Advertisements
Similar presentations
3 Copyright © 2005, Oracle. All rights reserved. Basic Java Syntax and Coding Conventions.
Advertisements

JavaBeans: Introspection and Customization Umer Farooq CS6704: Design Patterns & Component FrameworksJanuary 30, 2002.
CSE 1302 Lecture 8 Inheritance Richard Gesick Figures from Deitel, “Visual C#”, Pearson.
The road to reliable, autonomous distributed systems
Java Beans & Serialization CS-328 Dick Steflik. Java Beans Java based component technology –originally developed to provide java with a component technology.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
JavaBeans introduction Klaus-Peter Heidrich for the University of Karlstad Inst. for Information Technology Dept. of Computer Science.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of Creating Eclipse plug-ins.
By Dr. Jiang B. Liu 12. The Java Beans. Java Beans n JavaBeans is a portable, platform-independent software component model written in Java. It enables.
JavaBeans A component architecture. What is JavaBeans? NC World (New Computing) Dictionary: JavaBeans n. 1. JavaSoft technology. 2. Component object model.
JAVA BEANS By Madhuri Kakumanu. What is a Java Bean? “ A Java Bean is a reusable software component that can be visually manipulated in builder tools.”
Structure of a web application1 Dr Jim Briggs. MVC Structure of a web application2.
M.Sc. Course, Dept. of Informatics and Telecommunications, University of Athens S.Hadjiefthymiades “Web Application Servers” Basics on WAS WAS are necessary.
JAVA BEANS (Unit-V) K.Phani Sirisha.
Introducing JavaBeans Lesson 2A / Slide 1 of 30 JDBC and JavaBeans Pre-assessment Questions 1.Which of the given symbols is used as a placeholder for PreparedStatement.
Introducing JavaBeans Identify the features of a JavaBean Create and add a bean to an application Manipulate bean properties using accessor and mutator.
Java Beans.  Java offers software component development through java Beans  Java Beans are based on a software component model for java.  The model.
Java Beans Component Technology Integrated, Visual Development Environments Reusable Platform-Independent Modular.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse 2.
Component-Based Software Engineering Introduction to Java Beans Paul Krause and Sotiris Moschoyiannis.
Java Beans.
Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
SWE 316: Software Design and Architecture Objectives Lecture # 19 Java Beans SWE 316: Software Design and Architecture  Understand  what JavaBeans (“Beans”)
Last update October 18, 2004 Advanced Programming 2004 Java Beans.
JavaBeans Components. To understand JavaBeans…  Proficient experience with the Java language required  Knowledge of classes and interfaces  Object-Oriented.
TM Introduction to JavaBeans™ Dimitrios Psarros Questra Consulting (716) x225.
CIS 644 Aug. 25, 1999 tour of Java. First … about the media lectures… we are experimenting with the media format please give feedback.
Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02.
Java Programming: Advanced Topics 1 JavaBeans Chapter 8.
SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits.
Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.
Java Bean Definition “A Java Bean is a reusable software component that can be manipulated visually in a builder tool.”
1 CSC 222: Object-Oriented Programming Spring 2012 netBeans & GUIBuilder  netBeans IDE create/edit/run a project  GUIBuilder JFrame, JButton, JTextField,
Introduction to Java Beans CIS 421 Web-based Java Programming.
Frameworks CompSci 230 S Software Construction.
Introduction to Java 120 February 2004Sifei HE © 2004 Introduction to Java for CS381, EE4.Web By Sifei HE Department of Computing.
First Bean Compose SimpleBean Demo Simple Bean Discuss Manifest and Jar Add Properties to SimpleBean.
First Bean Compose SimpleBean Demo Simple Bean Discuss Manifest and Jar Add Properties to SimpleBean.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 27 JavaBeans and.
Java Beans. Definitions A reusable software component that can be manipulated visually in a ‘builder tool’. (from JavaBean Specification) The JavaBeans.
Intelligent Agent Framework1 From Chapter 7 of Constructing Intelligent Agents with Java.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Advanced Java Session 4 New York University School of Continuing and Professional Studies.
JavaBean Component Java bean is a reusable software component that can be manipulated visually in a builder tool Graphic bean and Non-graphic bean Javabean.
Introduction to Software Components: the JavaBeans specs Babak Esfandiari.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 32 JavaBeans and Bean.
Lorenz: Visitor Beans: An Aspect-Oriented Pattern Aspect-oriented pattern: describes a solution to a tangling problem in a particular context.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Java Programming: Advanced Topics1 Introduction to Advanced Java Programming Chapter 1.
Java Beans THETOPPERSWAY.COM. Contents What is a Java Bean? Advantages Properties Bean Developers Kit (BDK) What makes Bean possible? Support for Java.
Slides prepared by Rose Williams, Binghamton University Chapter 20 Java Never Ends.
Java Beans - Basics CIS 421 Web-based Java Programming.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Chapter 32 JavaBeans and Bean Events
CSC 222: Object-Oriented Programming
Structure of a web application
Chapter 36 JavaBeans and Bean Events
Java Beans Sagun Dhakhwa.
JavaBeans and JSP CS-422.
Lecture 22 Inheritance Richard Gesick.
Reusability 11/29/2018© 2006 ITT Educational Services Inc.
Pre-assessment Questions
Knowledge Byte In this section, you will learn about:
Enterprise Java Beans.
Component-Based Software Engineering
11.1 Applets & graphics.
Java Programming: Advanced Topics
Presentation transcript:

Copyright © 2001 Qusay H. Mahmoud JavaBeans An introduction to component-based development in general Introduction to JavaBeans – Java components – client-side Working with the BDK The beans development life cycle Writing simple and advanced beans

Copyright © 2001 Qusay H. Mahmoud Software Components All engineering discplines use components to build systems. In SE we rely on line-by-line SD. We have class libraries – create objects from class libraries – we still need to write a large amount of code – objects are not enough

Copyright © 2001 Qusay H. Mahmoud Software Components They are like Integrated Circuit (IC) components Over 20 years ago, hardware vendors learned how to package transistors Hardware Engineers integrate ICs to make a board of chips In SE, we are where hardware engineers were 20 years ago We are building software routines

Copyright © 2001 Qusay H. Mahmoud Java Components Instead of worrying about rotuines, we can buy routines and use/reuse them in our applications (assemble applications) JavaBeans -- portable, platform-independent component model Java components are known as beans A bean: a reusable software component that can be manipulated visually in a builder tool

Copyright © 2001 Qusay H. Mahmoud JavaBeans vs. Class Libraries Beans are appropriate for software components that can be visually manipulated Class libraries are good for providing functionality that is useful to programmers, and doesn’t benefit from visual manipulation

Copyright © 2001 Qusay H. Mahmoud JavaBeans Concepts A component is a self-contained reusable software unit Components expose their features (public methods and events) to builder tools A builder tool maintains Beans in a palette or toolbox.

Copyright © 2001 Qusay H. Mahmoud Concepts... You can select a bean from the toolbox, drop it in a form, and modify its appearance and behavior. Also, you can define its interaction with other beans ALL this without a line of code.

Copyright © 2001 Qusay H. Mahmoud JavaBean Characteristics a public class with 0-argument constuctor it has properties with accessory methods it has events it can customized its state can be saved it can be analyzed by a builder tool

Copyright © 2001 Qusay H. Mahmoud Key Concepts A builder tool discover a bean’s features by a process known as introspection. – Adhering to specific rules (design pattern) when naming Bean features. – Providing property, method, and event information with a related Bean Information class. Properties (bean’s appearance and behavior characteristics) can be changed at design-time.

Copyright © 2001 Qusay H. Mahmoud Key Concepts…. Properties can be customized at design-time. Customization can be done: – using property editor – using bean customizers Events are used when beans want to intercommunicate Persistence: for saving and restoring the state Bean’s methods are regular Java methods.

Copyright © 2001 Qusay H. Mahmoud Security Issues JavaBeans are sbject to the standard Java security model The security model has neither extended nor relaxed. If a bean runs as an untrusted applet then it will be subject to applet security If a bean runs as a stand-alone application then it will be treated as a normal Java application.

Copyright © 2001 Qusay H. Mahmoud JavaBeans and Threads Assume your beans will be running in a multi- threaded environment It is your responsibility (the developer) to make sure that their beans behave properly under multi-threaded access For simple beans, this can be handled by simply making all methods …...

Copyright © 2001 Qusay H. Mahmoud Beans Development Kit (BDK) To start the BeanBox: – run.bat (Windows) – run.sh (Unix)

Copyright © 2001 Qusay H. Mahmoud BDK ToolBox contains the beans available BeanBox window is the form where you visually wire beans together. Properties sheet: displays the properties for the Bean currently selected within the BeanBox window.

Copyright © 2001 Qusay H. Mahmoud MyFirstBean import java.awt.*; import java.io.Serializable; public class FirstBean extends Canvas implements Serializable { public FirstBean() { setSize(50,30); setBackground(Color.blue); }

Copyright © 2001 Qusay H. Mahmoud First Bean Compile: javac FirstBean.java Create a manifest file: manifest.txt – Name: FirstBean.class – Java-Bean: True Create a jar file: jar cfm FirstBean.jar mani.txt FirstBean.class

Copyright © 2001 Qusay H. Mahmoud Using Beans in hand-written app Use Beans.instantiate Frame f; f = new Frame("Testing Beans"); try { ClassLoader cl = this.getClass().getClassLoader(); fb =(FirstBean)Beans.instantiate(cl,"FirstBean"); } catch(Exception e) { e.printStackTrace(); } f.add(fb);

Copyright © 2001 Qusay H. Mahmoud Properties Bean’s appearance and behavior -- changeable at design time. They are private values Can be accessed through getter and setter methods getter and setter methods must follow some rules -- design patterns (documenting experience)

Copyright © 2001 Qusay H. Mahmoud Properties A builder tool can: – discover a bean’s properties – determine the properties’ read/write attribute – locate an appropriate “property editor” for each type – display the properties (in a sheet) – alter the properties at design-time

Copyright © 2001 Qusay H. Mahmoud Types of Properties Simple Index: multiple-value properties Bound: provide event notification when value changes Constrained: how proposed changes can be okayed or vetoed by other object

Copyright © 2001 Qusay H. Mahmoud Simple Properties When a builder tool introspect your bean it discovers two methods: – public Color getColor() – public void setColor(Color c) The builder tool knows that a property named “Color” exists -- of type Color. It tries to locate a property editor for that type to display the properties in a sheet.

Copyright © 2001 Qusay H. Mahmoud Simple Properties…. Adding a Color property – Create and initialize a private instance variable private Color color = Color.blue; – Write public getter & setter methods public Color getColor() { – return color; } public void setColor(Color c) { – color = c; – repaint(); }

Copyright © 2001 Qusay H. Mahmoud Events “Introspection” For a bean to be the source of an event, it must implement methods that add and remove listener objects for the type of the event: – public void add ( elt); – same thing for remove These methods help a source Bean know where to fire events.

Copyright © 2001 Qusay H. Mahmoud Events “Introspection” Source Bean fires events at the listeners using method of those interfaces. Example: if a source Bean register ActionListsener objects, it will fire events at those objects by calling the actionPerformed method on those listeners

Copyright © 2001 Qusay H. Mahmoud Events “using BeanInfo” Implementing the BeanInfo interface allows you to explicitly publish the events a Bean fires

Copyright © 2001 Qusay H. Mahmoud BeanInfo interface Question: how does a Bean exposes its features in a property sheet? Answer: using java.beans.Introspector class (which uses Core Reflection API) The discovery process is named “introspection” OR you can associate a class that implements the BeanInfo with your bean

Copyright © 2001 Qusay H. Mahmoud BeanInfo interface…. Why use BeanInfo then? Using BeanInfo you can: – Expose features that you want to expose

Copyright © 2001 Qusay H. Mahmoud Bean Customization The appearance and behavior of a bean can be customized at design time. Two ways to customize a bean: – using a property editor each bean property has its own editor a bean’s property is displayed in a property sheet – using customizers gives you complete GUI control over bean customization used when property editors are not practical

Copyright © 2001 Qusay H. Mahmoud Property Editors A property editor is a user interface for editing a bean property. The property must have both, read/write accessor methods. A property editor must implement the PropertyEditor interface. PropertyEditorSupport does that already, so you can extend it.

Copyright © 2001 Qusay H. Mahmoud Property Editors If you provide a custom property editor class, then you must refer to this class by calling PropertyDescriptor.setPropertyEditorClass in a BeanInfo class. Each bean may have a BeanInfo class which customizes how the bean is to appear. SimpleBeanInfo implements that interface

Copyright © 2001 Qusay H. Mahmoud How to be a good bean? JavaBeans are just the start of the Software Components industry. This market is growing in both, quantity and quality. To promote commercial quality java beans components and tools, we should strive to make our beans as reusable as possible. Here are a few guidelines...

Copyright © 2001 Qusay H. Mahmoud How to be a good bean? Creating beans – Your bean class must provide a zero-argument constructor. So, objects can be created using Bean.instantiate(); – The bean must support persistence implement Serializable or Externalizable