JavaBeans API

Edith Jones
rule01.gif (193 bytes)
The Java Development Toolkit (JDK) includes the JavaBeans API (Application Program interface)This API is only one of several closely related Java core APIs spread throughout various documents.

Hot Links

bullet3.gif (48 bytes) The Java Core Reflection API
Java Object Serialization

JDK1.1 - AWT Enhancements
Manifest File Specification
Java IDL
Remote Method Invocation
A   JavaBean exports properties, events and methods. The beanbox tool determines the properties,
events and methods a bean supports by using an "introspection" mechanism. The FeatureDescriptor class
(which is the base class for MethodDescriptor and PropertyDescriptor) provides this introspection
information.

Below is a brief discussion on the these topics.

PROPERTIES

Bean properties are attributes of the bean's internal state.  These  associated pieces can be queried
or can be set via appropriate methods exported by the bean.  In addition to basic properties,
the property itself may be indexed, bound or constrained.

An indexed  property has an array value whereas methods allow each element or the entire array to be set..
A bound property provides notification service when a property changes.  In general, a PropertyChangeListener
event listener interface reports the event.   A constrained property not only notifies registered listeners, but it
also allows for input.  Another bean may veto the change deeming it invalid; thus the property change cannot
commence until all interested beans concur.

Interfaces for property changes:

public interface java.beans.PropertyChangeListener extends java.util.EventListener
public PropertyChangeEvent (Object source,  String propertyName, Object oldValue, Object newValue);

public Object getNewValue();
public Object getOldValue();
public Object getPropagationId();
public String getPropertyName();
public void setPropagationId(Object propagationId);

Public PropertyVetoException(String mess, Property ChangeEvent evt);

EVENTS

Events are a core feature of the JavaBeans. This is well suited for event driven programming. JavaBean event
modeling is based on the AWT components. When an event is dispatched to the appropriate listener,
it passes through the processEvent() method. In general, this method checks the class of the event and
sends it to the class specific method. For example, if a mouse event occured, the event is passed to either
processMouseEvent() or
processMouseMotionEvent().

Below is a simple model for event processing.
 
This picture was taken from the JavaBeans API Specification (page 25).
The website below(reference 3)will lead to the ftp site to download the document.

METHODS

JavaBean methods do not entail any special meaning. They are simply any external methods supported by a bean.

REFERENCES:

1. Teach Yourself Java 1.2 in 21 Days
    Laura Lemay and Rogers Cadenhead
    Third Edition, Sam's Publishing
 

2. Java in a Nutshell
    David Flanagan
    Second Edition, O'Reilly and Associates

3. Javabeans Specification