Class StatelessServiceWrapper
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.StatelessServiceWrapper
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,EventHandlerAware,MessageEventGenerator,Service,ServiceWrapper,StateManagedComponent
@ComponentProfile(summary="Wraps another service, with a strategy for restarting the service periodically", tag="service") public class StatelessServiceWrapper extends ServiceImp implements EventHandlerAware, ServiceWrapperStateless 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
RestartStrategyfor the available restarting strategies. Note that some nested configuration will be ignored, particularlyServiceImp.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.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description StatelessServiceWrapper()StatelessServiceWrapper(Service s)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseService()java.lang.StringcreateName()Create a name for anyMleMarkerthat is generated.java.lang.StringcreateQualifier()Create a qualifier for anyMleMarkerthat is generated.voiddoService(AdaptrisMessage msg)Apply the service to the message.java.lang.BooleangetIsTrackingEndpoint()RestartStrategygetRestartStrategy()ServicegetService()protected voidinitService()booleanisBranching()Returns true if the implementation supports branching.booleanisTrackingEndpoint()Returns true if this should be considered an 'end-point' for tracking purposes, otherwise false.voidprepare()Prepare for initialisation.voidregisterEventHandler(EventHandler eh)Register the current event handler against this component.voidsetIsTrackingEndpoint(java.lang.Boolean b)whether or not this service is is a tracking endpoint.voidsetRestartStrategy(RestartStrategy restartStrategy)voidsetService(Service s)voidstart()Starts the component.voidstop()Stop the componentService[]wrappedServices()Return all the services that are wrapped by this service.-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, getContinueOnFail, getUniqueId, init, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setUniqueId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Constructor Detail
-
StatelessServiceWrapper
public StatelessServiceWrapper()
-
StatelessServiceWrapper
public StatelessServiceWrapper(Service s)
-
-
Method Detail
-
stop
public void stop()
Description copied from interface:ComponentLifecycleStop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer, calling stop will pause message delivery. Throwing aRuntimeExceptionmay cause unintended consequences- Specified by:
stopin interfaceComponentLifecycle- Overrides:
stopin classServiceImp
-
start
public void start() throws CoreExceptionDescription copied from interface:ComponentLifecycleStarts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer, calling start will begin message delivery.- Specified by:
startin interfaceComponentLifecycle- Overrides:
startin classServiceImp- Throws:
CoreException- wrapping any underlyingExceptions- See Also:
AdaptrisComponent
-
createName
public java.lang.String createName()
Description copied from interface:MessageEventGeneratorCreate a name for anyMleMarkerthat is generated.The default implementation is to return the classname of the component in question.
* @return the name for anyMleMarkerthat is generated.- Specified by:
createNamein interfaceMessageEventGenerator- Overrides:
createNamein classServiceImp
-
createQualifier
public java.lang.String createQualifier()
Description copied from interface:MessageEventGeneratorCreate a qualifier for anyMleMarkerthat is generated.The default implementation is to return the unique-id of the component in question, or the empty string if not configured
- Specified by:
createQualifierin interfaceMessageEventGenerator- Overrides:
createQualifierin classServiceImp- Returns:
- the qualifier for any
MleMarkerthat is generated.
-
isTrackingEndpoint
public boolean isTrackingEndpoint()
Description copied from interface:MessageEventGeneratorReturns true if this should be considered an 'end-point' for tracking purposes, otherwise false.
- Specified by:
isTrackingEndpointin interfaceMessageEventGenerator- Overrides:
isTrackingEndpointin classServiceImp- Returns:
- true if this should be considered an 'end-point' for tracking purposes, otherwise false
-
isBranching
public boolean isBranching()
Description copied from interface:ServiceReturns true if the implementation supports branching.
- Specified by:
isBranchingin interfaceService- Overrides:
isBranchingin classServiceImp- Returns:
- true if the implementation supports branching
- See Also:
BranchingServiceCollection
-
initService
protected void initService() throws CoreException- Specified by:
initServicein classServiceImp- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeServicein classServiceImp
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Specified by:
preparein interfaceComponentLifecycleExtension- Throws:
CoreException
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:ServiceApply the service to the message.
- Specified by:
doServicein interfaceService- Parameters:
msg- theAdaptrisMessageto process- Throws:
ServiceException- wrapping any underlyingExceptions
-
getService
public Service getService()
- Returns:
- the wrappedService
-
setService
public void setService(Service s)
- Parameters:
s- the wrappedService to set
-
getIsTrackingEndpoint
public java.lang.Boolean getIsTrackingEndpoint()
- Overrides:
getIsTrackingEndpointin classServiceImp
-
setIsTrackingEndpoint
public void setIsTrackingEndpoint(java.lang.Boolean b)
Description copied from class:ServiceImpwhether or not this service is is a tracking endpoint.- Overrides:
setIsTrackingEndpointin classServiceImp- Parameters:
b- true/false, default if not specified is false.
-
getRestartStrategy
public RestartStrategy getRestartStrategy()
-
setRestartStrategy
public void setRestartStrategy(RestartStrategy restartStrategy)
-
registerEventHandler
public void registerEventHandler(EventHandler eh)
Description copied from interface:EventHandlerAwareRegister the current event handler against this component.- Specified by:
registerEventHandlerin interfaceEventHandlerAware- Parameters:
eh- the event handler currently in use.
-
wrappedServices
public Service[] wrappedServices()
Description copied from interface:ServiceWrapperReturn all the services that are wrapped by this service.- Specified by:
wrappedServicesin interfaceServiceWrapper- Returns:
- an array of wrapped services.
-
-