textbender.g.beans.beancontext
Class ServiceRegistryCIU
java.lang.Object
java.beans.beancontext.BeanContextChildSupport
java.beans.beancontext.BeanContextSupport
java.beans.beancontext.BeanContextServicesSupport
ServiceRegistryCIU
- All Implemented Interfaces:
- BeanContext, BeanContextChild, BeanContextServiceRevokedListener, BeanContextServices, BeanContextServicesListener, DesignMode, PropertyChangeListener, VetoableChangeListener, Visibility, Serializable, Iterable, Collection, EventListener
public final class ServiceRegistryCIU
- extends BeanContextServicesSupport
A simplified registry for childless, irrevocable and unique services.
Service clients are not registered as BeanContextChildren,
so services are 'childless'. Once registered, they may never be revoked.
And service classes are unique; there is at most one instance of each.
Providers register each service by calling
addSimpleService().
Clients listen for these registrations via
addBeanContextServicesListener(),
and subsequently fetch the services they need via
getService().
Thread safe, though individual services are not (unless you know better).
- See Also:
- Serialized Form
Methods inherited from class java.beans.beancontext.BeanContextServicesSupport |
addBeanContextServicesListener, addService, addService, bcsPreDeserializationHook, bcsPreSerializationHook, childJustRemovedHook, createBCSChild, createBCSSServiceProvider, fireServiceAdded, fireServiceAdded, fireServiceRevoked, fireServiceRevoked, getBeanContextServicesPeer, getChildBeanContextServicesListener, getCurrentServiceClasses, getCurrentServiceSelectors, getService, hasService, initialize, initializeBeanContextResources, releaseBeanContextResources, releaseService, removeBeanContextServicesListener, serviceAvailable, serviceRevoked |
Methods inherited from class java.beans.beancontext.BeanContextSupport |
add, addAll, addBeanContextMembershipListener, avoidingGui, bcsChildren, childDeserializedHook, childJustAddedHook, classEquals, clear, contains, containsAll, containsKey, copyChildren, deserialize, dontUseGui, fireChildrenAdded, fireChildrenRemoved, getBeanContextPeer, getChildBeanContextChild, getChildBeanContextMembershipListener, getChildPropertyChangeListener, getChildSerializable, getChildVetoableChangeListener, getChildVisibility, getLocale, getResource, getResourceAsStream, 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, isDelegated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, validatePendingSetBeanContext |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
ServiceRegistryCIU
public ServiceRegistryCIU()
i
public static ServiceRegistryCIU i()
- The common instance of ServiceRegistryCIU. Other instances may be created,
but one is enough for most purposes.
addBeanContextServicesListener
public void addBeanContextServicesListener(BeanContextServicesListener listener,
boolean fireUp)
- Registers a new bean context services listener.
- Parameters:
listener
- to registerfireUp
- if true,
listener is immediately fired up
to the current state; otherwise it is not
addSimpleService
public void addSimpleService(Class serviceClass,
Object service)
- Adds a new service to the registry.
Once added, the service cannot be removed or revoked.
- Parameters:
serviceClass
- specifying the Java class of the service,
or one of its parent classes/interfaces (for which the service
will be the sole registrant)service
- instance that actually implements the service class
(of which the service must be an instance)
- Throws:
IllegalStateException
- if a service was already added for that serviceClass
getService
public Object getService(Class serviceClass)
- Returns a service previously added
to the registry.
- Parameters:
serviceClass
- per addSimpleService()
- Returns:
- service; or null if none yet added to the registry
revokeService
public void revokeService(Class serviceClass,
BeanContextServiceProvider serviceProvider,
boolean revokeCurrentServicesNow)
- Specified by:
revokeService
in interface BeanContextServices
- Overrides:
revokeService
in class BeanContextServicesSupport