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
State s defined in this region. |
java.util.Collection<Transition<S,E>> |
getTransitions()
Gets a
Transition s 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, stop
public DistributedStateMachine(StateMachineEnsemble<S,E> ensemble, StateMachine<S,E> delegate)
ensemble
- the state machine ensembledelegate
- the delegating state machineprotected void onInit() throws java.lang.Exception
LifecycleObjectSupport
InitializingBean
phase. Implementor should
always call super method not to break initialization chain.onInit
in class LifecycleObjectSupport
java.lang.Exception
- exceptionprotected void doStart()
LifecycleObjectSupport
LifecycleObjectSupport.lifecycleLock
.doStart
in class LifecycleObjectSupport
protected void doStop()
LifecycleObjectSupport
LifecycleObjectSupport.lifecycleLock
.doStop
in class LifecycleObjectSupport
public boolean sendEvent(org.springframework.messaging.Message<E> event)
Region
E
wrapped with a Message
to the region.public boolean sendEvent(E event)
Region
E
to the region.public State<S,E> getState()
Region
State
.public java.util.Collection<State<S,E>> getStates()
Region
State
s 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()
Region
Transition
s for this region.getTransitions
in interface Region<S,E>
public boolean isComplete()
Region
isComplete
in interface Region<S,E>
public void setStateMachineError(java.lang.Exception exception)
StateMachine
setStateMachineError
in interface StateMachine<S,E>
exception
- the new state machine errorpublic boolean hasStateMachineError()
StateMachine
hasStateMachineError
in interface StateMachine<S,E>
public void addStateListener(StateMachineListener<S,E> listener)
Region
addStateListener
in interface Region<S,E>
listener
- the listenerpublic void removeStateListener(StateMachineListener<S,E> listener)
Region
removeStateListener
in interface Region<S,E>
listener
- the listenerpublic State<S,E> getInitialState()
StateMachine
S
.getInitialState
in interface StateMachine<S,E>
public ExtendedState getExtendedState()
StateMachine
getExtendedState
in interface StateMachine<S,E>
public StateMachineAccessor<S,E> getStateMachineAccessor()
StateMachine
getStateMachineAccessor
in interface StateMachine<S,E>
public java.util.UUID getUuid()
Region
public java.lang.String getId()
Region
public java.lang.String toString()
toString
in class java.lang.Object