Components Components are specialized self contained Software entities that can be replicated,...

17
Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come in variety of different Implementation and support a wide range of Functions. Numerous individual components can be created and tailored for different applications. Components are contained within containers. Interaction with components occurs through event handling and method invocation.

Transcript of Components Components are specialized self contained Software entities that can be replicated,...

Page 1: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Components• Components are specialized self containedSoftware entities that can be replicated,Customized and inserted into applications.

• Components come in variety of different Implementation and support a wide range of Functions.

• Numerous individual components can be created and tailored for different applications.

• Components are contained within containers.

• Interaction with components occurs through event handling and method invocation.

Page 2: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Java Beans

• Java Beans are software components that are designed for maximum reuse.They are often visible GUI components,but can also be invisible algorithmic components.

Page 3: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Advantages of Java Beans• Java Beans is based on the policy of “write once and run anywhere” which means Bean component created once can be executed anywhere in any platform.

• Java Beans has an builder tool called “Bean box” which is used to test bean component its properties,events and methods.

• The configured settings of any bean component can be saved into persistence storage and reused when ever required.

• A Bean may receive event from other objects and can generate events that are sent to other objects

Page 4: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Bean development Kit• Bean development kit is used to create configure and connect a set of Beans. There is also a set of sample Beans with their source code.

• In order to use BDK the tool should be installed and can be downloaded from the site java.sun.com

• To start BDK execute run.bat(batch file) available in the directory c:\bdk1.1\beanbox which opens 4 windows

1. Toolbox :Its used to display Bean

component

Page 5: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

2. Bean Box :

It’s the layout to create, design and configure a bean

3. Properties :

Its used to display and configure properties associated with Bean.

4. Method Tracer :

Any method invoked on Bean is

Traced by the method tracer.

Page 6: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Introspection

• Introspection is the process of analyzing a bean to determine its capabilities.

• Its essential feature of the Java Beans API because it allows to present the information about the component to the software designer.

• In short it’s the exposure of methods, properties and events by an application builder.

Page 7: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Jar Utilities

• Jar refers to Java Archive files.

• Java Archives are compressed form of all the class files and required resources for a component.

• Jar technology makes the usage of resources much faster and easier.

Page 8: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Steps to Create a Java Archieve

• Create the class file which is to be converted into jar

• Write a manifest file which describes which among the resources is going to be an java file

• Issue jar command and convert the class file into jar.

Page 9: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Jar options• c A new archive is to created.

• C Change directories during command execution.

• f The first element in the file list is the name of the archive file to be created.

• m The second element in the file list is the name of the external manifest file.

• M Manifest file not created

• t The archive content should be tabulated

• u Update existing JAR file

• x The jar file is to be extracted.

Page 10: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Types of Properties• Simple Properties

Properties which is set by assigning a single value refers to simple property.

eg:public type getN();public void setN();

• Boolean Properties Properties which has true and false value refers to Boolean

Property.’eg:

public void setN()public boolean getN()

Page 11: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

• Indexed property

An indexed property is one which has multiple values.

For eg:

public type getN(int index);

public type[] getN();

public void setN(int index,type value);

public void setN(type values[]);

• Bound Property

A bean that has bound property generates an event when the property is changed.The event is of type PropertyChangeEvent and sent to the objects that are previously registered an interest in receiving notifications.

Page 12: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Constrained Properties• A Bean that has a constrained property generates an event

when an attempt is made to change its value.The event is of PropertyChangeEvent and send to only those objects which are registered.

Page 13: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Classes in Java Beans package• PropertyChangeEvent

The PropertyChangeEvent class in the above package defines the event notification that are multicast by a bean when one of its properties is changed

PropertyChangeEvent(Object src,String pname,Object Oldvalue,Object NewValue)

src is the bean whose property is changed

pname is the name of property which has changed

OldValue is the initial value of the property

NewValue is the updated value of the property

Page 14: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

Methods of PropertyChange Event class

• Object getNewValue()

• Object getOldValue()

• String PropertyName()

• PropertyChangeListener is interface which receives PropertyChangeEvent.

• Method

void propertyChange(PropertyChangeEvent pce)

Page 15: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

PropertyChangeSupport• PropertyChangeSupport is used to perform much of the work

associated with bound properties.

• synchronized void addPropertyChange(PropertyChangeListener pcl)

• synchronized void removePropertyChange(PropertyChangeListener pcl)

• Void firePropertyChange(String pname,Object oldValue,Object newValue)

Page 16: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.

• VetoableChangeListener interface

void vetoableChange(PropertyChangeEvent pce)throws PropertyVetoException

• PropertyVetoException class

PropertyVetoException(String message, PropertyChangeEvent pce)

• VetoableChangeSupport class

VetoableChangeSupport(Object src)

synchornized void addVetoableChangeListener( VetoableChangeListener pcl)

synchornized void addVetoableChangeListener( VetoableChangeListener pcl)

• Void fireVetoableChangeListener(String pname,Object oldValue,Object newValue)throws PropertyVetoException

Page 17: Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.