public class WrapperService extends Object implements Service
Service.MemberJoinAction
Modifier and Type | Field and Description |
---|---|
protected Service |
m_service
The (wrapped) Service.
|
Constructor and Description |
---|
WrapperService(Service service)
Create a new WrapperService that delegates to the given Service
instance.
|
Modifier and Type | Method and 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 scoped
ResourceRegistry . |
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 |
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 specified
IntPredicate . |
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() |
protected Service m_service
public WrapperService(Service service)
service
- the Service to wrappublic ServiceDependencies getDependencies()
public Cluster getCluster()
public ServiceInfo getInfo()
public void addMemberListener(MemberListener listener)
MemberListeners will be invoked in the order in which they are registered.
listener
- the MemberListener
to addpublic void removeMemberListener(MemberListener listener)
listener
- the MemberListener
to removepublic Object getUserContext()
The data type and semantics of this context object are entirely application specific and are opaque to the Service itself.
public void setUserContext(Object oCtx)
oCtx
- a user context objectpublic Serializer getSerializer()
public void addServiceListener(ServiceListener listener)
addServiceListener
in interface Service
listener
- the new ServiceListener to register; if the listener
has already been registered, this method has no effectpublic void removeServiceListener(ServiceListener listener)
After a ServiceListener is removed, it will no longer receive events pertaining to the lifecycle of this Service.
removeServiceListener
in interface Service
listener
- the ServiceListener to deregister; if the listener has
not previously been registered, this method has no
effectpublic void configure(XmlElement xml)
This method can only be called before the controllable service is started.
configure
in interface Controllable
xml
- an XmlElement carrying configuration information
specific to the Controllable objectpublic void start()
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.
start
in interface Controllable
public boolean isRunning()
isRunning
in interface Controllable
public void shutdown()
Controllable.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.
shutdown
in interface Controllable
public void stop()
Controllable.shutdown()
for normal service termination. Calling this method for a service
that has already stopped has no effect.stop
in interface Controllable
public ClassLoader getContextClassLoader()
getContextClassLoader
in interface ClassLoaderAware
Thread.getContextClassLoader()
public void setContextClassLoader(ClassLoader loader)
setContextClassLoader
in interface ClassLoaderAware
loader
- the context ClassLoader for this objectpublic void setDependencies(ServiceDependencies deps)
This method can only be called before the Service is started.
deps
- the dependencies object carrying configuration information
specific to this Servicepublic ResourceRegistry getResourceRegistry()
ResourceRegistry
. The resource
registry is used to:
ResourceRegistry
API for details on how to enable
cleanup of resources.
public boolean isVersionCompatible(int nMajor, int nMinor, int nMicro, int nPatchSet, int nPatch)
Service
nMajor
- the major version numbernMinor
- the minor version numbernMicro
- the micro version numbernPatchSet
- the patch set version numbernPatch
- the patch version numbertrue
if the members of the service are all running a version that
is greater than or equal to the specified versionpublic boolean isVersionCompatible(int nYear, int nMonth, int nPatch)
Service
nYear
- the year version numbernMonth
- the month version numbernPatch
- the patch version numbertrue
if the members of the service are all running a version that
is greater than or equal to the specified versionpublic boolean isVersionCompatible(int nVersion)
Service
nVersion
- the encoded version to comparetrue
if the members of the service are all running a version that
is greater than or equal to the specified versionpublic boolean isVersionCompatible(IntPredicate predicate)
Service
IntPredicate
.predicate
- an IntPredicate
to apply to the minimum encoded service versiontrue
if the minimum service version matches the predicatepublic int getMinimumServiceVersion()
Service
The version is the int
encoded version
(see VersionHelper
).
public Service getService()