@ComponentProfile(summary="Wraps another service, with a strategy for restarting the service periodically", tag="service") public class StatelessServiceWrapper extends ServiceImp implements EventHandlerAware, ServiceWrapper
Stateless service wrapper, wraps any configured service and allows you to set a strategy on when to restart the service before allowing it to execute.
Consider using this wrapper on a service where you will periodically want to stop and re-start a service. Check
RestartStrategy
for the available restarting strategies. Note that some nested configuration will be ignored,
particularly ServiceImp.setContinueOnFail(Boolean)
in the nested service. If you want that behaviour, then you should explicitly
configure it in this service.
In the adapter configuration file this class is aliased as stateless-service-wrapper which is the preferred alternative to the fully qualified classname when building your configuration.
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
StatelessServiceWrapper() |
StatelessServiceWrapper(Service s) |
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
java.lang.String |
createName()
Create a name for any
MleMarker that is generated. |
java.lang.String |
createQualifier()
Create a qualifier for any
MleMarker that is generated. |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
java.lang.Boolean |
getIsTrackingEndpoint() |
RestartStrategy |
getRestartStrategy() |
Service |
getService() |
protected void |
initService() |
boolean |
isBranching()
Returns true if the implementation supports branching.
|
boolean |
isTrackingEndpoint()
Returns true if this should be considered an 'end-point' for tracking
purposes, otherwise false.
|
void |
prepare()
Prepare for initialisation.
|
void |
registerEventHandler(EventHandler eh)
Register the current event handler against this component.
|
void |
setIsTrackingEndpoint(java.lang.Boolean b)
whether or not this service is is a tracking endpoint.
|
void |
setRestartStrategy(RestartStrategy restartStrategy) |
void |
setService(Service s) |
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
Service[] |
wrappedServices()
Return all the services that are wrapped by this service.
|
changeState, close, continueOnFailure, getContinueOnFail, getLookupName, getUniqueId, init, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setLookupName, setUniqueId
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
continueOnFailure, setUniqueId
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
getUniqueId
close, init
getLookupName
public StatelessServiceWrapper()
public StatelessServiceWrapper(Service s)
public void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
stop
in interface ComponentLifecycle
stop
in class ServiceImp
public void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
start
in interface ComponentLifecycle
start
in class ServiceImp
CoreException
- wrapping any underlying Exception
sAdaptrisComponent
public java.lang.String createName()
MessageEventGenerator
MleMarker
that is generated.
The default implementation is to return the classname of the component in question.
* @return the name for anyMleMarker
that is generated.createName
in interface MessageEventGenerator
createName
in class ServiceImp
public java.lang.String createQualifier()
MessageEventGenerator
MleMarker
that is generated.
The default implementation is to return the unique-id of the component in question, or the empty string if not configured
createQualifier
in interface MessageEventGenerator
createQualifier
in class ServiceImp
MleMarker
that is generated.public boolean isTrackingEndpoint()
MessageEventGenerator
Returns true if this should be considered an 'end-point' for tracking purposes, otherwise false.
isTrackingEndpoint
in interface MessageEventGenerator
isTrackingEndpoint
in class ServiceImp
public boolean isBranching()
Service
Returns true if the implementation supports branching.
isBranching
in interface Service
isBranching
in class ServiceImp
BranchingServiceCollection
protected void initService() throws CoreException
initService
in class ServiceImp
CoreException
protected void closeService()
closeService
in class ServiceImp
public void prepare() throws CoreException
ComponentLifecycleExtension
prepare
in interface ComponentLifecycleExtension
CoreException
public void doService(AdaptrisMessage msg) throws ServiceException
Service
Apply the service to the message.
doService
in interface Service
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
spublic Service getService()
public void setService(Service s)
s
- the wrappedService to setpublic java.lang.Boolean getIsTrackingEndpoint()
getIsTrackingEndpoint
in class ServiceImp
public void setIsTrackingEndpoint(java.lang.Boolean b)
ServiceImp
setIsTrackingEndpoint
in class ServiceImp
b
- true/false, default if not specified is false.public RestartStrategy getRestartStrategy()
public void setRestartStrategy(RestartStrategy restartStrategy)
public void registerEventHandler(EventHandler eh)
EventHandlerAware
registerEventHandler
in interface EventHandlerAware
eh
- the event handler currently in use.public Service[] wrappedServices()
ServiceWrapper
wrappedServices
in interface ServiceWrapper