Package com.adaptris.core.services
Class WaitService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.WaitService
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,MessageEventGenerator,Service,StateManagedComponent
@ComponentProfile(summary="Delay processing", tag="service") public class WaitService extends ServiceImpImplementation of
Servicefor testing which sleeps for a configurable period.In the adapter configuration file this class is aliased as wait-service 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 WaitService()Creates a new instance.WaitService(TimeInterval wait)WaitService(TimeInterval wait, java.lang.Boolean randomize)WaitService(java.lang.String uniqueId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseService()voiddoService(AdaptrisMessage msg)Waits for the configured number of milliseconds.java.lang.BooleangetExceptionOnInterrupt()java.lang.BooleangetRandomize()TimeIntervalgetWaitInterval()protected voidinitService()voidprepare()Prepare for initialisation.protected booleanrandomizeWait()voidsetExceptionOnInterrupt(java.lang.Boolean b)Whether or not to throw an exception if anInterruptedExceptionhappens.voidsetRandomize(java.lang.Boolean b)Set to true to randomize the wait time between 0 and the value specified bysetWaitInterval(TimeInterval)voidsetWaitInterval(TimeInterval interval)Set how long to wait for.protected longwaitMs()-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
-
-
-
Constructor Detail
-
WaitService
public WaitService()
Creates a new instance.
-
WaitService
public WaitService(TimeInterval wait)
-
WaitService
public WaitService(TimeInterval wait, java.lang.Boolean randomize)
-
WaitService
public WaitService(java.lang.String uniqueId)
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Waits for the configured number of milliseconds.
- Parameters:
msg- the message to apply service to- Throws:
ServiceException- wrapping any underlyingExceptions
-
initService
protected void initService()
- Specified by:
initServicein classServiceImp
-
closeService
protected void closeService()
- Specified by:
closeServicein classServiceImp
-
waitMs
protected long waitMs()
-
getWaitInterval
public TimeInterval getWaitInterval()
-
setWaitInterval
public void setWaitInterval(TimeInterval interval)
Set how long to wait for.- Parameters:
interval- if not specified then the default is 20 seconds.
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Throws:
CoreException
-
getRandomize
public java.lang.Boolean getRandomize()
-
setRandomize
public void setRandomize(java.lang.Boolean b)
Set to true to randomize the wait time between 0 and the value specified bysetWaitInterval(TimeInterval)- Parameters:
b- default null (false)
-
randomizeWait
protected boolean randomizeWait()
-
getExceptionOnInterrupt
public java.lang.Boolean getExceptionOnInterrupt()
- Returns:
- the exceptionOnInterupt
-
setExceptionOnInterrupt
public void setExceptionOnInterrupt(java.lang.Boolean b)
Whether or not to throw an exception if anInterruptedExceptionhappens.- Parameters:
b- the exceptionOnInterupt to set- Since:
- 3.6.6
-
-