java.beans.beancontext
public class BeanContextServicesSupport extends BeanContextSupport implements BeanContextServices
Since: 1.2
Nested Class Summary | |
---|---|
protected class | BeanContextServicesSupport.BCSSChild |
protected class | BeanContextServicesSupport.BCSSProxyServiceProvider |
protected static class | BeanContextServicesSupport.BCSSServiceProvider |
Field Summary | |
---|---|
protected ArrayList | bcsListeners
A collection of listeners who receive availability
and revocation notifications. |
protected BeanContextServicesSupport.BCSSProxyServiceProvider | proxy |
protected int | serializable
The number of serializable service providers. |
protected HashMap | services
A map of registered services, linking the service
class to its associated {@link BCSSServiceProvider}. |
Constructor Summary | |
---|---|
BeanContextServicesSupport()
Construct a {@link BeanContextServicesSupport} instance. | |
BeanContextServicesSupport(BeanContextServices peer)
Construct a {@link BeanContextServicesSupport} instance.
| |
BeanContextServicesSupport(BeanContextServices peer, Locale locale)
Construct a {@link BeanContextServicesSupport} instance.
| |
BeanContextServicesSupport(BeanContextServices peer, Locale locale, boolean dtime)
Construct a {@link BeanContextServicesSupport} instance.
| |
BeanContextServicesSupport(BeanContextServices peer, Locale locale, boolean dtime, boolean visible)
Construct a {@link BeanContextServicesSupport} instance.
|
Method Summary | |
---|---|
void | addBeanContextServicesListener(BeanContextServicesListener listener)
Adds a new listener for service availability and
revocation events.
|
boolean | addService(Class serviceClass, BeanContextServiceProvider bcsp)
Registers a new service from the specified service provider.
|
protected boolean | addService(Class serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent)
Registers a new service from the specified service provider.
|
protected void | bcsPreDeserializationHook(ObjectInputStream ois)
Deserializes any service providers which are serializable. |
protected void | bcsPreSerializationHook(ObjectOutputStream oos)
Serializes any service providers which are serializable. |
protected void | childJustRemovedHook(Object child, BeanContextSupport.BCSChild bcsc)
Revokes any services used by a child that has just been removed.
|
protected BeanContextSupport.BCSChild | createBCSChild(Object targetChild, Object peer)
Overrides the {@link BeanContextSupport#createBCSChild} method
so as to use a {@link BCSSChild} instead.
|
protected BeanContextServicesSupport.BCSSServiceProvider | createBCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp)
Provides a hook so that subclasses can replace the
{@link BCSSServiceProvider} class, used to store registered
service providers, with a subclass without replacing the
{@link #addService(Class, BeanContextServiceProvider)} method.
|
protected void | fireServiceAdded(BeanContextServiceAvailableEvent bcssae)
Sends a BeanContextServiceAvailableEvent to all
registered listeners.
|
protected void | fireServiceAdded(Class serviceClass)
Sends a BeanContextServiceAvailableEvent to all
registered listeners.
|
protected void | fireServiceRevoked(BeanContextServiceRevokedEvent event)
Sends a BeanContextServiceRevokedEvent to all
registered listeners.
|
protected void | fireServiceRevoked(Class serviceClass, boolean revokeNow)
Sends a BeanContextServiceRevokedEvent to all
registered listeners.
|
BeanContextServices | getBeanContextServicesPeer()
Returns the services peer given at construction time,
or null if no peer was given.
|
protected static BeanContextServicesListener | getChildBeanContextServicesListener(Object child)
Returns child as an instance of
{@link BeanContextServicesListener}, or null if
child does not implement that interface.
|
Iterator | getCurrentServiceClasses()
Returns an iterator over the currently available
services.
|
Iterator | getCurrentServiceSelectors(Class serviceClass)
Returns an iterator over the service selectors of the service
provider for the given service. |
Object | getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl)
Retrieves the specified service. |
boolean | hasService(Class serviceClass)
Returns true if the specified service is available.
|
void | initialize() |
protected void | initializeBeanContextResources()
Subclasses may override this method to allocate resources
from the nesting bean context. |
protected void | releaseBeanContextResources()
Relinquishes any resources obtained from the parent context.
|
void | releaseService(BeanContextChild child, Object requestor, Object service)
Releases the reference to a service held by a
{@link BeanContextChild} (or an arbitrary object associated
with it). |
void | removeBeanContextServicesListener(BeanContextServicesListener listener) |
void | revokeService(Class serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow)
Revokes the given service. |
void | serviceAvailable(BeanContextServiceAvailableEvent bcssae) |
void | serviceRevoked(BeanContextServiceRevokedEvent bcssre) |
Parameters: peer the bean context services peer (null
permitted).
Parameters: peer the bean context peer (null
permitted). locale the locale (null
permitted, equivalent to
the default locale).
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.
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 the okToUseGui
flag.
Parameters: listener the listener to add.
BeanContextServiceAvailableEvent
is fired. If
the service is already registered, then this method instead
returns false
. This is equivalent to calling
addService(serviceClass, bcsp, true)
.
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.
See Also: BeanContextServicesSupport
fireEvent
is true) a
BeanContextServiceAvailableEvent
is fired. If
the service is already registered, then this method instead
returns false
.
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.
readObject
method of
{@link BeanContextSupport} prior to deserialization of the children.
Subclasses may envelope its behaviour in order to read further
serialized data to the stream.
Parameters: oos 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.
writeObject
method of
{@link BeanContextSupport} prior to serialization of the children.
Subclasses may envelope its behaviour in order to add further
serialized data to the stream.
Parameters: oos the stream to which data is being serialized.
Throws: IOException if an I/O error occurs.
Parameters: child the child being removed. bcsc the support object for the child.
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 {@link BCSSChild}.
Parameters: sc the class of service being registered. bcsp the provider of the service.
Returns: a instance of {@link BCSSServiceProvider} wrapping the provider.
BeanContextServiceAvailableEvent
to all
registered listeners.
Parameters: bcssae the event to send.
BeanContextServiceAvailableEvent
to all
registered listeners.
Parameters: serviceClass the service that is now available.
See Also: fireServiceAdded
BeanContextServiceRevokedEvent
to all
registered listeners.
Parameters: event the event to send.
BeanContextServiceRevokedEvent
to all
registered listeners.
Parameters: serviceClass the service that has been revoked.
See Also: fireServiceRevoked
null
if no peer was given.
Returns: the {@link BeanContextServices} peer.
child
as an instance of
{@link BeanContextServicesListener}, or null
if
child
does not implement that interface.
Parameters: child the child (null
permitted).
Returns: The child cast to {@link BeanContextServicesListener}.
Returns: an iterator over the currently available services.
null
is returned.
Parameters: serviceClass the service whose provider's selectors should be iterated over.
Returns: an {@link Iterator} over the service selectors of the provider of the given service.
null
is returned.
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 be null
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.
Parameters: serviceClass the service to check for.
Returns: true if the service is available.
Parameters: child the child who holds the reference. requestor the object that requested the reference. service the service being released.
revokeCurrentServicesNow
is true, termination of the service is immediate. Otherwise, prior
acquisitions of the service by requestors remain valid.
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.