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 ServiceImp
Implementation of
Service
for 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 void
closeService()
void
doService(AdaptrisMessage msg)
Waits for the configured number of milliseconds.java.lang.Boolean
getExceptionOnInterrupt()
java.lang.Boolean
getRandomize()
TimeInterval
getWaitInterval()
protected void
initService()
void
prepare()
Prepare for initialisation.protected boolean
randomizeWait()
void
setExceptionOnInterrupt(java.lang.Boolean b)
Whether or not to throw an exception if anInterruptedException
happens.void
setRandomize(java.lang.Boolean b)
Set to true to randomize the wait time between 0 and the value specified bysetWaitInterval(TimeInterval)
void
setWaitInterval(TimeInterval interval)
Set how long to wait for.protected long
waitMs()
-
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 underlyingException
s
-
initService
protected void initService()
- Specified by:
initService
in classServiceImp
-
closeService
protected void closeService()
- Specified by:
closeService
in 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 CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare 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 anInterruptedException
happens.- Parameters:
b
- the exceptionOnInterupt to set- Since:
- 3.6.6
-
-