public class WaitingOutOfStateHandler extends OutOfStateHandlerImp
This implementation of the OutOfStateHandler
will simply wait on the current Thread for the StateManagedComponent
to be in the correct/expected state.
While waiting, we will periodically check the StateManagedComponent
s state. This periodic check can be configured by
setting the interval-to-check which is a TimeInterval
.
We will also only wait for the StateManagedComponent
to be in the right state for a maximum time, configured by setting
the maximum-wait-time, which is also a TimeInterval
. If the maximum time should pass while waiting, we will stop waiting
and throw an OutOfStateException
.
If you do not configure interval-to-check and/or maximum-wait-time, the following defaults will be applied;
Example configuration;
<waiting-out-of-state-handler>
<correct-state>STARTED</correct-state>
<maximum-wait-time>
<unit>MINUTES</UNIT>
<interval>2</interval>
</maximum-wait-time>
<interval-to-check>
<unit>SECONDS<<unit>
<interval>5</interval>
</interval-to-check>
</waiting-out-of-state-handler>
In the adapter configuration file this class is aliased as waiting-out-of-state-handler which is the preferred alternative to the fully qualified classname when building your configuration.
Constructor and Description |
---|
WaitingOutOfStateHandler() |
Modifier and Type | Method and Description |
---|---|
TimeInterval |
getIntervalToCheck() |
TimeInterval |
getMaximumWaitTime() |
void |
handleOutOfState(StateManagedComponent component) |
protected long |
intervalToCheckMs() |
protected long |
maxWaitTimeMs() |
void |
setIntervalToCheck(TimeInterval interval) |
void |
setMaximumWaitTime(TimeInterval max) |
getCorrectState, isInCorrectState, setCorrectState
public void handleOutOfState(StateManagedComponent component) throws OutOfStateException
OutOfStateException
public TimeInterval getMaximumWaitTime()
public void setMaximumWaitTime(TimeInterval max)
public TimeInterval getIntervalToCheck()
public void setIntervalToCheck(TimeInterval interval)
protected long intervalToCheckMs()
protected long maxWaitTimeMs()