S
- the states enumeration.E
- the events enumeration.public interface StateMachineService<S extends java.lang.Enum<S>,E extends java.lang.Enum<E>> extends FSM<S,E>
A FSM-based service implementation.
These services should be built with StateMachineServiceBuilder
.
StateMachineServiceBuilder
Modifier and Type | Method and Description |
---|---|
void |
awaitTermination() |
S |
currentState()
Returns the current state of the machine.
|
void |
failWithError(java.lang.Throwable e) |
void |
fire(E event)
Fires an event.
|
void |
forceShutdown()
Shutdowns and cleans up the service even if it have not terminate yet.
|
boolean |
isFailed()
Tells whether the machine has failed.
|
boolean |
isInState(S state)
Checks atomically whether the service is in the given state.
|
boolean |
isRunning()
Returns whether the service is isRunning.
|
boolean |
isTerminated()
Tells whether the machine is already terminated.
|
void |
shutdown()
Shutdowns and cleans up the service.
|
void fire(E event)
Fires an event.
event
- an event to fire.boolean isRunning()
Returns whether the service is isRunning.
boolean isInState(S state)
Checks atomically whether the service is in the given state.
state
- a state to check.S currentState()
Returns the current state of the machine.
boolean isFailed()
Tells whether the machine has failed.
void failWithError(java.lang.Throwable e)
boolean isTerminated()
Tells whether the machine is already terminated.
void awaitTermination() throws java.lang.InterruptedException
java.lang.InterruptedException
void shutdown()
Shutdowns and cleans up the service.
java.lang.IllegalStateException
- if service has not terminated yet.isTerminated()
void forceShutdown()
Shutdowns and cleans up the service even if it have not terminate yet.
isTerminated()
,
shutdown()