java.beans.beancontext

Class BeanContextServicesSupport

Implemented Interfaces:
BeanContext, BeanContextChild, BeanContextServiceRevokedListener, BeanContextServices, BeanContextServicesListener, Collection<E>, DesignMode, EventListener, Iterable<T>, PropertyChangeListener, Serializable, VetoableChangeListener, Visibility

public class BeanContextServicesSupport
extends BeanContextSupport
implements BeanContextServices

This helper class provides a utility implementation of the java.beans.beancontext.BeanContextServices interface.

Since this class directly implements the BeanContextServices interface, the class can, and is intended to be used either by subclassing this implementation, or via delegation of an instance of this class from another through the BeanContextProxy interface.

Since:
1.2
See Also:
Serialized Form

Nested Class Summary

protected class
BeanContextServicesSupport.BCSSChild
protected class
BeanContextServicesSupport.BCSSProxyServiceProvider
protected static class
BeanContextServicesSupport.BCSSServiceProvider
subclasses may subclass this nested class to add behaviors for each BeanContextServicesProvider.

Nested classes/interfaces inherited from class java.beans.beancontext.BeanContextSupport

BeanContextSupport.BCSChild, BeanContextSupport.BCSIterator

Field Summary

protected ArrayList<E>
bcsListeners
List of BeanContextServicesListener objects.
protected BeanContextServicesSupport.BCSSProxyServiceProvider
proxy
Delegate for the BeanContextServiceProvider.
protected int
serializable
The number of instances of a serializable BeanContextServceProvider.
protected HashMap<K,V>
services
all accesses to the protected transient HashMap services field should be synchronized on that object

Fields inherited from class java.beans.beancontext.BeanContextSupport

bcmListeners, children, designTime, locale, okToUseGui

Fields inherited from class java.beans.beancontext.BeanContextChildSupport

beanContext, beanContextChildPeer, pcSupport, rejectedSetBCOnce, vcSupport

Fields inherited from interface java.beans.beancontext.BeanContext

globalHierarchyLock

Fields inherited from interface java.beans.DesignMode

PROPERTYNAME

Constructor Summary

BeanContextServicesSupport()
Create an instance that is not a delegate of another object
BeanContextServicesSupport(BeanContextServices peer)
Create an instance with a peer
BeanContextServicesSupport(BeanContextServices peer, Locale lcle)
Create an instance using the specified locale
BeanContextServicesSupport(BeanContextServices peer, Locale lcle, boolean dtime)
Create an instance using the specified Locale and design mode.
BeanContextServicesSupport(BeanContextServices peer, Locale lcle, boolean dTime, boolean visible)
Construct a BeanContextServicesSupport instance

Method Summary

void
addBeanContextServicesListener(BeanContextServicesListener bcsl)
add a BeanContextServicesListener
boolean
addService(Class<T> serviceClass, BeanContextServiceProvider bcsp)
add a service
protected boolean
addService(Class<T> serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent)
add a service
protected void
bcsPreDeserializationHook(ObjectInputStream ois)
called from BeanContextSupport readObject before it deserializes the children ...
protected void
bcsPreSerializationHook(ObjectOutputStream oos)
called from BeanContextSupport writeObject before it serializes the children ...
protected void
childJustRemovedHook(Object child, BeanContextSupport.BCSChild bcsc)
called from superclass child removal operations after a child has been successfully removed.
protected BeanContextSupport.BCSChild
createBCSChild(Object targetChild, Object peer)
Subclasses can override this method to insert their own subclass of Child without having to override add() or the other Collection methods that add children to the set.
protected BeanContextServicesSupport.BCSSServiceProvider
createBCSSServiceProvider(Class<T> sc, BeanContextServiceProvider bcsp)
subclasses can override this method to create new subclasses of BCSSServiceProvider without having to overrride addService() in order to instantiate.
protected void
fireServiceAdded(BeanContextServiceAvailableEvent bcssae)
Fires a BeanContextServiceAvailableEvent indicating that a new service has become available.
protected void
fireServiceAdded(Class<T> serviceClass)
Fires a BeanContextServiceEvent notifying of a new service.
protected void
fireServiceRevoked(BeanContextServiceRevokedEvent bcsre)
Fires a BeanContextServiceEvent notifying of a service being revoked.
protected void
fireServiceRevoked(Class<T> serviceClass, boolean revokeNow)
Fires a BeanContextServiceRevokedEvent indicating that a particular service is no longer available.
BeanContextServices
getBeanContextServicesPeer()
Gets the BeanContextServices associated with this BeanContextServicesSupport.
protected static BeanContextServicesListener
getChildBeanContextServicesListener(Object child)
Gets the BeanContextServicesListener (if any) of the specified child.
Iterator<E>
getCurrentServiceClasses()
Iterator<E>
getCurrentServiceSelectors(Class<T> serviceClass)
Object
getService(BeanContextChild child, Object requestor, Class<T> serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl)
obtain a service which may be delegated
boolean
hasService(Class<T> serviceClass)
has a service, which may be delegated
void
initialize()
called by BeanContextSupport superclass during construction and deserialization to initialize subclass transient state.
protected void
initializeBeanContextResources()
called from setBeanContext to notify a BeanContextChild to allocate resources obtained from the nesting BeanContext.
protected void
releaseBeanContextResources()
called from setBeanContext to notify a BeanContextChild to release resources obtained from the nesting BeanContext.
void
releaseService(BeanContextChild child, Object requestor, Object service)
release a service
void
removeBeanContextServicesListener(BeanContextServicesListener bcsl)
remove a BeanContextServicesListener
void
revokeService(Class<T> serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow)
remove a service
void
serviceAvailable(BeanContextServiceAvailableEvent bcssae)
BeanContextServicesListener callback, propagates event to all currently registered listeners and BeanContextServices children, if this BeanContextService does not already implement this service itself.
void
serviceRevoked(BeanContextServiceRevokedEvent bcssre)
BeanContextServicesListener callback, propagates event to all currently registered listeners and BeanContextServices children, if this BeanContextService does not already implement this service itself.

Methods inherited from class java.beans.beancontext.BeanContextSupport

add, addAll, addBeanContextMembershipListener, avoidingGui, bcsChildren, bcsPreDeserializationHook, bcsPreSerializationHook, childDeserializedHook, childJustAddedHook, childJustRemovedHook, classEquals, clear, contains, containsAll, containsKey, copyChildren, createBCSChild, deserialize, dontUseGui, fireChildrenAdded, fireChildrenRemoved, getBeanContextPeer, getChildBeanContextChild, getChildBeanContextMembershipListener, getChildPropertyChangeListener, getChildSerializable, getChildVetoableChangeListener, getChildVisibility, getLocale, getResource, getResourceAsStream, initialize, instantiateChild, isDesignTime, isEmpty, isSerializing, iterator, needsGui, okToUseGui, propertyChange, readChildren, remove, remove, removeAll, removeBeanContextMembershipListener, retainAll, serialize, setDesignTime, setLocale, size, toArray, toArray, validatePendingAdd, validatePendingRemove, vetoableChange, writeChildren

Methods inherited from class java.beans.beancontext.BeanContextChildSupport

addPropertyChangeListener, addVetoableChangeListener, firePropertyChange, fireVetoableChange, getBeanContext, getBeanContextChildPeer, initializeBeanContextResources, isDelegated, releaseBeanContextResources, removePropertyChangeListener, removeVetoableChangeListener, serviceAvailable, serviceRevoked, setBeanContext, validatePendingSetBeanContext

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

bcsListeners

protected ArrayList<E> bcsListeners
List of BeanContextServicesListener objects.

proxy

protected BeanContextServicesSupport.BCSSProxyServiceProvider proxy
Delegate for the BeanContextServiceProvider.

serializable

protected int serializable
The number of instances of a serializable BeanContextServceProvider.

services

protected HashMap<K,V> services
all accesses to the protected transient HashMap services field should be synchronized on that object

Constructor Details

BeanContextServicesSupport

public BeanContextServicesSupport()
Create an instance that is not a delegate of another object
Usages and Demos :

View More Examples of BeanContextServicesSupport()

BeanContextServicesSupport

public BeanContextServicesSupport(BeanContextServices peer)
Create an instance with a peer
Parameters:
peer - The peer BeanContext we are supplying an implementation for, if null the this object is its own peer

BeanContextServicesSupport

public BeanContextServicesSupport(BeanContextServices peer,
                                  Locale lcle)
Create an instance using the specified locale
Parameters:
peer - The peer BeanContext we are supplying an implementation for, if null the this object is its own peer
lcle - The current Locale for this BeanContext.

BeanContextServicesSupport

public BeanContextServicesSupport(BeanContextServices peer,
                                  Locale lcle,
                                  boolean dtime)
Create an instance using the specified Locale and design mode.
Parameters:
peer - The peer BeanContext we are supplying an implementation for, if null the this object is its own peer
lcle - The current Locale for this BeanContext.
dtime - The initial state, true if in design mode, false if runtime.

BeanContextServicesSupport

public BeanContextServicesSupport(BeanContextServices peer,
                                  Locale lcle,
                                  boolean dTime,
                                  boolean visible)
Construct a BeanContextServicesSupport instance
Parameters:
peer - The peer BeanContext we are supplying an implementation for, if null the this object is its own peer
lcle - The current Locale for this BeanContext.
visible - The initial visibility.

Method Details

addBeanContextServicesListener

public void addBeanContextServicesListener(BeanContextServicesListener bcsl)
add a BeanContextServicesListener
Specified by:
addBeanContextServicesListener in interface BeanContextServices
Usages and Demos :

View More Examples of addBeanContextServicesListener(BeanContextServicesListener bcsl)

addService

public boolean addService(Class<T> serviceClass,
                          BeanContextServiceProvider bcsp)
add a service
Specified by:
addService in interface BeanContextServices
Usages and Demos :

View More Examples of addService(Class serviceClass,BeanContextServiceProvider bcsp)

addService

protected boolean addService(Class<T> serviceClass,
                             BeanContextServiceProvider bcsp,
                             boolean fireEvent)
add a service

bcsPreDeserializationHook

protected void bcsPreDeserializationHook(ObjectInputStream ois)
            throws IOException,
                   ClassNotFoundException
called from BeanContextSupport readObject before it deserializes the children ... This class will deserialize any Serializable BeanContextServiceProviders serialized earlier thus making them available to the children when they deserialized. subclasses may envelope this method to insert their own serialization processing that has to occur prior to serialization of the children
Overrides:
bcsPreDeserializationHook in interface BeanContextSupport

bcsPreSerializationHook

protected void bcsPreSerializationHook(ObjectOutputStream oos)
            throws IOException
called from BeanContextSupport writeObject before it serializes the children ... This class will serialize any Serializable BeanContextServiceProviders herein. subclasses may envelope this method to insert their own serialization processing that has to occur prior to serialization of the children
Overrides:
bcsPreSerializationHook in interface BeanContextSupport

childJustRemovedHook

protected void childJustRemovedHook(Object child,
                                    BeanContextSupport.BCSChild bcsc)
called from superclass child removal operations after a child has been successfully removed. called with child synchronized. This subclass uses this hook to immediately revoke any services being used by this child if it is a BeanContextChild. subclasses may envelope this method in order to implement their own child removal side-effects.
Overrides:
childJustRemovedHook in interface BeanContextSupport

createBCSChild

protected BeanContextSupport.BCSChild createBCSChild(Object targetChild,
                                                     Object peer)
Subclasses can override this method to insert their own subclass of Child without having to override add() or the other Collection methods that add children to the set.
Overrides:
createBCSChild in interface BeanContextSupport
Parameters:
targetChild - the child to create the Child on behalf of
peer - the peer if the targetChild and peer are related by BeanContextProxy

createBCSSServiceProvider

protected BeanContextServicesSupport.BCSSServiceProvider createBCSSServiceProvider(Class<T> sc,
                                                                                   BeanContextServiceProvider bcsp)
subclasses can override this method to create new subclasses of BCSSServiceProvider without having to overrride addService() in order to instantiate.

fireServiceAdded

protected final void fireServiceAdded(BeanContextServiceAvailableEvent bcssae)
Fires a BeanContextServiceAvailableEvent indicating that a new service has become available.
Parameters:
bcssae - the BeanContextServiceAvailableEvent

fireServiceAdded

protected final void fireServiceAdded(Class<T> serviceClass)
Fires a BeanContextServiceEvent notifying of a new service.

fireServiceRevoked

protected final void fireServiceRevoked(BeanContextServiceRevokedEvent bcsre)
Fires a BeanContextServiceEvent notifying of a service being revoked.
Parameters:
bcsre - the BeanContextServiceRevokedEvent

fireServiceRevoked

protected final void fireServiceRevoked(Class<T> serviceClass,
                                        boolean revokeNow)
Fires a BeanContextServiceRevokedEvent indicating that a particular service is no longer available.

getBeanContextServicesPeer

public BeanContextServices getBeanContextServicesPeer()
Gets the BeanContextServices associated with this BeanContextServicesSupport.
Returns:
the instance of BeanContext this object is providing the implementation for.

getChildBeanContextServicesListener

protected static final BeanContextServicesListener getChildBeanContextServicesListener(Object child)
Gets the BeanContextServicesListener (if any) of the specified child.
Parameters:
child - the specified child
Returns:
the BeanContextServicesListener (if any) of the specified child

getCurrentServiceClasses

public Iterator<E> getCurrentServiceClasses()
Specified by:
getCurrentServiceClasses in interface BeanContextServices
Returns:
an iterator for all the currently registered service classes.

getCurrentServiceSelectors

public Iterator<E> getCurrentServiceSelectors(Class<T> serviceClass)
Specified by:
getCurrentServiceSelectors in interface BeanContextServices
Returns:
an iterator for all the currently available service selectors (if any) available for the specified service.

getService

public Object getService(BeanContextChild child,
                         Object requestor,
                         Class<T> serviceClass,
                         Object serviceSelector,
                         BeanContextServiceRevokedListener bcsrl)
            throws TooManyListenersException
obtain a service which may be delegated
Specified by:
getService in interface BeanContextServices

hasService

public boolean hasService(Class<T> serviceClass)
has a service, which may be delegated
Specified by:
hasService in interface BeanContextServices

initialize

public void initialize()
called by BeanContextSupport superclass during construction and deserialization to initialize subclass transient state. subclasses may envelope this method, but should not override it or call it directly.
Overrides:
initialize in interface BeanContextSupport

initializeBeanContextResources

protected void initializeBeanContextResources()
called from setBeanContext to notify a BeanContextChild to allocate resources obtained from the nesting BeanContext. subclasses may envelope this method to implement their own semantics.
Overrides:
initializeBeanContextResources in interface BeanContextChildSupport

releaseBeanContextResources

protected void releaseBeanContextResources()
called from setBeanContext to notify a BeanContextChild to release resources obtained from the nesting BeanContext. This method revokes any services obtained from its parent. subclasses may envelope this method to implement their own semantics.
Overrides:
releaseBeanContextResources in interface BeanContextChildSupport

releaseService

public void releaseService(BeanContextChild child,
                           Object requestor,
                           Object service)
release a service
Specified by:
releaseService in interface BeanContextServices

removeBeanContextServicesListener

public void removeBeanContextServicesListener(BeanContextServicesListener bcsl)
remove a BeanContextServicesListener
Specified by:
removeBeanContextServicesListener in interface BeanContextServices

revokeService

public void revokeService(Class<T> serviceClass,
                          BeanContextServiceProvider bcsp,
                          boolean revokeCurrentServicesNow)
remove a service
Specified by:
revokeService in interface BeanContextServices

serviceAvailable

public void serviceAvailable(BeanContextServiceAvailableEvent bcssae)
BeanContextServicesListener callback, propagates event to all currently registered listeners and BeanContextServices children, if this BeanContextService does not already implement this service itself. subclasses may override or envelope this method to implement their own propagation semantics.
Specified by:
serviceAvailable in interface BeanContextServicesListener
Overrides:
serviceAvailable in interface BeanContextChildSupport

serviceRevoked

public void serviceRevoked(BeanContextServiceRevokedEvent bcssre)
BeanContextServicesListener callback, propagates event to all currently registered listeners and BeanContextServices children, if this BeanContextService does not already implement this service itself. subclasses may override or envelope this method to implement their own propagation semantics.
Specified by:
serviceRevoked in interface BeanContextServiceRevokedListener
Overrides:
serviceRevoked in interface BeanContextChildSupport