S - the type of stateE - the type of eventpublic class DistributedStateMachine<S,E> extends LifecycleObjectSupport implements StateMachine<S,E>
DistributedStateMachine is wrapping a real StateMachine and works
together with a StateMachineEnsemble order to provide a distributed state
machine.
Every distributed state machine will enter its initial state regardless of
a distributed state status.| Constructor and Description |
|---|
DistributedStateMachine(StateMachineEnsemble<S,E> ensemble,
StateMachine<S,E> delegate)
Instantiates a new distributed state machine.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addStateListener(StateMachineListener<S,E> listener)
Adds the state listener.
|
protected void |
doStart()
Subclasses may implement this method with the start behavior.
|
protected void |
doStop()
Subclasses may implement this method with the stop behavior.
|
ExtendedState |
getExtendedState()
Gets the state machine extended state.
|
java.lang.String |
getId()
Gets the region and state machine id.
|
State<S,E> |
getInitialState()
Gets the initial state
S. |
State<S,E> |
getState()
Gets the current
State. |
StateMachineAccessor<S,E> |
getStateMachineAccessor()
Gets the state machine accessor.
|
java.util.Collection<State<S,E>> |
getStates()
Gets the
States defined in this region. |
java.util.Collection<Transition<S,E>> |
getTransitions()
Gets a
Transitions for this region. |
java.util.UUID |
getUuid()
Gets the region and state machine unique id.
|
boolean |
hasStateMachineError()
Checks for state machine error.
|
boolean |
isComplete()
Checks if region complete.
|
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
void |
removeStateListener(StateMachineListener<S,E> listener)
Removes the state listener.
|
boolean |
sendEvent(E event)
Send an event
E to the region. |
boolean |
sendEvent(org.springframework.messaging.Message<E> event)
Send an event
E wrapped with a Message to the region. |
void |
setStateMachineError(java.lang.Exception exception)
Sets the state machine error.
|
java.lang.String |
toString() |
afterPropertiesSet, destroy, doDestroy, getBeanFactory, getPhase, getTaskExecutor, getTaskScheduler, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, setTaskExecutor, setTaskScheduler, start, stop, stoppublic DistributedStateMachine(StateMachineEnsemble<S,E> ensemble, StateMachine<S,E> delegate)
ensemble - the state machine ensembledelegate - the delegating state machineprotected void onInit()
throws java.lang.Exception
LifecycleObjectSupportInitializingBean phase. Implementor should
always call super method not to break initialization chain.onInit in class LifecycleObjectSupportjava.lang.Exception - exceptionprotected void doStart()
LifecycleObjectSupportLifecycleObjectSupport.lifecycleLock.doStart in class LifecycleObjectSupportprotected void doStop()
LifecycleObjectSupportLifecycleObjectSupport.lifecycleLock.doStop in class LifecycleObjectSupportpublic boolean sendEvent(org.springframework.messaging.Message<E> event)
RegionE wrapped with a Message to the region.public boolean sendEvent(E event)
RegionE to the region.public State<S,E> getState()
RegionState.public java.util.Collection<State<S,E>> getStates()
RegionStates defined in this region. Returned collection is
an unmodifiable copy because states in a state machine are immutable.public java.util.Collection<Transition<S,E>> getTransitions()
RegionTransitions for this region.getTransitions in interface Region<S,E>public boolean isComplete()
RegionisComplete in interface Region<S,E>public void setStateMachineError(java.lang.Exception exception)
StateMachinesetStateMachineError in interface StateMachine<S,E>exception - the new state machine errorpublic boolean hasStateMachineError()
StateMachinehasStateMachineError in interface StateMachine<S,E>public void addStateListener(StateMachineListener<S,E> listener)
RegionaddStateListener in interface Region<S,E>listener - the listenerpublic void removeStateListener(StateMachineListener<S,E> listener)
RegionremoveStateListener in interface Region<S,E>listener - the listenerpublic State<S,E> getInitialState()
StateMachineS.getInitialState in interface StateMachine<S,E>public ExtendedState getExtendedState()
StateMachinegetExtendedState in interface StateMachine<S,E>public StateMachineAccessor<S,E> getStateMachineAccessor()
StateMachinegetStateMachineAccessor in interface StateMachine<S,E>public java.util.UUID getUuid()
Regionpublic java.lang.String getId()
Regionpublic java.lang.String toString()
toString in class java.lang.Object