Class WrapperService
- java.lang.Object
-
- com.tangosol.net.WrapperService
-
- All Implemented Interfaces:
ClassLoaderAware,Service,Controllable,Service
- Direct Known Subclasses:
WrapperCacheService,WrapperInvocationService
public class WrapperService extends Object implements Service
Service implementation that delegates to a wrapped Service instance.- Author:
- jh 2010.03.17
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.tangosol.net.Service
Service.MemberJoinAction
-
-
Constructor Summary
Constructors Constructor Description WrapperService(Service service)Create a new WrapperService that delegates to the given Service instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMemberListener(MemberListener listener)Add a Member listener.voidaddServiceListener(ServiceListener listener)Register a ServiceListener that will receive events pertaining to the lifecycle of this Service.voidconfigure(XmlElement xml)Configure the controllable service.ClustergetCluster()Return the Cluster object that this Service is a part of.ClassLoadergetContextClassLoader()Retrieve the context ClassLoader for this object.ServiceDependenciesgetDependencies()Return the service's dependencies.ServiceInfogetInfo()Return the ServiceInfo object for this Service.intgetMinimumServiceVersion()Return the minimum version for the members in this set.ResourceRegistrygetResourceRegistry()Retrieves a Service scopedResourceRegistry.SerializergetSerializer()Return a Serializer used by this Service.ServicegetService()Return the wrapped Service.ObjectgetUserContext()Return the user context object associated with this Service.booleanisRunning()Determine whether or not the controllable service is running.booleanisSuspended()Returnstrueif this service is currently suspended.booleanisVersionCompatible(int nVersion)Check whether the members of this service run a version that is greater than or equal to the specified version.booleanisVersionCompatible(int nYear, int nMonth, int nPatch)Check whether the members of this service run a version that is greater than or equal to the specified version.booleanisVersionCompatible(int nMajor, int nMinor, int nMicro, int nPatchSet, int nPatch)Check whether the members of this service run a version that is greater than or equal to the specified version.booleanisVersionCompatible(IntPredicate predicate)Check whether the members of this service run a minimum service version that matches a specifiedIntPredicate.voidremoveMemberListener(MemberListener listener)Remove a Member listener.voidremoveServiceListener(ServiceListener listener)Unregister a ServiceListener from this ConnectionManager.voidsetContextClassLoader(ClassLoader loader)Specify the context ClassLoader for this object.voidsetDependencies(ServiceDependencies deps)Configure the Service.voidsetUserContext(Object oCtx)Associate a user context object with this Service.voidshutdown()Stop the controllable service.voidstart()Start the controllable service.voidstop()Hard-stop the controllable service.StringtoString()
-
-
-
Field Detail
-
m_service
protected Service m_service
The (wrapped) Service.
-
-
Constructor Detail
-
WrapperService
public WrapperService(Service service)
Create a new WrapperService that delegates to the given Service instance.- Parameters:
service- the Service to wrap
-
-
Method Detail
-
getDependencies
public ServiceDependencies getDependencies()
Return the service's dependencies.- Specified by:
getDependenciesin interfaceService- Returns:
- the service's dependencies
-
getCluster
public Cluster getCluster()
Return the Cluster object that this Service is a part of.- Specified by:
getClusterin interfaceService- Returns:
- the Cluster object
-
getInfo
public ServiceInfo getInfo()
Return the ServiceInfo object for this Service.
-
addMemberListener
public void addMemberListener(MemberListener listener)
Add a Member listener.MemberListeners will be invoked in the order in which they are registered.
- Specified by:
addMemberListenerin interfaceService- Parameters:
listener- theMemberListenerto add
-
removeMemberListener
public void removeMemberListener(MemberListener listener)
Remove a Member listener.- Specified by:
removeMemberListenerin interfaceService- Parameters:
listener- theMemberListenerto remove
-
getUserContext
public Object getUserContext()
Return the user context object associated with this Service.The data type and semantics of this context object are entirely application specific and are opaque to the Service itself.
- Specified by:
getUserContextin interfaceService- Returns:
- an associated user context object or null if a context has not been set
-
setUserContext
public void setUserContext(Object oCtx)
Associate a user context object with this Service.- Specified by:
setUserContextin interfaceService- Parameters:
oCtx- a user context object
-
getSerializer
public Serializer getSerializer()
Return a Serializer used by this Service.- Specified by:
getSerializerin interfaceService- Returns:
- the Serializer object
-
addServiceListener
public void addServiceListener(ServiceListener listener)
Register a ServiceListener that will receive events pertaining to the lifecycle of this Service.- Specified by:
addServiceListenerin interfaceService- Parameters:
listener- the new ServiceListener to register; if the listener has already been registered, this method has no effect
-
removeServiceListener
public void removeServiceListener(ServiceListener listener)
Unregister a ServiceListener from this ConnectionManager.After a ServiceListener is removed, it will no longer receive events pertaining to the lifecycle of this Service.
- Specified by:
removeServiceListenerin interfaceService- Parameters:
listener- the ServiceListener to deregister; if the listener has not previously been registered, this method has no effect
-
configure
public void configure(XmlElement xml)
Configure the controllable service.This method can only be called before the controllable service is started.
- Specified by:
configurein interfaceControllable- Parameters:
xml- an XmlElement carrying configuration information specific to the Controllable object
-
start
public void start()
Start the controllable service.This method should only be called once per the life cycle of the Controllable service. This method has no affect if the service is already running.
- Specified by:
startin interfaceControllable
-
isRunning
public boolean isRunning()
Determine whether or not the controllable service is running. This method returns false before a service is started, while the service is starting, while a service is shutting down and after the service has stopped. It only returns true after completing its start processing and before beginning its shutdown processing.- Specified by:
isRunningin interfaceControllable- Returns:
- true if the service is running; false otherwise
-
shutdown
public void shutdown()
Stop the controllable service. This is a controlled shut-down, and is preferred to theControllable.stop()method.This method should only be called once per the life cycle of the controllable service. Calling this method for a service that has already stopped has no effect.
- Specified by:
shutdownin interfaceControllable
-
stop
public void stop()
Hard-stop the controllable service. UseControllable.shutdown()for normal service termination. Calling this method for a service that has already stopped has no effect.- Specified by:
stopin interfaceControllable
-
getContextClassLoader
public ClassLoader getContextClassLoader()
Retrieve the context ClassLoader for this object. The context ClassLoader is provided by the creator of the object for use by the object when loading classes and resources.- Specified by:
getContextClassLoaderin interfaceClassLoaderAware- Returns:
- the context ClassLoader for this object
- See Also:
Thread.getContextClassLoader()
-
setContextClassLoader
public void setContextClassLoader(ClassLoader loader)
Specify the context ClassLoader for this object. The context ClassLoader can be set when the object is created, and allows the creator to provide the appropriate class loader to be used by the object when when loading classes and resources.- Specified by:
setContextClassLoaderin interfaceClassLoaderAware- Parameters:
loader- the context ClassLoader for this object
-
setDependencies
public void setDependencies(ServiceDependencies deps)
Configure the Service.This method can only be called before the Service is started.
- Specified by:
setDependenciesin interfaceService- Parameters:
deps- the dependencies object carrying configuration information specific to this Service
-
getResourceRegistry
public ResourceRegistry getResourceRegistry()
Retrieves a Service scopedResourceRegistry. The resource registry is used to:- Register resources with the Service and make them accessible to the application code bound to this Service.
- Dispose of resources when the Service is shut down; see
the
ResourceRegistryAPI for details on how to enable cleanup of resources.
- Specified by:
getResourceRegistryin interfaceService- Returns:
- a Service scoped resource registry
-
isSuspended
public boolean isSuspended()
Description copied from interface:ServiceReturnstrueif this service is currently suspended.- Specified by:
isSuspendedin interfaceService- Returns:
trueif this service is currently suspended- See Also:
Cluster.suspendService(String),Cluster.resumeService(String)
-
isVersionCompatible
public boolean isVersionCompatible(int nMajor, int nMinor, int nMicro, int nPatchSet, int nPatch)Description copied from interface:ServiceCheck whether the members of this service run a version that is greater than or equal to the specified version.- Specified by:
isVersionCompatiblein interfaceService- Parameters:
nMajor- the major version numbernMinor- the minor version numbernMicro- the micro version numbernPatchSet- the patch set version numbernPatch- the patch version number- Returns:
trueif the members of the service are all running a version that is greater than or equal to the specified version
-
isVersionCompatible
public boolean isVersionCompatible(int nYear, int nMonth, int nPatch)Description copied from interface:ServiceCheck whether the members of this service run a version that is greater than or equal to the specified version.- Specified by:
isVersionCompatiblein interfaceService- Parameters:
nYear- the year version numbernMonth- the month version numbernPatch- the patch version number- Returns:
trueif the members of the service are all running a version that is greater than or equal to the specified version
-
isVersionCompatible
public boolean isVersionCompatible(int nVersion)
Description copied from interface:ServiceCheck whether the members of this service run a version that is greater than or equal to the specified version.- Specified by:
isVersionCompatiblein interfaceService- Parameters:
nVersion- the encoded version to compare- Returns:
trueif the members of the service are all running a version that is greater than or equal to the specified version
-
isVersionCompatible
public boolean isVersionCompatible(IntPredicate predicate)
Description copied from interface:ServiceCheck whether the members of this service run a minimum service version that matches a specifiedIntPredicate.- Specified by:
isVersionCompatiblein interfaceService- Parameters:
predicate- anIntPredicateto apply to the minimum encoded service version- Returns:
trueif the minimum service version matches the predicate
-
getMinimumServiceVersion
public int getMinimumServiceVersion()
Description copied from interface:ServiceReturn the minimum version for the members in this set.- Specified by:
getMinimumServiceVersionin interfaceService- Returns:
- the minimum version for the members in this set
-
getService
public Service getService()
Return the wrapped Service.- Returns:
- the wrapped Service
-
-