Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.beans.beancontext.BeanContextChildSupport
java.beans.beancontext.BeanContextSupport
java.beans.beancontext.BeanContextServicesSupport
Nested Class Summary | |
protected class | |
protected class | |
protected static class |
Nested classes/interfaces inherited from class java.beans.beancontext.BeanContextSupport | |
BeanContextSupport.BCSChild , BeanContextSupport.BCSIterator |
Field Summary | |
protected ArrayList<E> |
|
protected BeanContextServicesSupport.BCSSProxyServiceProvider | |
protected int |
|
protected HashMap<K,V> |
|
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 | |
| |
| |
| |
| |
|
Method Summary | |
void |
|
boolean |
|
protected boolean |
|
protected void |
|
protected void |
|
protected void |
|
protected BeanContextSupport.BCSChild |
|
protected BeanContextServicesSupport.BCSSServiceProvider |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
BeanContextServices |
|
protected static BeanContextServicesListener |
|
Iterator<E> |
|
Iterator<E> |
|
Object |
|
boolean |
|
void | |
protected void |
|
protected void |
|
void |
|
void | |
void |
|
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
protected ArrayList<E> bcsListeners
A collection of listeners who receive availability and revocation notifications.
protected HashMap<K,V> services
A map of registered services, linking the service class to its associatedBeanContextServicesSupport.BCSSServiceProvider
.
public BeanContextServicesSupport()
Construct aBeanContextServicesSupport
instance.
public BeanContextServicesSupport(BeanContextServices peer)
Construct aBeanContextServicesSupport
instance.
- Parameters:
peer
- the bean context services peer (null
permitted).
public BeanContextServicesSupport(BeanContextServices peer, Locale locale)
Construct aBeanContextServicesSupport
instance.
- Parameters:
peer
- the bean context peer (null
permitted).locale
- the locale (null
permitted, equivalent to the default locale).
public BeanContextServicesSupport(BeanContextServices peer, Locale locale, boolean dtime)
Construct aBeanContextServicesSupport
instance.
- Parameters:
peer
- the bean context peer (null
permitted).locale
- the locale (null
permitted, equivalent to the default locale).dtime
- a flag indicating whether or not the bean context is in design time mode.
public BeanContextServicesSupport(BeanContextServices peer, Locale locale, boolean dtime, boolean visible)
Construct aBeanContextServicesSupport
instance.
- Parameters:
peer
- the bean context peer (null
permitted).locale
- the locale (null
permitted, equivalent to the default locale).dtime
- a flag indicating whether or not the bean context is in design time mode.visible
- initial value of theokToUseGui
flag.
public void addBeanContextServicesListener(BeanContextServicesListener listener)
Adds a new listener for service availability and revocation events.
- Specified by:
- addBeanContextServicesListener in interface BeanContextServices
- Parameters:
listener
- the listener to add.
public boolean addService(Class<T> serviceClass, BeanContextServiceProvider bcsp)
Registers a new service from the specified service provider. The service is internally associated with the service provider and aBeanContextServiceAvailableEvent
is fired. If the service is already registered, then this method instead returnsfalse
. This is equivalent to callingaddService(serviceClass, bcsp, true)
.
- Specified by:
- addService in interface BeanContextServices
- Parameters:
serviceClass
- the class of the service to be registered.bcsp
- the provider of the given service.
- Returns:
- true if the service was registered successfully.
protected boolean addService(Class<T> serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent)
Registers a new service from the specified service provider. The service is internally associated with the service provider and (iffireEvent
is true) aBeanContextServiceAvailableEvent
is fired. If the service is already registered, then this method instead returnsfalse
.
- Parameters:
serviceClass
- the class of the service to be registered.bcsp
- the provider of the given service.fireEvent
- true if a service availability event should be fired.
- Returns:
- true if the service was registered successfully.
protected void bcsPreDeserializationHook(ObjectInputStream ois) throws ClassNotFoundException, IOException
Deserializes any service providers which are serializable. This method is called by thereadObject
method ofBeanContextSupport
prior to deserialization of the children. Subclasses may envelope its behaviour in order to read further serialized data to the stream.
- Overrides:
- bcsPreDeserializationHook in interface BeanContextSupport
- Parameters:
ois
- the stream from which data is being deserialized.
- Throws:
IOException
- if an I/O error occurs.ClassNotFoundException
- if the class of a deserialized object can not be found.
protected void bcsPreSerializationHook(ObjectOutputStream oos) throws IOException
Serializes any service providers which are serializable. This method is called by thewriteObject
method ofBeanContextSupport
prior to serialization of the children. Subclasses may envelope its behaviour in order to add further serialized data to the stream.
- Overrides:
- bcsPreSerializationHook in interface BeanContextSupport
- Parameters:
oos
- the stream to which data is being serialized.
- Throws:
IOException
- if an I/O error occurs.
protected void childJustRemovedHook(Object child, BeanContextSupport.BCSChild bcsc)
Revokes any services used by a child that has just been removed. The superclass (BeanContextSupport
) calls this method when a child has just been successfully removed. Subclasses can extend this method in order to perform additional operations on child removal.
- Overrides:
- childJustRemovedHook in interface BeanContextSupport
- Parameters:
child
- the child being removed.bcsc
- the support object for the child.
protected BeanContextSupport.BCSChild createBCSChild(Object targetChild, Object peer)
Overrides theBeanContextSupport.createBCSChild(Object,Object)
method so as to use aBeanContextServicesSupport.BCSSChild
instead.
- Overrides:
- createBCSChild in interface BeanContextSupport
- Parameters:
targetChild
- the child to create the child for.peer
- the peer which relates to the child if a proxy is used.
- Returns:
- a new instance of
BeanContextServicesSupport.BCSSChild
.
protected BeanContextServicesSupport.BCSSServiceProvider createBCSSServiceProvider(Class<T> sc, BeanContextServiceProvider bcsp)
Provides a hook so that subclasses can replace theBeanContextServicesSupport.BCSSServiceProvider
class, used to store registered service providers, with a subclass without replacing theaddService(Class,BeanContextServiceProvider)
method.
- Parameters:
sc
- the class of service being registered.bcsp
- the provider of the service.
- Returns:
- a instance of
BeanContextServicesSupport.BCSSServiceProvider
wrapping the provider.
protected final void fireServiceAdded(BeanContextServiceAvailableEvent bcssae)
Sends aBeanContextServiceAvailableEvent
to all registered listeners.
- Parameters:
bcssae
- the event to send.
protected final void fireServiceAdded(Class<T> serviceClass)
Sends aBeanContextServiceAvailableEvent
to all registered listeners.
- Parameters:
serviceClass
- the service that is now available.
protected final void fireServiceRevoked(BeanContextServiceRevokedEvent event)
Sends aBeanContextServiceRevokedEvent
to all registered listeners.
- Parameters:
event
- the event to send.
protected final void fireServiceRevoked(Class<T> serviceClass, boolean revokeNow)
Sends aBeanContextServiceRevokedEvent
to all registered listeners.
- Parameters:
serviceClass
- the service that has been revoked.
public BeanContextServices getBeanContextServicesPeer()
Returns the services peer given at construction time, ornull
if no peer was given.
- Returns:
- the
BeanContextServices
peer.
protected static final BeanContextServicesListener getChildBeanContextServicesListener(Object child)
Returnschild
as an instance ofBeanContextServicesListener
, ornull
ifchild
does not implement that interface.
- Parameters:
child
- the child (null
permitted).
- Returns:
- The child cast to
BeanContextServicesListener
.
public Iterator<E> getCurrentServiceClasses()
Returns an iterator over the currently available services.
- Specified by:
- getCurrentServiceClasses in interface BeanContextServices
- Returns:
- an iterator over the currently available services.
public Iterator<E> getCurrentServiceSelectors(Class<T> serviceClass)
Returns an iterator over the service selectors of the service provider for the given service. The iterator is actually obtained by calling theBeanContextServiceProvider.getCurrentServiceSelectors(BeanContextServices,Class)
of the provider itself. If the specified service is not available,null
is returned.
- Specified by:
- getCurrentServiceSelectors in interface BeanContextServices
- Parameters:
serviceClass
- the service whose provider's selectors should be iterated over.
- Returns:
- an
Iterator
over the service selectors of the provider of the given service.
public Object getService(BeanContextChild child, Object requestor, Class<T> serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException
Retrieves the specified service. If a provider for the service is registered in this context, then the request is passed on to the provider and the service returned. Otherwise, the request is delegated to a parentBeanContextServices
, if possible. If the service can not be found at all, thennull
is returned.
- Specified by:
- getService in interface BeanContextServices
- Parameters:
child
- the child obtaining the reference.requestor
- the requestor of the service, which may be the child itself.serviceClass
- the service being requested.serviceSelector
- an additional service-dependent parameter (may benull
if not appropriate).bcsrl
- a listener used to notify the requestor that the service has since been revoked.
- Returns:
- a reference to the service requested, or
null
.
- Throws:
TooManyListenersException
- according to Sun's documentation.
public boolean hasService(Class<T> serviceClass)
Returns true if the specified service is available.
- Specified by:
- hasService in interface BeanContextServices
- Parameters:
serviceClass
- the service to check for.
- Returns:
- true if the service is available.
protected void initializeBeanContextResources()
Subclasses may override this method to allocate resources from the nesting bean context.
- Overrides:
- initializeBeanContextResources in interface BeanContextChildSupport
protected void releaseBeanContextResources()
Relinquishes any resources obtained from the parent context. Specifically, those services obtained from the parent are revoked. Subclasses may override this method to deallocate resources from the nesting bean context.
- Overrides:
- releaseBeanContextResources in interface BeanContextChildSupport
public void releaseService(BeanContextChild child, Object requestor, Object service)
Releases the reference to a service held by aBeanContextChild
(or an arbitrary object associated with it). It simply calls the appropriate method on the underlying provider.
- Specified by:
- releaseService in interface BeanContextServices
- Parameters:
child
- the child who holds the reference.requestor
- the object that requested the reference.service
- the service being released.
public void removeBeanContextServicesListener(BeanContextServicesListener listener)
- Specified by:
- removeBeanContextServicesListener in interface BeanContextServices
public void revokeService(Class<T> serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow)
Revokes the given service. ABeanContextServiceRevokedEvent
is emitted to all registeredBeanContextServiceRevokedListener
s andBeanContextServiceListener
s. IfrevokeCurrentServicesNow
is true, termination of the service is immediate. Otherwise, prior acquisitions of the service by requestors remain valid.
- Specified by:
- revokeService in interface BeanContextServices
- Parameters:
serviceClass
- the service to revoke.bcsp
- the provider of the revoked service.revokeCurrentServicesNow
- true if this is an exceptional circumstance where service should be immediately revoked.
public void serviceAvailable(BeanContextServiceAvailableEvent bcssae)
Called byBeanContextServices
whenever a service is made available.
- Specified by:
- serviceAvailable in interface BeanContextServicesListener
- Overrides:
- serviceAvailable in interface BeanContextChildSupport
- Parameters:
public void serviceRevoked(BeanContextServiceRevokedEvent bcssre)
Called byBeanContextServices.revokeService()
to indicate that a service has been revoked. If you have a reference to such a service, it should be discarded and may no longer function properly.getService()
will no longer work on the specified service class after this event has been fired.This method is meant to be overriden.
BeanContextChildSupport
's implementation does nothing.
- Specified by:
- serviceRevoked in interface BeanContextServiceRevokedListener
- Overrides:
- serviceRevoked in interface BeanContextChildSupport
- Parameters: