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 void
addMemberListener(MemberListener listener)
Add a Member listener.void
addServiceListener(ServiceListener listener)
Register a ServiceListener that will receive events pertaining to the lifecycle of this Service.void
configure(XmlElement xml)
Configure the controllable service.Cluster
getCluster()
Return the Cluster object that this Service is a part of.ClassLoader
getContextClassLoader()
Retrieve the context ClassLoader for this object.ServiceDependencies
getDependencies()
Return the service's dependencies.ServiceInfo
getInfo()
Return the ServiceInfo object for this Service.int
getMinimumServiceVersion()
Return the minimum version for the members in this set.ResourceRegistry
getResourceRegistry()
Retrieves a Service scopedResourceRegistry
.Serializer
getSerializer()
Return a Serializer used by this Service.Service
getService()
Return the wrapped Service.Object
getUserContext()
Return the user context object associated with this Service.boolean
isRunning()
Determine whether or not the controllable service is running.boolean
isSuspended()
Returnstrue
if this service is currently suspended.boolean
isVersionCompatible(int nVersion)
Check whether the members of this service run a version that is greater than or equal to the specified version.boolean
isVersionCompatible(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.boolean
isVersionCompatible(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.boolean
isVersionCompatible(IntPredicate predicate)
Check whether the members of this service run a minimum service version that matches a specifiedIntPredicate
.void
removeMemberListener(MemberListener listener)
Remove a Member listener.void
removeServiceListener(ServiceListener listener)
Unregister a ServiceListener from this ConnectionManager.void
setContextClassLoader(ClassLoader loader)
Specify the context ClassLoader for this object.void
setDependencies(ServiceDependencies deps)
Configure the Service.void
setUserContext(Object oCtx)
Associate a user context object with this Service.void
shutdown()
Stop the controllable service.void
start()
Start the controllable service.void
stop()
Hard-stop the controllable service.String
toString()
-
-
-
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:
getDependencies
in interfaceService
- Returns:
- the service's dependencies
-
getCluster
public Cluster getCluster()
Return the Cluster object that this Service is a part of.- Specified by:
getCluster
in 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:
addMemberListener
in interfaceService
- Parameters:
listener
- theMemberListener
to add
-
removeMemberListener
public void removeMemberListener(MemberListener listener)
Remove a Member listener.- Specified by:
removeMemberListener
in interfaceService
- Parameters:
listener
- theMemberListener
to 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:
getUserContext
in 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:
setUserContext
in interfaceService
- Parameters:
oCtx
- a user context object
-
getSerializer
public Serializer getSerializer()
Return a Serializer used by this Service.- Specified by:
getSerializer
in 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:
addServiceListener
in 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:
removeServiceListener
in 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:
configure
in 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:
start
in 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:
isRunning
in 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:
shutdown
in 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:
stop
in 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:
getContextClassLoader
in 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:
setContextClassLoader
in 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:
setDependencies
in 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
ResourceRegistry
API for details on how to enable cleanup of resources.
- Specified by:
getResourceRegistry
in interfaceService
- Returns:
- a Service scoped resource registry
-
isSuspended
public boolean isSuspended()
Description copied from interface:Service
Returnstrue
if this service is currently suspended.- Specified by:
isSuspended
in interfaceService
- Returns:
true
if 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:Service
Check whether the members of this service run a version that is greater than or equal to the specified version.- Specified by:
isVersionCompatible
in 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:
true
if 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:Service
Check whether the members of this service run a version that is greater than or equal to the specified version.- Specified by:
isVersionCompatible
in interfaceService
- Parameters:
nYear
- the year version numbernMonth
- the month version numbernPatch
- the patch version number- Returns:
true
if 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:Service
Check whether the members of this service run a version that is greater than or equal to the specified version.- Specified by:
isVersionCompatible
in interfaceService
- Parameters:
nVersion
- the encoded version to compare- Returns:
true
if 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:Service
Check whether the members of this service run a minimum service version that matches a specifiedIntPredicate
.- Specified by:
isVersionCompatible
in interfaceService
- Parameters:
predicate
- anIntPredicate
to apply to the minimum encoded service version- Returns:
true
if the minimum service version matches the predicate
-
getMinimumServiceVersion
public int getMinimumServiceVersion()
Description copied from interface:Service
Return the minimum version for the members in this set.- Specified by:
getMinimumServiceVersion
in interfaceService
- Returns:
- the minimum version for the members in this set
-
getService
public Service getService()
Return the wrapped Service.- Returns:
- the wrapped Service
-
-