Package jadex.commons.beans.beancontext
Class BeanContextServicesSupport
- java.lang.Object
- 
- jadex.commons.beans.beancontext.BeanContextChildSupport
- 
- jadex.commons.beans.beancontext.BeanContextSupport
- 
- jadex.commons.beans.beancontext.BeanContextServicesSupport
 
 
 
- 
- All Implemented Interfaces:
- BeanContext,- BeanContextChild,- BeanContextServiceRevokedListener,- BeanContextServices,- BeanContextServicesListener,- DesignMode,- PropertyChangeListener,- VetoableChangeListener,- Visibility,- java.io.Serializable,- java.lang.Iterable,- java.util.Collection,- java.util.EventListener
 
 public class BeanContextServicesSupport extends BeanContextSupport implements BeanContextServices, java.io.Serializable This support class implementsBeanContextServicesinterface. This class can be used directly, or be a super class of your class, or be a delegate of your implementation that needs to supportBeanContextServicesinterface.- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classBeanContextServicesSupport.BCSSChildEvery child of context is companied with aBCSSChildinstance.protected classBeanContextServicesSupport.BCSSProxyServiceProviderThis class implements theBeanContextServiceProviderinterface by wrapping aBeanContextServices.protected static classBeanContextServicesSupport.BCSSServiceProviderEvery servie registered in this context is companied with aBCSSServiceProviderinstance.- 
Nested classes/interfaces inherited from class jadex.commons.beans.beancontext.BeanContextSupportBeanContextSupport.BCSChild, BeanContextSupport.BCSIterator
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected java.util.ArrayListbcsListenersA list of registeredBeanContextServicesListeners.protected BeanContextServicesSupport.BCSSProxyServiceProviderproxyA proxy service provider that delegates service requests to the parent context.protected intserializableThe number of serializable service providers currently registered.protected java.util.HashMapservicesA map of all registered services - key is service class, value isBCSSServiceProviderobject.- 
Fields inherited from class jadex.commons.beans.beancontext.BeanContextSupportbcmListeners, children, designTime, locale, okToUseGui
 - 
Fields inherited from class jadex.commons.beans.beancontext.BeanContextChildSupportbeanContext, beanContextChildPeer, pcSupport, rejectedSetBCOnce, vcSupport
 - 
Fields inherited from interface jadex.commons.beans.beancontext.BeanContextglobalHierarchyLock
 - 
Fields inherited from interface jadex.commons.beans.DesignModePROPERTYNAME
 
- 
 - 
Constructor SummaryConstructors Constructor Description BeanContextServicesSupport()Constructs a standardBeanContextServicesSupport.BeanContextServicesSupport(BeanContextServices peer)Constructs aBeanContextServicesSupportwhich is a delegate of the given peer.BeanContextServicesSupport(BeanContextServices peer, java.util.Locale locale)Constructs aBeanContextServicesSupportwhich is a delegate of the given peer.BeanContextServicesSupport(BeanContextServices peer, java.util.Locale locale, boolean designTime)Constructs aBeanContextServicesSupportwhich is a delegate of the given peer.BeanContextServicesSupport(BeanContextServices peer, java.util.Locale locale, boolean designTime, boolean okToUseGui)Constructs aBeanContextServicesSupportwhich is a delegate of the given peer.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBeanContextServicesListener(BeanContextServicesListener listener)booleanaddService(java.lang.Class serviceClass, BeanContextServiceProvider provider)Add a service to this context.protected booleanaddService(java.lang.Class serviceClass, BeanContextServiceProvider provider, boolean fireEvent)Add a service to this context.protected voidbcsPreDeserializationHook(java.io.ObjectInputStream ois)Deserializes all serializable services and their providers before the children of this context is deserialized.protected voidbcsPreSerializationHook(java.io.ObjectOutputStream oos)Serializes all serializable services and their providers before the children of this context is serialized.protected voidchildJustRemovedHook(java.lang.Object child, BeanContextSupport.BCSChild bcsChild)This method is called everytime a child is removed from this context.protected BeanContextSupport.BCSChildcreateBCSChild(java.lang.Object child, java.lang.Object proxyPeer)Creates aBCSSChildobject to company the given child.protected BeanContextServicesSupport.BCSSServiceProvidercreateBCSSServiceProvider(java.lang.Class serviceClass, BeanContextServiceProvider provider)Creates aBCSSServiceProviderto company the given service.protected voidfireServiceAdded(BeanContextServiceAvailableEvent event)Fires aBeanContextServiceAvailableEventto registeredBeanContextServicesListeners.protected voidfireServiceAdded(java.lang.Class serviceClass)Fires aBeanContextServiceAvailableEventto registeredBeanContextServicesListeners.protected voidfireServiceRevoked(BeanContextServiceRevokedEvent event)Fires aBeanContextServiceRevokedEventto registeredBeanContextServicesListeners.protected voidfireServiceRevoked(java.lang.Class serviceClass, boolean revokeNow)Fires aBeanContextServiceRevokedEventto registeredBeanContextServicesListeners.BeanContextServicesgetBeanContextServicesPeer()Returns the peer of this context casted asBeanContextServices.protected static BeanContextServicesListenergetChildBeanContextServicesListener(java.lang.Object child)Returns the given child casted toBeanContextServicesListener, or null if it does not implements the interface.java.util.IteratorgetCurrentServiceClasses()Returns an iterator of all registered service classes, withremoved()disabled.java.util.IteratorgetCurrentServiceSelectors(java.lang.Class serviceClass)Returns the service selectors of the specified service.java.lang.ObjectgetService(BeanContextChild child, java.lang.Object requestor, java.lang.Class serviceClass, java.lang.Object serviceSelector, BeanContextServiceRevokedListener bcsrl)Get a service instance on behalf of the specified child of this context, by calling the registered service provider, or by delegating to the parent context.booleanhasService(java.lang.Class serviceClass)Checks whether a service is registed in this context or the parent context.voidinitialize()Initializes all transient fields of this instance, called by constructors andreadObject().protected voidinitializeBeanContextResources()Called after the parent context is updated.protected voidreleaseBeanContextResources()Called before the parent context is updated.voidreleaseService(BeanContextChild child, java.lang.Object requestor, java.lang.Object service)Release a service which has been requested previously.voidremoveBeanContextServicesListener(BeanContextServicesListener listener)voidrevokeService(java.lang.Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow)Revokes a service in this bean context.voidserviceAvailable(BeanContextServiceAvailableEvent event)Notify all listeners and children that implementsBeanContextServicesof the event.voidserviceRevoked(BeanContextServiceRevokedEvent event)Notify all listeners and children that implementsBeanContextServicesof the event.- 
Methods inherited from class jadex.commons.beans.beancontext.BeanContextSupportadd, 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 jadex.commons.beans.beancontext.BeanContextChildSupportaddPropertyChangeListener, addVetoableChangeListener, firePropertyChange, fireVetoableChange, getBeanContext, getBeanContextChildPeer, isDelegated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, validatePendingSetBeanContext
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface jadex.commons.beans.beancontext.BeanContextaddBeanContextMembershipListener, getResource, getResourceAsStream, instantiateChild, removeBeanContextMembershipListener
 - 
Methods inherited from interface jadex.commons.beans.beancontext.BeanContextChildaddPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext
 - 
Methods inherited from interface java.util.Collectionadd, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
 - 
Methods inherited from interface jadex.commons.beans.DesignModeisDesignTime, setDesignTime
 - 
Methods inherited from interface jadex.commons.beans.VisibilityavoidingGui, dontUseGui, needsGui, okToUseGui
 
- 
 
- 
- 
- 
Field Detail- 
servicesprotected transient java.util.HashMap services A map of all registered services - key is service class, value isBCSSServiceProviderobject. All access to this object should be synchronized on itself.
 - 
serializableprotected transient int serializable The number of serializable service providers currently registered.
 - 
proxyprotected transient BeanContextServicesSupport.BCSSProxyServiceProvider proxy A proxy service provider that delegates service requests to the parent context.
 - 
bcsListenersprotected transient java.util.ArrayList bcsListeners A list of registeredBeanContextServicesListeners. All access to this object should be synchronized on itself.
 
- 
 - 
Constructor Detail- 
BeanContextServicesSupportpublic BeanContextServicesSupport() Constructs a standardBeanContextServicesSupport.
 - 
BeanContextServicesSupportpublic BeanContextServicesSupport(BeanContextServices peer) Constructs aBeanContextServicesSupportwhich is a delegate of the given peer.- Parameters:
- peer- the peer of this context
 
 - 
BeanContextServicesSupportpublic BeanContextServicesSupport(BeanContextServices peer, java.util.Locale locale) Constructs aBeanContextServicesSupportwhich is a delegate of the given peer.- Parameters:
- peer- the peer of this context
- locale- the locale of this context
 
 - 
BeanContextServicesSupportpublic BeanContextServicesSupport(BeanContextServices peer, java.util.Locale locale, boolean designTime) Constructs aBeanContextServicesSupportwhich is a delegate of the given peer.- Parameters:
- peer- the peer of this context
- locale- the locale of this context
- designTime- whether in design mode or not
 
 - 
BeanContextServicesSupportpublic BeanContextServicesSupport(BeanContextServices peer, java.util.Locale locale, boolean designTime, boolean okToUseGui) Constructs aBeanContextServicesSupportwhich is a delegate of the given peer.- Parameters:
- peer- the peer of this context
- locale- the locale of this context
- designTime- whether in design mode or not
- okToUseGui- whether GUI is usable or not
 
 
- 
 - 
Method Detail- 
addBeanContextServicesListenerpublic void addBeanContextServicesListener(BeanContextServicesListener listener) - Specified by:
- addBeanContextServicesListenerin interface- BeanContextServices
 
 - 
addServicepublic boolean addService(java.lang.Class serviceClass, BeanContextServiceProvider provider)Add a service to this context.addService(serviceClass, provider, true). - Specified by:
- addServicein interface- BeanContextServices
- See Also:
- BeanContextServices.addService(java.lang.Class, jadex.commons.beans.beancontext.BeanContextServiceProvider)
 - 
addServiceprotected boolean addService(java.lang.Class serviceClass, BeanContextServiceProvider provider, boolean fireEvent)Add a service to this context.- Parameters:
- serviceClass- the service class
- provider- the provider of the service
- fireEvent- the flag indicating to fire event or not
- Returns:
- true if the service is added; or false if the context already has this service
 - 
bcsPreDeserializationHookprotected void bcsPreDeserializationHook(java.io.ObjectInputStream ois) throws java.io.IOException, java.lang.ClassNotFoundExceptionDeserializes all serializable services and their providers before the children of this context is deserialized.int is read, indicating the number of services to read. Then pairs of service class and service provider are read one by one. - Overrides:
- bcsPreDeserializationHookin class- BeanContextSupport
- Parameters:
- ois- the object input stream
- Throws:
- java.io.IOException
- java.lang.ClassNotFoundException
- See Also:
- BeanContextSupport.bcsPreDeserializationHook(java.io.ObjectInputStream)
 - 
bcsPreSerializationHookprotected void bcsPreSerializationHook(java.io.ObjectOutputStream oos) throws java.io.IOExceptionSerializes all serializable services and their providers before the children of this context is serialized.int is writtern, indicating the number of serializable services. Then pairs of service class and service provider are writtern one by one. - Overrides:
- bcsPreSerializationHookin class- BeanContextSupport
- Parameters:
- oos- the object output stream
- Throws:
- java.io.IOException
- See Also:
- BeanContextSupport.bcsPreSerializationHook(java.io.ObjectOutputStream)
 - 
childJustRemovedHookprotected void childJustRemovedHook(java.lang.Object child, BeanContextSupport.BCSChild bcsChild)This method is called everytime a child is removed from this context.- Overrides:
- childJustRemovedHookin class- BeanContextSupport
- Parameters:
- child- the child just removed
- bcsChild- the- BCSChildjust removed
- See Also:
- BeanContextSupport.childJustRemovedHook(java.lang.Object, jadex.commons.beans.beancontext.BeanContextSupport.BCSChild)
 - 
createBCSChildprotected BeanContextSupport.BCSChild createBCSChild(java.lang.Object child, java.lang.Object proxyPeer) Creates aBCSSChildobject to company the given child.- Overrides:
- createBCSChildin class- BeanContextSupport
- Parameters:
- child- the child
- proxyPeer- the proxy peer of the child if there is one
- Returns:
- a BCSChildobject to company the given child
- See Also:
- BeanContextSupport.createBCSChild(java.lang.Object, java.lang.Object)
 
 - 
createBCSSServiceProviderprotected BeanContextServicesSupport.BCSSServiceProvider createBCSSServiceProvider(java.lang.Class serviceClass, BeanContextServiceProvider provider) Creates aBCSSServiceProviderto company the given service.- Parameters:
- serviceClass- the service class
- provider- the service provider
- Returns:
- a BCSSServiceProviderto company the given service
 
 - 
fireServiceAddedprotected final void fireServiceAdded(java.lang.Class serviceClass) Fires aBeanContextServiceAvailableEventto registeredBeanContextServicesListeners.- Parameters:
- serviceClass- the service that has been added
 
 - 
fireServiceAddedprotected final void fireServiceAdded(BeanContextServiceAvailableEvent event) Fires aBeanContextServiceAvailableEventto registeredBeanContextServicesListeners.- Parameters:
- event- the event
 
 - 
fireServiceRevokedprotected final void fireServiceRevoked(java.lang.Class serviceClass, boolean revokeNow)Fires aBeanContextServiceRevokedEventto registeredBeanContextServicesListeners.- Parameters:
- serviceClass- the service that has been revoked
- revokeNow- whether to terminate service immediately
 
 - 
fireServiceRevokedprotected final void fireServiceRevoked(BeanContextServiceRevokedEvent event) Fires aBeanContextServiceRevokedEventto registeredBeanContextServicesListeners.- Parameters:
- event- the event
 
 - 
getBeanContextServicesPeerpublic BeanContextServices getBeanContextServicesPeer() Returns the peer of this context casted asBeanContextServices.- Returns:
- the peer of this context casted as
         BeanContextServices
 
 - 
getChildBeanContextServicesListenerprotected static final BeanContextServicesListener getChildBeanContextServicesListener(java.lang.Object child) Returns the given child casted toBeanContextServicesListener, or null if it does not implements the interface.- Parameters:
- child- a child
- Returns:
- the given child casted to
         BeanContextServicesListener, or null if it does not implements the interface
 
 - 
getCurrentServiceClassespublic java.util.Iterator getCurrentServiceClasses() Returns an iterator of all registered service classes, withremoved()disabled.- Specified by:
- getCurrentServiceClassesin interface- BeanContextServices
- Returns:
- an iterator of all registered service classes
- See Also:
- BeanContextServices.getCurrentServiceClasses()
 
 - 
getCurrentServiceSelectorspublic java.util.Iterator getCurrentServiceSelectors(java.lang.Class serviceClass) Returns the service selectors of the specified service. The iterator'sremove()operation is disabled.- Specified by:
- getCurrentServiceSelectorsin interface- BeanContextServices
- See Also:
- BeanContextServices.getCurrentServiceSelectors(java.lang.Class)
 
 - 
getServicepublic java.lang.Object getService(BeanContextChild child, java.lang.Object requestor, java.lang.Class serviceClass, java.lang.Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws java.util.TooManyListenersException Get a service instance on behalf of the specified child of this context, by calling the registered service provider, or by delegating to the parent context.- Specified by:
- getServicein interface- BeanContextServices
- Parameters:
- child- the child that request service
- requestor- the requestor object
- serviceClass- the service class
- serviceSelector- the service selectors
- bcsrl- the- BeanContextServiceRevokedListener
- Returns:
- a service instance on behalf of the specified child of this context
- Throws:
- java.lang.IllegalArgumentException- if- childis not a child of this context
- java.util.TooManyListenersException
- See Also:
- BeanContextServices.getService(jadex.commons.beans.beancontext.BeanContextChild, java.lang.Object, java.lang.Class, java.lang.Object, jadex.commons.beans.beancontext.BeanContextServiceRevokedListener)
 
 - 
hasServicepublic boolean hasService(java.lang.Class serviceClass) Checks whether a service is registed in this context or the parent context.- Specified by:
- hasServicein interface- BeanContextServices
- Parameters:
- serviceClass- the service class
- Returns:
- true if the service is registered
- See Also:
- BeanContextServices.hasService(java.lang.Class)
 
 - 
initializepublic void initialize() Description copied from class:BeanContextSupportInitializes all transient fields of this instance, called by constructors andreadObject().- Overrides:
- initializein class- BeanContextSupport
 
 - 
initializeBeanContextResourcesprotected void initializeBeanContextResources() Called after the parent context is updated. The implementation checks if the parent context is aBeanContextServices. If it is, then aBCSSProxyServiceProvideris created to delegate service requests to the parent context.- Overrides:
- initializeBeanContextResourcesin class- BeanContextChildSupport
- See Also:
- BeanContextChildSupport.initializeBeanContextResources()
 
 - 
releaseBeanContextResourcesprotected void releaseBeanContextResources() Called before the parent context is updated. The implementation releases any service that is currently provided by the parent context.- Overrides:
- releaseBeanContextResourcesin class- BeanContextChildSupport
- See Also:
- BeanContextChildSupport.releaseBeanContextResources()
 
 - 
releaseServicepublic void releaseService(BeanContextChild child, java.lang.Object requestor, java.lang.Object service) Release a service which has been requested previously.- Specified by:
- releaseServicein interface- BeanContextServices
- Parameters:
- child- the child that request the service
- requestor- the requestor object
- service- the service instance
- Throws:
- java.lang.IllegalArgumentException- if- childis not a child of this context
 
 - 
removeBeanContextServicesListenerpublic void removeBeanContextServicesListener(BeanContextServicesListener listener) - Specified by:
- removeBeanContextServicesListenerin interface- BeanContextServices
 
 - 
revokeServicepublic void revokeService(java.lang.Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow)Revokes a service in this bean context.BeanContextServiceRevokedEvent is fired. All registered service listeners and current service users get notified. - Specified by:
- revokeServicein interface- BeanContextServices
- Parameters:
- serviceClass- the service class
- serviceProvider- the service provider
- revokeCurrentServicesNow- true if service should be terminated immediantly
- See Also:
- BeanContextServices.revokeService(java.lang.Class, jadex.commons.beans.beancontext.BeanContextServiceProvider, boolean)
 - 
serviceAvailablepublic void serviceAvailable(BeanContextServiceAvailableEvent event) Notify all listeners and children that implementsBeanContextServicesof the event.- Specified by:
- serviceAvailablein interface- BeanContextServicesListener
- Overrides:
- serviceAvailablein class- BeanContextChildSupport
- See Also:
- BeanContextServicesListener.serviceAvailable(jadex.commons.beans.beancontext.BeanContextServiceAvailableEvent)
 
 - 
serviceRevokedpublic void serviceRevoked(BeanContextServiceRevokedEvent event) Notify all listeners and children that implementsBeanContextServicesof the event.- Specified by:
- serviceRevokedin interface- BeanContextServiceRevokedListener
- Overrides:
- serviceRevokedin class- BeanContextChildSupport
- See Also:
- BeanContextServiceRevokedListener.serviceRevoked(jadex.commons.beans.beancontext.BeanContextServiceRevokedEvent)
 
 
 
 
 
 
 
 
- 
 
-