java.beans.beancontext
Class BeanContextServicesSupport
- BeanContext, BeanContextChild, BeanContextServiceRevokedListener, BeanContextServices, BeanContextServicesListener, Collection<E>, DesignMode, EventListener, Iterable<E>, PropertyChangeListener, Serializable, VetoableChangeListener, Visibility
This is a helper class for implementing a bean context which
supplies services. It is intended to be used either by
subclassing or by calling methods of this implementation
from another.
void | addBeanContextServicesListener(BeanContextServicesListener listener) - Adds a new listener for service availability and
revocation events.
|
boolean | addService(Class<T> serviceClass, BeanContextServiceProvider bcsp) - Registers a new service from the specified service provider.
|
protected boolean | addService(Class<T> 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
BeanContextSupport.createBCSChild(Object,Object) method
so as to use a BeanContextServicesSupport.BCSSChild instead.
|
protected BeanContextServicesSupport.BCSSServiceProvider | createBCSSServiceProvider(Class<T> sc, BeanContextServiceProvider bcsp) - Provides a hook so that subclasses can replace the
BeanContextServicesSupport.BCSSServiceProvider class, used to store registered
service providers, with a subclass without replacing the
addService(Class,BeanContextServiceProvider) method.
|
protected void | fireServiceAdded(BeanContextServiceAvailableEvent bcssae) - Sends a
BeanContextServiceAvailableEvent to all
registered listeners.
|
protected void | fireServiceAdded(Class<T> serviceClass) - Sends a
BeanContextServiceAvailableEvent to all
registered listeners.
|
protected void | fireServiceRevoked(BeanContextServiceRevokedEvent event) - Sends a
BeanContextServiceRevokedEvent to all
registered listeners.
|
protected void | fireServiceRevoked(Class<T> 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
BeanContextServicesListener , or null if
child does not implement that interface.
|
Iterator<E> | getCurrentServiceClasses() - Returns an iterator over the currently available
services.
|
Iterator<E> | getCurrentServiceSelectors(Class<T> serviceClass) - Returns an iterator over the service selectors of the service
provider for the given service.
|
Object | getService(BeanContextChild child, Object requestor, Class<T> serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) - Retrieves the specified service.
|
boolean | hasService(Class<T> 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
BeanContextChild (or an arbitrary object associated
with it).
|
void | removeBeanContextServicesListener(BeanContextServicesListener listener)
|
void | revokeService(Class<T> serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow) - Revokes the given service.
|
void | serviceAvailable(BeanContextServiceAvailableEvent bcssae)
|
void | serviceRevoked(BeanContextServiceRevokedEvent bcssre) - Called by
BeanContextServices.revokeService() to indicate that a service has been revoked.
|
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 |
addPropertyChangeListener , addVetoableChangeListener , firePropertyChange , fireVetoableChange , getBeanContext , getBeanContextChildPeer , initializeBeanContextResources , isDelegated , releaseBeanContextResources , removePropertyChangeListener , removeVetoableChangeListener , serviceAvailable , serviceRevoked , setBeanContext , validatePendingSetBeanContext |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
bcsListeners
protected ArrayList<E> bcsListeners
A collection of listeners who receive availability
and revocation notifications.
serializable
protected int serializable
The number of serializable service providers.
BeanContextServicesSupport
public BeanContextServicesSupport(BeanContextServices peer,
Locale locale,
boolean dtime)
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.
BeanContextServicesSupport
public BeanContextServicesSupport(BeanContextServices peer,
Locale locale,
boolean dtime,
boolean visible)
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.
addService
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 a BeanContextServiceAvailableEvent
is fired. If
the service is already registered, then this method instead
returns false
. This is equivalent to calling
addService(serviceClass, bcsp, true)
.
- addService in interface BeanContextServices
serviceClass
- the class of the service to be registered.bcsp
- the provider of the given service.
- true if the service was registered successfully.
addService
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 (if fireEvent
is true) a
BeanContextServiceAvailableEvent
is fired. If
the service is already registered, then this method instead
returns false
.
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.
- true if the service was registered successfully.
fireServiceAdded
protected final void fireServiceAdded(Class<T> serviceClass)
Sends a BeanContextServiceAvailableEvent
to all
registered listeners.
serviceClass
- the service that is now available.
fireServiceRevoked
protected final void fireServiceRevoked(Class<T> serviceClass,
boolean revokeNow)
Sends a BeanContextServiceRevokedEvent
to all
registered listeners.
serviceClass
- the service that has been revoked.
getService
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 parent
BeanContextServices
, if possible.
If the service can not be found at all, then
null
is returned.
- getService in interface BeanContextServices
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.
- a reference to the service requested, or
null
.
BeanContextServicesSupport.java --
Copyright (C) 2003, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.