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
ConstructorDescriptionCreates a new instance.WaitService
(TimeInterval wait) WaitService
(TimeInterval wait, Boolean randomize) WaitService
(String uniqueId) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
doService
(AdaptrisMessage msg) Waits for the configured number of milliseconds.protected void
void
prepare()
Prepare for initialisation.protected boolean
void
Whether or not to throw an exception if anInterruptedException
happens.void
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 Details
-
WaitService
public WaitService()Creates a new instance.
-
WaitService
-
WaitService
-
WaitService
-
-
Method Details
-
doService
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
-
setWaitInterval
Set how long to wait for.- Parameters:
interval
- if not specified then the default is 20 seconds.
-
prepare
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
getRandomize
-
setRandomize
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
- Returns:
- the exceptionOnInterupt
-
setExceptionOnInterrupt
Whether or not to throw an exception if anInterruptedException
happens.- Parameters:
b
- the exceptionOnInterupt to set- Since:
- 3.6.6
-