Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaBeans Components. To understand JavaBeans…  Proficient experience with the Java language required  Knowledge of classes and interfaces  Object-Oriented.

Similar presentations


Presentation on theme: "JavaBeans Components. To understand JavaBeans…  Proficient experience with the Java language required  Knowledge of classes and interfaces  Object-Oriented."— Presentation transcript:

1 JavaBeans Components

2 To understand JavaBeans…  Proficient experience with the Java language required  Knowledge of classes and interfaces  Object-Oriented development and design  Simple Java GUI application programming using AWT  Exposure to Java’s Delegation Event-Handling Model

3 JavaBeans Overview  Software Components  JavaBeans Definition  The JavaBeans API  Applying JavaBeans  The Basic Structure of a Bean

4 Software Components  Discrete, Reusable Software standard  Microsoft’s ActiveX  Distributed Network Environment  Cross-platform  Must be controlled dynamically  Assembled to form applications  Interoperablility standards

5 The Component Model  Introspection - Discovery and Registration  Event Handling  Persistence  Visual Presentation - Layout  Application Builder Support

6 Introspection  Discovery of Component at Run Time  Late Binding  Expose Component Functionality  Component is Isolated, yet Usable

7 Event Handling  Alert to Internal Change  Component Interactivity  Listeners

8 Persistence  Saving State  Storage and Retrieval  Uniform Persistence Mechanism needed

9 Visual Presentation - Layout  Dynamic Property Control  Physical Layout  Component Interaction and Spatial Requirement  Container/Component Behavior

10 Application Builder Support  Graphical application builders  Toolboxes and Palettes  Editing Properties  Components must Expose properties and behaviors

11 JavaBean Definition  What is a Bean?  The JavaBeans specification states: A JavaBean is a reusable software component that can be manipulated visually in a builder tool.

12 JavaBeans Benefits and Features  Simple and Compact  Portable  Leverage Strengths of Java Platform  Application Builder Support  Flexible Build-Time Component Editors  Distributed Computing Support

13 JavaBeans and Java  Java: “Write once, Run Anywhere”  JavaBeans mission statement: “….Reuse Everywhere”  Java provides no component model  JavaBeans specifies framework for reusability and interoperability for components  Java integration requires code-level knowledge  JavaBeans integration requires visual editor

14 JavaBeans API  Property Management  Event Handling  Introspection  Persistence  Application Builder Support  Customization  Multithreading

15 Property Management  Accessor Methods  Indexed Properties  Bound Properties  Constrained Properties

16 Event Handling  Event Sources  Unicast  Multicast  Event Listeners  Event Objects  Event Adapters

17 Introspection  Reflection  Design Patterns  Explicit Bean Information  Introspector

18 Persistence  Storage and Retrieval  Java Object Serialization  Bean controlled persistence

19 Application Builder Support  Edit and Manipulate Beans  Bundled with Bean Separately  Property Sheets  Property Editors  Customizers

20 Multithreading  Relies on conventional Java Programming techniques  synchronized keyword  Make sure Beans are thread-safe

21 Where and How Beans are Used  Web Pages  Liven up static HTML  Interactivity  Applications  Application Builder Tool  Handwritten Code  Bridge Technology

22 Structure of a JavaBean  Data  Methods  Events DataMethods JavaBean Events

23 JavaBeans and the Interface Data Public Methods JavaBean Interface A Interface B

24 What Constitutes a Bean?  Class must be instantiable  Class must have a default constructor (not officially required by spec, but by most builder tools)  Class must be serializable  Implement Serializable, Externalizable  Class must follow JavaBeans naming conventions (sometimes called design patterns)  Class must use delegation event model

25 Constructing a Bean  “Must be instantiable” requirement  Not abstract  Not an interface  “Default constructor” requirement  Application builder tools  Persistence

26 Serialization  Representation as a series of bytes  Storage to non-volatile location  Implement Serializable Interface  Implement Externalizable Interface

27 JavaBeans Design Patterns  Naming conventions for automatic Introspection  Example: Property named Height public int getHeight(); public void setHeight(int h);  Patterns for Event Registration

28 Delegation Event Model  Introduced in Java 1.1 AWT  Most Java AWT Components are Beans  Simple  Graphical  Reusable  JFC Swing Components are JavaBean compliant

29 A Simple Bean public class FirstBean implements java.io.Serializable { protected int theValue; public FirstBean() { } public void setMyValue( int n ) { theValue = n; } public int getMyValue() { return theValue; }

30 Visual Development Environments  Developer can focus on Business Application  Connect Components Visually  Code-Generation Engine  Stability  Ease of Generation  Knowledge of Underlying Language Helpful

31 Visual Programming  NetBeans  JBuilder  VisualAge for Java  Eclipse  JDeveloper

32 Security and JavaBeans  Same security model as Java  Beans are treated like applets  Untrusted applet -> Untrusted Bean  Trusted applet -> Trusted Bean  Program for Untrusted Environments

33 Summary  JavaBeans satisfies the requirements of a discrete, reusable component model  Visual and Non-Visual JavaBeans can be developed and used in diverse development environments  Java Classes can become JavaBeans by adhering to some minimum standards  Java’s Security Model transfers directly to JavaBeans


Download ppt "JavaBeans Components. To understand JavaBeans…  Proficient experience with the Java language required  Knowledge of classes and interfaces  Object-Oriented."

Similar presentations


Ads by Google