Book Home Java Enterprise in a Nutshell Search this book

Chapter 10. The java.beans.beancontext Package

The java.beans.beancontext package extends the JavaBeans component model to add the notion of a containment hierarchy. It also supports bean containers that provide an execution context for the beans they contain and that may also provide a set of services to those beans. This package is typically used by advanced bean developers and developers of bean-manipulation tools. Application programmers who are simply using beans do not typically use this package. Figure 10-1 shows the class hierarchy.

figure

Figure 10-1. The java.beans.beancontext package

BeanContext is the central interface of this package. It is a container for beans and also defines several methods that specify context information for beans. BeanContextServices extends BeanContext to define methods that allow a contained bean to query and request available services. A bean that wishes to be told about its containing BeanContext implements the BeanContextChild interface. BeanContext is itself a BeanContextChild, which means that contexts can be nested within other contexts.

See Chapter 6, "JavaBeans", for more information on beans and bean contexts.

BeanContextJava 1.2
java.beans.beancontextcollection

This interface defines the methods that must be implemented by any class that wants to act as a logical container for JavaBeans components. Every BeanContext is also a BeanContextChild and can therefore be nested within a higher-level bean context. BeanContext is extended by BeanContextServices; any bean context that wants to provide services to the beans it contains must implement this more specialized interface.

The BeanContext interface extends the java.util.Collection interface; the children it contains are accessed using the methods of that interface. In addition, BeanContext defines several important methods of its own. instantiateChild() instantiates a new bean, in the same manner as the standard Beans.instantiate() method, and then makes that new bean a child of the context. Calling this method is typically the same as calling the three-argument version of Beans.instantiate(). getResource() and getResourceAsStream() are the BeanContext versions of the java.lang.Class and java.lang.ClassLoader methods of the same name. Some bean-context implementations may provide special behavior for these methods; others may simply delegate to the Class or ClassLoader of the bean. The remaining two methods allow the registration and deregistration of event listeners that the BeanContext notifies when bean children are added or removed from the context.

Implementing a BeanContext is a more specialized task than developing a JavaBeans component. Many bean developers will never have to implement a bean context themselves. If you do implement a bean context, you'll probably find it easier to use BeanContextSupport, either by extending it or using an instance as a proxy.

public interface BeanContext extends BeanContextChild, java.util.Collection, java.beans.DesignMode, java.beans.Visibility {
// Public Constants
public static final Object globalHierarchyLock ;
// Event Registration Methods (by event name)
public abstract void addBeanContextMembershipListener (BeanContextMembershipListener bcml);
public abstract void removeBeanContextMembershipListener (BeanContextMembershipListener bcml);
// Public Instance Methods
public abstract java.net.URL getResource (String name, BeanContextChild bcc) throws IllegalArgumentException;
public abstract java.io.InputStream getResourceAsStream (String name, BeanContextChild bcc) throws IllegalArgumentException;
public abstract Object instantiateChild (String beanName) throws java.io.IOExceptionClassNotFoundException;
}

Hierarchy: (BeanContext(BeanContextChild,java.util.Collection,java.beans.DesignMode,java.beans.Visibility))

Implementations: BeanContextServices, BeanContextSupport

Passed To: java.beans.AppletInitializer.initialize(), java.beans.Beans.instantiate(), BeanContextChild.setBeanContext(), BeanContextChildSupport.{setBeanContext(), validatePendingSetBeanContext()}, BeanContextEvent.{BeanContextEvent(), setPropagatedFrom()}, BeanContextMembershipEvent.BeanContextMembershipEvent(), BeanContextSupport.BeanContextSupport()

Returned By: BeanContextChild.getBeanContext(), BeanContextChildSupport.getBeanContext(), BeanContextEvent.{getBeanContext(), getPropagatedFrom()}, BeanContextSupport.getBeanContextPeer()

Type Of: BeanContextChildSupport.beanContext, BeanContextEvent.propagatedFrom

BeanContextChildJava 1.2
java.beans.beancontext

JavaBeans components that are designed to be nested within a bean context and need to be aware of that context must implement this interface. BeanContextChild implements a single beanContext property that identifies the BeanContext within which the bean is contained. The beanContext property is bound and constrained, which means that it must fire PropertyChangeEvent events when setBeanContext() is called, and any call to setBeanContext() may result in a PropertyVetoException if one of the VetoableChangeListener objects vetoes the change. The setBeanContext() method is not intended for use by beans or by applications. When a bean is instantiated or deserialized, its containing bean context calls this method to introduce itself to the bean. The bean must store a reference to its BeanContext in a transient field so that the context is not serialized along with the bean itself.

Implementing a BeanContextChild from scratch can be somewhat tricky because you must correctly handle the VetoableChangeListener protocol and correctly implement important conventions, such as storing the BeanContext reference in a transient field. Therefore, most bean developers do not implement the interface directly, but instead use BeanContextSupport, either by subclassing it or by using an instance as a delegate.

public interface BeanContextChild {
// Public Instance Methods
public abstract void addPropertyChangeListener (String name, java.beans.PropertyChangeListener pcl);
public abstract void addVetoableChangeListener (String name, java.beans.VetoableChangeListener vcl);
public abstract BeanContext getBeanContext ();
public abstract void removePropertyChangeListener (String name, java.beans.PropertyChangeListener pcl);
public abstract void removeVetoableChangeListener (String name, java.beans.VetoableChangeListener vcl);
public abstract void setBeanContext (BeanContext bc) throws java.beans.PropertyVetoException;
}

Implementations: BeanContext, BeanContextChildSupport

Passed To: BeanContext.{getResource(), getResourceAsStream()}, BeanContextChildSupport.BeanContextChildSupport(), BeanContextServices.{getService(), releaseService()}, BeanContextServicesSupport.{getService(), releaseService()}, BeanContextSupport.{getResource(), getResourceAsStream()}

Returned By: BeanContextChildSupport.getBeanContextChildPeer(), BeanContextProxy.getBeanContextProxy(), BeanContextSupport.getChildBeanContextChild()

Type Of: BeanContextChildSupport.beanContextChildPeer

BeanContextChildComponentProxyJava 1.2
java.beans.beancontext

If a BeanContextChild is not a Component subclass but has an associated Component object to display its visual representation, it implements this interface to allow access to that component.

public interface BeanContextChildComponentProxy {
// Public Instance Methods
public abstract java.awt.Component getComponent ();
}
BeanContextChildSupportJava 1.2
java.beans.beancontextserializable

This class provides support for implementing the BeanContextChild interface in a way that correctly conforms to the details of the bean context specification. A subclass should implement initializeBeanContextResources() and releaseBeanContextResources() to obtain and release whatever resources the bean context child requires, such as service objects obtained from the containing BeanContext. These methods are called when the containing bean context introduces itself by calling setBeanContext(). Any resources obtained with these methods should be stored in transient fields so that they are not serialized along with the bean. A bean that wants a chance to approve any call to setBeanContext() before that call succeeds can implement validatePendingSetBeanContext(). If this method returns false, the setBeanContext() call that triggered it fails with a PropertyVetoException.

Many beans are AWT or Swing components and cannot subclass both Component and BeanContextChildSupport. Therefore, many bean developers find it useful to delegate to an internal instance of BeanContextChildSupport. One way to do this is to have your bean implement the BeanContextProxy interface and simply return an instance of BeanContextChildSupport from the getBeanContextProxy() method. Another technique is to actually implement the BeanContextChild interface in your bean, but provide dummy methods that call the corresponding methods of BeanContextChildSupport. If you do this, you should pass an instance of your bean to the BeanContextChildSupport() constructor. This makes the delegation transparent so events appear to come directly from your bean. In either case, you can instantiate BeanContextChildSupport directly. Often, however, you want to create a custom subclass (perhaps as an inner class) to implement methods such as initializeBeanContextResources().

public class BeanContextChildSupport implements BeanContextChildBeanContextServicesListenerSerializable {
// Public Constructors
public BeanContextChildSupport ();
public BeanContextChildSupport (BeanContextChild bcc);
// Public Instance Methods
public void firePropertyChange (String name, Object oldValue, Object newValue);
public void fireVetoableChange (String name, Object oldValue, Object newValue) throws java.beans.PropertyVetoException;
public BeanContextChild getBeanContextChildPeer (); default:BeanContextChildSupport
public boolean isDelegated (); default:false
public boolean validatePendingSetBeanContext (BeanContext newValue); constant
// Methods Implementing BeanContextChild
public void addPropertyChangeListener (String name, java.beans.PropertyChangeListener pcl);
public void addVetoableChangeListener (String name, java.beans.VetoableChangeListener vcl);
public BeanContext getBeanContext (); synchronized default:null
public void removePropertyChangeListener (String name, java.beans.PropertyChangeListener pcl);
public void removeVetoableChangeListener (String name, java.beans.VetoableChangeListener vcl);
public void setBeanContext (BeanContext bc) throws java.beans.PropertyVetoException; synchronized
// Methods Implementing BeanContextServiceRevokedListener
public void serviceRevoked (BeanContextServiceRevokedEvent bcsre); empty
// Methods Implementing BeanContextServicesListener
public void serviceAvailable (BeanContextServiceAvailableEvent bcsae); empty
// Protected Instance Methods
protected void initializeBeanContextResources (); empty
protected void releaseBeanContextResources (); empty
// Public Instance Fields
public BeanContextChild beanContextChildPeer ;
// Protected Instance Fields
protected transient BeanContext beanContext ;
protected java.beans.PropertyChangeSupport pcSupport ;
protected transient boolean rejectedSetBCOnce ;
protected java.beans.VetoableChangeSupport vcSupport ;
}

Hierarchy: Object-->BeanContextChildSupport(BeanContextChild,BeanContextServicesListener(BeanContextServiceRevokedListener(java.util.EventListener)),Serializable)

Subclasses: BeanContextSupport

BeanContextContainerProxyJava 1.2
java.beans.beancontext

This interface is implemented by a BeanContext that has a java.awt.Container associated with it. The getContainer() method allows any interested parties to obtain a reference to the container associated with the bean context. It is a common practice for bean contexts to be associated with containers. Unfortunately, BeanContext implements java.util.Collection, which has method-name conflicts with java.awt.Container, so no Container subclass can implement the BeanContext interface. See also BeanContextProxy, which reverses the direction of the proxy relationship.

public interface BeanContextContainerProxy {
// Public Instance Methods
public abstract java.awt.Container getContainer ();
}
BeanContextEventJava 1.2
java.beans.beancontextserializable event

This is the abstract superclass of all bean context-related events. getBeanContext() returns the source of the event. If isPropagated() returns true, the event has been propagated through a hierarchy of bean contexts, and getPropagatedFrom() returns the most recent bean context to propagate the event.

public abstract class BeanContextEvent extends java.util.EventObject {
// Protected Constructors
protected BeanContextEvent (BeanContext bc);
// Public Instance Methods
public BeanContext getBeanContext ();
public BeanContext getPropagatedFrom (); synchronized
public boolean isPropagated (); synchronized
public void setPropagatedFrom (BeanContext bc); synchronized
// Protected Instance Fields
protected BeanContext propagatedFrom ;
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->BeanContextEvent

Subclasses: BeanContextMembershipEvent, BeanContextServiceAvailableEvent, BeanContextServiceRevokedEvent

BeanContextMembershipEventJava 1.2
java.beans.beancontextserializable event

An event of this type is generated by a BeanContext when beans are added to it or removed from it. The event object contains the list of children that were added or removed and allows access to that list in several ways. The size() method returns the number of affected children. The contains() method checks whether a specified object was one of the affected children. toArray() returns the list of affected children as an array, and iterator() returns the list in the form of a java.util.Iterator.

public class BeanContextMembershipEvent extends BeanContextEvent {
// Public Constructors
public BeanContextMembershipEvent (BeanContext bc, Object[ ] changes);
public BeanContextMembershipEvent (BeanContext bc, java.util.Collection changes);
// Public Instance Methods
public boolean contains (Object child);
public java.util.Iterator iterator ();
public int size ();
public Object[ ] toArray ();
// Protected Instance Fields
protected java.util.Collection children ;
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->BeanContextEvent-->BeanContextMembershipEvent

Passed To: BeanContextMembershipListener.{childrenAdded(), childrenRemoved()}, BeanContextSupport.{fireChildrenAdded(), fireChildrenRemoved()}

BeanContextMembershipListenerJava 1.2
java.beans.beancontextevent listener

This interface should be implemented by any object that wants to be notified when children are added to or removed from a BeanContext.

public interface BeanContextMembershipListener extends java.util.EventListener {
// Public Instance Methods
public abstract void childrenAdded (BeanContextMembershipEvent bcme);
public abstract void childrenRemoved (BeanContextMembershipEvent bcme);
}

Hierarchy: (BeanContextMembershipListener(java.util.EventListener))

Passed To: BeanContext.{addBeanContextMembershipListener(), removeBeanContextMembershipListener()}, BeanContextSupport.{addBeanContextMembershipListener(), removeBeanContextMembershipListener()}

Returned By: BeanContextSupport.getChildBeanContextMembershipListener()

BeanContextProxyJava 1.2
java.beans.beancontext

This interface is implemented by a JavaBeans component (often, but not always, an AWT Component or Container object) that is not itself a BeanContext or BeanContextChild, but has a BeanContext or BeanContextChild object associated with it. The getBeanContextProxy() method returns the associated object. The return type of this method is BeanContextChild. Depending on the context in which you call this method, however, the returned object may actually be a BeanContext or BeanContextServices object. You should test for this using the instanceof operator before casting the object to these more specific types.

public interface BeanContextProxy {
// Public Instance Methods
public abstract BeanContextChild getBeanContextProxy ();
}
BeanContextServiceAvailableEventJava 1.2
java.beans.beancontextserializable event

An event of this type is generated to notify interested BeanContextServicesListener objects that a new class of service is available from a BeanContextServices object. getServiceClass() returns the class of the service, and getCurrentServiceSelectors() may return a set of additional arguments that can parameterize the service.

public class BeanContextServiceAvailableEvent extends BeanContextEvent {
// Public Constructors
public BeanContextServiceAvailableEvent (BeanContextServices bcs, Class sc);
// Public Instance Methods
public java.util.Iterator getCurrentServiceSelectors ();
public Class getServiceClass ();
public BeanContextServices getSourceAsBeanContextServices ();
// Protected Instance Fields
protected Class serviceClass ;
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->BeanContextEvent-->BeanContextServiceAvailableEvent

Passed To: BeanContextChildSupport.serviceAvailable(), BeanContextServicesListener.serviceAvailable(), BeanContextServicesSupport.{fireServiceAdded(), serviceAvailable()}

BeanContextServiceProviderJava 1.2
java.beans.beancontext

This interface defines the methods that must be implemented by a factory class that wants to provide service objects to beans. To provide its service, a BeanContextServiceProvider is passed to the addService() method of a BeanContextServices object. This creates a mapping in the BeanContextServices object between a class of service (such as java.awt.print.PrinterJob) and a BeanContextServiceProvider that can return a suitable instance of that class to provide the service.

When a BeanContextChild requests a service of a particular class from its BeanContextServices container, the BeanContextServices object finds the appropriate BeanContextServiceProvider object and forwards the request to its getService() method. When the bean relinquishes the service, releaseService() is called. A getService() request may include an arbitrary object as an additional parameter or service selector. Service providers that use the service selector argument and that support a finite set of legal service selector values should implement the getCurrentServiceSelectors() method to allow the list of legal selector values to be queried.

Bean developers typically do not have to use or implement this interface. From the point of view of a bean context child, service objects are obtained from a BeanContextServices object. Developers creating BeanContextServices implementations, however, must implement appropriate BeanContextServiceProvider objects to provide the services.

public interface BeanContextServiceProvider {
// Public Instance Methods
public abstract java.util.Iterator getCurrentServiceSelectors (BeanContextServices bcs, Class serviceClass);
public abstract Object getService (BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector);
public abstract void releaseService (BeanContextServices bcs, Object requestor, Object service);
}

Implementations: BeanContextServicesSupport.BCSSProxyServiceProvider

Passed To: BeanContextServices.{addService(), revokeService()}, BeanContextServicesSupport.{addService(), createBCSSServiceProvider(), revokeService()}

Returned By: BeanContextServicesSupport.BCSSServiceProvider.getServiceProvider()

Type Of: BeanContextServicesSupport.BCSSServiceProvider.serviceProvider

BeanContextServiceProviderBeanInfoJava 1.2
java.beans.beancontext

A BeanContextServiceProvider that wishes to provide information to a GUI builder tool about the service or services it offers should implement this BeanInfo subinterface. Following the standard BeanInfo naming conventions, the implementing class should have the same name as the service provider class, with "BeanInfo" appended. This enables a design tool to look for and dynamically load the bean info class when necessary.

getServicesBeanInfo() should return an array of BeanInfo objects, one for each class of service offered by the BeanContextServiceProvider. These BeanInfo objects enable a design tool to allow the user to visually configure the service object. This can be quite useful, since service objects may be instances of existing classes that were not designed with the standard JavaBeans naming conventions in mind.

public interface BeanContextServiceProviderBeanInfo extends java.beans.BeanInfo {
// Public Instance Methods
public abstract java.beans.BeanInfo[ ] getServicesBeanInfo ();
}

Hierarchy: (BeanContextServiceProviderBeanInfo(java.beans.BeanInfo))

BeanContextServiceRevokedEventJava 1.2
java.beans.beancontextserializable event

This event class provides details about a service revocation initiated by a BeanContextServices object. getServiceClass() specifies the class of service being revoked. isCurrentServiceInvalidNow() specifies whether the currently owned service object has become invalid. If this method returns true, the bean that receives this event must stop using the service object immediately. If the method returns false, the bean can continue to use the service object, but future requests for services of this class will fail.

public class BeanContextServiceRevokedEvent extends BeanContextEvent {
// Public Constructors
public BeanContextServiceRevokedEvent (BeanContextServices bcs, Class sc, boolean invalidate);
// Public Instance Methods
public Class getServiceClass ();
public BeanContextServices getSourceAsBeanContextServices ();
public boolean isCurrentServiceInvalidNow ();
public boolean isServiceClass (Class service);
// Protected Instance Fields
protected Class serviceClass ;
}

Hierarchy: Object-->java.util.EventObject(Serializable)-->BeanContextEvent-->BeanContextServiceRevokedEvent

Passed To: BeanContextChildSupport.serviceRevoked(), BeanContextServiceRevokedListener.serviceRevoked(), BeanContextServicesSupport.{fireServiceRevoked(), serviceRevoked()}, BeanContextServicesSupport.BCSSProxyServiceProvider.serviceRevoked()

BeanContextServiceRevokedListenerJava 1.2
java.beans.beancontextevent listener

This interface defines a method that is invoked when a service object returned by a BeanContextServices object is forcibly revoked. Unlike other types of event listeners, the BeanContextServiceRevokedListener is not registered and deregistered with a pair of add and remove methods. Instead, an implementation of this interface must be passed to every getService() call on a BeanContextServices object. If the returned service is ever revoked by the granting BeanContextServiceProvider object before the bean has relinquished the service, the serviceRevoked() method of this interface is called.

When a service is revoked, it means that future requests for the service will not succeed. But it may also mean that current service objects have become invalid and must not be used anymore. The serviceRevoked() method should call the isCurrentServiceInvalidNow() method of the supplied event object to determine if this is the case. If so, it must immediately stop using the service object.

public interface BeanContextServiceRevokedListener extends java.util.EventListener {
// Public Instance Methods
public abstract void serviceRevoked (BeanContextServiceRevokedEvent bcsre);
}

Hierarchy: (BeanContextServiceRevokedListener(java.util.EventListener))

Implementations: BeanContextServicesListener, BeanContextServicesSupport.BCSSProxyServiceProvider

Passed To: BeanContextServices.getService(), BeanContextServicesSupport.getService()

BeanContextServicesJava 1.2
java.beans.beancontextcollection event listener

This interface defines additional methods a bean context class must implement if it wants to provide services to the beans it contains. A bean calls hasService() to determine if a service of a particular type is available from its bean context. It calls getService() to request an instance of the specified service class and then calls releaseService() when it no longer needs the service object. A bean that wants to find the complete list of available services can call getCurrentServiceClasses(). Some services allow (or require) a service selector object to be passed to the getService() method to provide additional information about the service object. If a service defines a fixed set of legal service selectors, getCurrentServiceSelectors() allows a bean to iterate through the set of selector objects. Beans that want to know when new services become available or when existing services are revoked should register a BeanContextServicesListener object with addBeanContextServicesListener().

If a BeanContextServices object does not provide a requested service, but is nested within another BeanContext, it should check whether any of its ancestor bean contexts can provide the service. The BeanContextServices interface extends BeanContextServicesListener. This means that every BeanContextServices object can be listening to the set of services available from its container.

The previous methods are the ones beans call to obtain services. BeanContextServices defines a different set of methods service providers use to deliver services. addService() defines a BeanContextServiceProvider for a specified Class of service. revokeService() removes this mapping between service class and service provider, and indicates that the specified service is no longer available. When a service is revoked, the BeanContextServices object must notify any beans that have been granted service objects (and have not released them yet) that the service has been revoked. It does this by notifying the BeanContextServiceRevokedListener objects passed to the getService() method.

Bean context developers may find it easier to use the BeanContextServicesSupport class, either by subclassing or by delegation, instead of implementing BeanContextServices from scratch.

public interface BeanContextServices extends BeanContext, BeanContextServicesListener {
// Event Registration Methods (by event name)
public abstract void addBeanContextServicesListener (BeanContextServicesListener bcsl);
public abstract void removeBeanContextServicesListener (BeanContextServicesListener bcsl);
// Public Instance Methods
public abstract boolean addService (Class serviceClass, BeanContextServiceProvider serviceProvider);
public abstract java.util.Iterator getCurrentServiceClasses ();
public abstract java.util.Iterator getCurrentServiceSelectors (Class serviceClass);
public abstract Object getService (BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws java.util.TooManyListenersException;
public abstract boolean hasService (Class serviceClass);
public abstract void releaseService (BeanContextChild child, Object requestor, Object service);
public abstract void revokeService (Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow);
}

Hierarchy: (BeanContextServices(BeanContext(BeanContextChild,java.util.Collection,java.beans.DesignMode,java.beans.Visibility),BeanContextServicesListener(BeanContextServiceRevokedListener(java.util.EventListener))))

Implementations: BeanContextServicesSupport

Passed To: BeanContextServiceAvailableEvent.BeanContextServiceAvailableEvent(), BeanContextServiceProvider.{getCurrentServiceSelectors(), getService(), releaseService()}, BeanContextServiceRevokedEvent.BeanContextServiceRevokedEvent(), BeanContextServicesSupport.BeanContextServicesSupport(), BeanContextServicesSupport.BCSSProxyServiceProvider.{getCurrentServiceSelectors(), getService(), releaseService()}

Returned By: BeanContextServiceAvailableEvent.getSourceAsBeanContextServices(), BeanContextServiceRevokedEvent.getSourceAsBeanContextServices(), BeanContextServicesSupport.getBeanContextServicesPeer()

BeanContextServicesListenerJava 1.2
java.beans.beancontextevent listener

This interface adds a serviceAvailable() method to the serviceRevoked() method of BeanContextServiceRevokedListener. Listeners of this type can be registered with a BeanContextServices object and are notified when a new class of service becomes available or when an existing class of service is revoked.

public interface BeanContextServicesListener extends BeanContextServiceRevokedListener {
// Public Instance Methods
public abstract void serviceAvailable (BeanContextServiceAvailableEvent bcsae);
}

Hierarchy: (BeanContextServicesListener(BeanContextServiceRevokedListener(java.util.EventListener)))

Implementations: BeanContextChildSupport, BeanContextServices

Passed To: BeanContextServices.{addBeanContextServicesListener(), removeBeanContextServicesListener()}, BeanContextServicesSupport.{addBeanContextServicesListener(), removeBeanContextServicesListener()}

Returned By: BeanContextServicesSupport.getChildBeanContextServicesListener()

BeanContextServicesSupportJava 1.2
java.beans.beancontextserializable collection

This class is a useful implementation of the BeanContextServices interface that correctly conforms to the bean context specifications and conventions. Most bean context implementors find it easier to subclass this class or delegate to an instance of this class rather than implement BeanContextServices from scratch. The most common technique is to implement the BeanContextProxy interface and return an instance of BeanContextServicesSupport from the getBeanContextProxy() method.

public class BeanContextServicesSupport extends BeanContextSupport implements BeanContextServices {
// Public Constructors
public BeanContextServicesSupport ();
public BeanContextServicesSupport (BeanContextServices peer);
public BeanContextServicesSupport (BeanContextServices peer, java.util.Locale lcle);
public BeanContextServicesSupport (BeanContextServices peer, java.util.Locale lcle, boolean dtime);
public BeanContextServicesSupport (BeanContextServices peer, java.util.Locale lcle, boolean dTime, boolean visible);
// Inner Classes
;
;
;
// Protected Class Methods
protected static final BeanContextServicesListener getChildBeanContextServicesListener (Object child);
// Event Registration Methods (by event name)
public void addBeanContextServicesListener (BeanContextServicesListener bcsl); Implements:BeanContextServices
public void removeBeanContextServicesListener (BeanContextServicesListener bcsl); Implements:BeanContextServices
// Public Instance Methods
public BeanContextServices getBeanContextServicesPeer (); default:BeanContextServicesSupport
// Methods Implementing BeanContextServiceRevokedListener
public void serviceRevoked (BeanContextServiceRevokedEvent bcssre);
// Methods Implementing BeanContextServices
public void addBeanContextServicesListener (BeanContextServicesListener bcsl);
public boolean addService (Class serviceClass, BeanContextServiceProvider bcsp);
public java.util.Iterator getCurrentServiceClasses (); default:BeanContextSupport.BCSIterator
public java.util.Iterator getCurrentServiceSelectors (Class serviceClass);
public Object getService (BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws java.util.TooManyListenersException;
public boolean hasService (Class serviceClass); synchronized
public void releaseService (BeanContextChild child, Object requestor, Object service);
public void removeBeanContextServicesListener (BeanContextServicesListener bcsl);
public void revokeService (Class serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow);
// Methods Implementing BeanContextServicesListener
public void serviceAvailable (BeanContextServiceAvailableEvent bcssae);
// Public Methods Overriding BeanContextSupport
public void initialize ();
// Protected Methods Overriding BeanContextSupport
protected void bcsPreDeserializationHook (java.io.ObjectInputStream ois) throws java.io.IOExceptionClassNotFoundException; synchronized
protected void bcsPreSerializationHook (java.io.ObjectOutputStream oos) throws java.io.IOException; synchronized
protected void childJustRemovedHook (Object child, BeanContextSupport.BCSChild bcsc);
protected BeanContextSupport.BCSChild createBCSChild (Object targetChild, Object peer);
// Protected Methods Overriding BeanContextChildSupport
protected void initializeBeanContextResources (); synchronized
protected void releaseBeanContextResources (); synchronized
// Protected Instance Methods
protected boolean addService (Class serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent);
protected BeanContextServicesSupport.BCSSServiceProvider createBCSSServiceProvider (Class sc, BeanContextServiceProvider bcsp);
protected final void fireServiceAdded (BeanContextServiceAvailableEvent bcssae);
protected final void fireServiceAdded (Class serviceClass);
protected final void fireServiceRevoked (BeanContextServiceRevokedEvent bcsre);
protected final void fireServiceRevoked (Class serviceClass, boolean revokeNow);
// Protected Instance Fields
protected transient java.util.ArrayList bcsListeners ;
protected transient BeanContextServicesSupport.BCSSProxyServiceProvider proxy ;
protected transient int serializable ;
protected transient java.util.HashMap services ;
}

Hierarchy: Object-->BeanContextChildSupport(BeanContextChild,BeanContextServicesListener(BeanContextServiceRevokedListener(java.util.EventListener)),Serializable)-->BeanContextSupport(BeanContext(BeanContextChild,java.util.Collection,java.beans.DesignMode,java.beans.Visibility),java.beans.PropertyChangeListener(java.util.EventListener),Serializable,java.beans.VetoableChangeListener(java.util.EventListener))-->BeanContextServicesSupport(BeanContextServices(BeanContext(BeanContextChild,java.util.Collection,java.beans.DesignMode,java.beans.Visibility),BeanContextServicesListener(BeanContextServiceRevokedListener(java.util.EventListener))))

BeanContextServicesSupport.BCSSChildJava 1.2
java.beans.beancontextserializable

This class is used internally by BeanContextServicesSupport to associate additional information with each child of the bean context. It has no public or protected method or fields, but may be customized by subclassing.

protected class BeanContextServicesSupport.BCSSChild extends BeanContextSupport.BCSChild {
// No Constructor
}
BeanContextServicesSupport.BCSSProxyServiceProviderJava 1.2
java.beans.beancontext

This inner class is used internally by BeanContextServicesSupport to properly handle delegation to the services provided by containing bean contexts. It implements the BeanContextServiceProvider interface in terms of the methods of a containing BeanContextServices object.

protected class BeanContextServicesSupport.BCSSProxyServiceProvider implements BeanContextServiceProviderBeanContextServiceRevokedListener {
// No Constructor
// Methods Implementing BeanContextServiceProvider
public java.util.Iterator getCurrentServiceSelectors (BeanContextServices bcs, Class serviceClass);
public Object getService (BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector);
public void releaseService (BeanContextServices bcs, Object requestor, Object service);
// Methods Implementing BeanContextServiceRevokedListener
public void serviceRevoked (BeanContextServiceRevokedEvent bcsre);
}

Type Of: BeanContextServicesSupport.proxy

BeanContextServicesSupport.BCSSServiceProviderJava 1.2
java.beans.beancontextserializable

This inner class is a trivial wrapper around a BeanContextServiceProvider object. Subclasses that want to associate additional information with each service provider can subclass this class and override the createBCSSServiceProvider() method of BeanContextServicesSupport.

protected static class BeanContextServicesSupport.BCSSServiceProvider implements Serializable {
// No Constructor
// Protected Instance Methods
protected BeanContextServiceProvider getServiceProvider ();
// Protected Instance Fields
protected BeanContextServiceProvider serviceProvider ;
}

Returned By: BeanContextServicesSupport.createBCSSServiceProvider()

BeanContextSupportJava 1.2
java.beans.beancontextserializable collection

This class provides a simple, easily customizable implementation of BeanContext. Most bean context implementors find it easier to subclass BeanContextSupport or create a BeanContextSupport delegate object rather than implement the BeanContext interface from scratch.

Bean contexts are often AWT or Swing containers and cannot (because of a method-naming conflict) implement BeanContext. Therefore, a context object implements the BeanContextProxy interface and returns a BeanContext object from its getBeanContextProxy() method. A BeanContextSupport object is a suitable object to return from this method.

Some bean contexts require customized behavior, however, and BeanContextSupport is designed to be easily customized through subclassing. Protected methods such as childJustAddedHook() and validatePendingAdd() are particularly useful when subclassing.

public class BeanContextSupport extends BeanContextChildSupport implements BeanContext, java.beans.PropertyChangeListener, Serializable, java.beans.VetoableChangeListener {
// Public Constructors
public BeanContextSupport ();
public BeanContextSupport (BeanContext peer);
public BeanContextSupport (BeanContext peer, java.util.Locale lcle);
public BeanContextSupport (BeanContext peer, java.util.Locale lcle, boolean dtime);
public BeanContextSupport (BeanContext peer, java.util.Locale lcle, boolean dTime, boolean visible);
// Inner Classes
;
;
// Protected Class Methods
protected static final boolean classEquals (Class first, Class second);
protected static final BeanContextChild getChildBeanContextChild (Object child);
protected static final BeanContextMembershipListener getChildBeanContextMembershipListener (Object child);
protected static final java.beans.PropertyChangeListener getChildPropertyChangeListener (Object child);
protected static final Serializable getChildSerializable (Object child);
protected static final java.beans.VetoableChangeListener getChildVetoableChangeListener (Object child);
protected static final java.beans.Visibility getChildVisibility (Object child);
// Event Registration Methods (by event name)
public void addBeanContextMembershipListener (BeanContextMembershipListener bcml); Implements:BeanContext
public void removeBeanContextMembershipListener (BeanContextMembershipListener bcml); Implements:BeanContext
// Property Accessor Methods (by property name)
public BeanContext getBeanContextPeer (); default:BeanContextSupport
public boolean isDesignTime (); Implements:DesignMode synchronized default:false
public void setDesignTime (boolean dTime); Implements:DesignMode synchronized
public boolean isEmpty (); Implements:Collection default:true
public java.util.Locale getLocale (); synchronized
public void setLocale (java.util.Locale newLocale) throws java.beans.PropertyVetoException; synchronized
public boolean isSerializing (); default:false
// Public Instance Methods
public boolean containsKey (Object o);
public final void readChildren (java.io.ObjectInputStream ois) throws java.io.IOExceptionClassNotFoundException;
public final void writeChildren (java.io.ObjectOutputStream oos) throws java.io.IOException;
// Methods Implementing BeanContext
public void addBeanContextMembershipListener (BeanContextMembershipListener bcml);
public java.net.URL getResource (String name, BeanContextChild bcc);
public java.io.InputStream getResourceAsStream (String name, BeanContextChild bcc);
public Object instantiateChild (String beanName) throws java.io.IOExceptionClassNotFoundException;
public void removeBeanContextMembershipListener (BeanContextMembershipListener bcml);
// Methods Implementing Collection
public boolean add (Object targetChild);
public boolean addAll (java.util.Collection c);
public void clear ();
public boolean contains (Object o);
public boolean containsAll (java.util.Collection c);
public boolean isEmpty (); default:true
public java.util.Iterator iterator ();
public boolean remove (Object targetChild);
public boolean removeAll (java.util.Collection c);
public boolean retainAll (java.util.Collection c);
public int size ();
public Object[ ] toArray ();
public Object[ ] toArray (Object[ ] arry);
// Methods Implementing DesignMode
public boolean isDesignTime (); synchronized default:false
public void setDesignTime (boolean dTime); synchronized
// Methods Implementing PropertyChangeListener
public void propertyChange (java.beans.PropertyChangeEvent pce);
// Methods Implementing VetoableChangeListener
public void vetoableChange (java.beans.PropertyChangeEvent pce) throws java.beans.PropertyVetoException;
// Methods Implementing Visibility
public boolean avoidingGui ();
public void dontUseGui (); synchronized
public boolean needsGui (); synchronized
public void okToUseGui (); synchronized
// Protected Instance Methods
protected java.util.Iterator bcsChildren ();
protected void bcsPreDeserializationHook (java.io.ObjectInputStream ois) throws java.io.IOExceptionClassNotFoundException; empty
protected void bcsPreSerializationHook (java.io.ObjectOutputStream oos) throws java.io.IOException; empty
protected void childDeserializedHook (Object child, BeanContextSupport.BCSChild bcsc);
protected void childJustAddedHook (Object child, BeanContextSupport.BCSChild bcsc); empty
protected void childJustRemovedHook (Object child, BeanContextSupport.BCSChild bcsc); empty
protected final Object[ ] copyChildren ();
protected BeanContextSupport.BCSChild createBCSChild (Object targetChild, Object peer);
protected final void deserialize (java.io.ObjectInputStream ois, java.util.Collection coll) throws java.io.IOExceptionClassNotFoundException;
protected final void fireChildrenAdded (BeanContextMembershipEvent bcme);
protected final void fireChildrenRemoved (BeanContextMembershipEvent bcme);
protected void initialize (); synchronized
protected boolean remove (Object targetChild, boolean callChildSetBC);
protected final void serialize (java.io.ObjectOutputStream oos, java.util.Collection coll) throws java.io.IOException;
protected boolean validatePendingAdd (Object targetChild); constant
protected boolean validatePendingRemove (Object targetChild); constant
// Protected Instance Fields
protected transient java.util.ArrayList bcmListeners ;
protected transient java.util.HashMap children ;
protected boolean designTime ;
protected java.util.Locale locale ;
protected boolean okToUseGui ;
}

Hierarchy: Object-->BeanContextChildSupport(BeanContextChild,BeanContextServicesListener(BeanContextServiceRevokedListener(java.util.EventListener)),Serializable)-->BeanContextSupport(BeanContext(BeanContextChild,java.util.Collection,java.beans.DesignMode,java.beans.Visibility),java.beans.PropertyChangeListener(java.util.EventListener),Serializable,java.beans.VetoableChangeListener(java.util.EventListener))

Subclasses: BeanContextServicesSupport

BeanContextSupport.BCSChildJava 1.2
java.beans.beancontextserializable

This class is used internally by BeanContextSupport to keep track of additional information about its children. In particular, for children that implement the BeanContextProxy interface, it keeps track of the BeanContextChild object associated with the child. This class does not define any public or protected fields or methods. BeanContextSupport subclasses that want to associate additional information with each child can subclass this class and override the createBCSChild() method to instantiate the new subclass.

protected class BeanContextSupport.BCSChild implements Serializable {
// No Constructor
}

Subclasses: BeanContextServicesSupport.BCSSChild

Passed To: BeanContextServicesSupport.childJustRemovedHook(), BeanContextSupport.{childDeserializedHook(), childJustAddedHook(), childJustRemovedHook()}

Returned By: BeanContextServicesSupport.createBCSChild(), BeanContextSupport.createBCSChild()

BeanContextSupport.BCSIteratorJava 1.2
java.beans.beancontext

This class implements the java.util.Iterator interface. An instance of this class is returned by the iterator() method implemented by BeanContextSupport. The remove() method has an empty implementation and does not actually remove a child of the bean context.

protected static final class BeanContextSupport.BCSIterator implements java.util.Iterator {
// No Constructor
// Methods Implementing Iterator
public boolean hasNext ();
public Object next ();
public void remove (); empty
}


Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.