S - the type of stateE - the type of eventpublic abstract class AbstractStateMachine<S,E> extends StateMachineObjectSupport<S,E> implements StateMachine<S,E>, StateMachineAccess<S,E>
StateMachine loosely modelled from UML state
machine.StateMachineObjectSupport.StateMachineListenerRelay| Constructor and Description |
|---|
AbstractStateMachine(java.util.Collection<State<S,E>> states,
java.util.Collection<Transition<S,E>> transitions,
State<S,E> initialState)
Instantiates a new abstract state machine.
|
AbstractStateMachine(java.util.Collection<State<S,E>> states,
java.util.Collection<Transition<S,E>> transitions,
State<S,E> initialState,
ExtendedState extendedState)
Instantiates a new abstract state machine.
|
AbstractStateMachine(java.util.Collection<State<S,E>> states,
java.util.Collection<Transition<S,E>> transitions,
State<S,E> initialState,
Transition<S,E> initialTransition,
org.springframework.messaging.Message<E> initialEvent,
ExtendedState extendedState)
Instantiates a new abstract state machine.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
acceptEvent(org.springframework.messaging.Message<E> message) |
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.
|
void |
doWithAllRegions(StateMachineFunction<StateMachineAccess<S,E>> stateMachineAccess)
Execute given
StateMachineFunction with all recursive regions. |
ExtendedState |
getExtendedState()
Gets the state machine extended state.
|
State<S,E> |
getInitialState()
Gets the initial state
S. |
State<S,E> |
getState()
Gets the current
State. |
java.util.Collection<State<S,E>> |
getStates()
Gets the
States defined in this machine. |
java.util.Collection<Transition<S,E>> |
getTransitions()
Gets a
Transitions for this region. |
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 |
setHistoryState(PseudoState<S,E> history) |
void |
setRelay(StateMachine<S,E> stateMachine)
Sets the relay state machine.
|
protected void |
stateChangedInRelay() |
java.lang.String |
toString() |
getStateListener, getStateMachineEventPublisher, notifyStateChanged, notifyStateEntered, notifyStateExited, notifyStateMachineStarted, notifyStateMachineStopped, notifyTransition, notifyTransitionEnd, notifyTransitionStart, setContextEventsEnabled, setStateMachineEventPublisherafterPropertiesSet, getBeanFactory, getPhase, getTaskExecutor, getTaskScheduler, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, setTaskExecutor, setTaskScheduler, start, stop, stoppublic AbstractStateMachine(java.util.Collection<State<S,E>> states, java.util.Collection<Transition<S,E>> transitions, State<S,E> initialState)
states - the states of this machinetransitions - the transitions of this machineinitialState - the initial state of this machinepublic AbstractStateMachine(java.util.Collection<State<S,E>> states, java.util.Collection<Transition<S,E>> transitions, State<S,E> initialState, ExtendedState extendedState)
states - the states of this machinetransitions - the transitions of this machineinitialState - the initial state of this machineextendedState - the extended state of this machinepublic AbstractStateMachine(java.util.Collection<State<S,E>> states, java.util.Collection<Transition<S,E>> transitions, State<S,E> initialState, Transition<S,E> initialTransition, org.springframework.messaging.Message<E> initialEvent, ExtendedState extendedState)
states - the states of this machinetransitions - the transitions of this machineinitialState - the initial state of this machineinitialEvent - the initial event of this machineextendedState - the extended state of this machinepublic State<S,E> getState()
RegionState.public State<S,E> getInitialState()
StateMachineS.getInitialState in interface StateMachine<S,E>public ExtendedState getExtendedState()
StateMachinegetExtendedState in interface StateMachine<S,E>public void setHistoryState(PseudoState<S,E> history)
public 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.protected 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 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 boolean isComplete()
RegionisComplete in interface Region<S,E>public java.util.Collection<State<S,E>> getStates()
States defined in this machine. 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 void doWithAllRegions(StateMachineFunction<StateMachineAccess<S,E>> stateMachineAccess)
StateMachineAccessStateMachineFunction with all recursive regions.doWithAllRegions in interface StateMachineAccess<S,E>stateMachineAccess - the state machine accesspublic void setRelay(StateMachine<S,E> stateMachine)
StateMachineAccesssetRelay in interface StateMachineAccess<S,E>stateMachine - the state machineprotected void stateChangedInRelay()
stateChangedInRelay in class StateMachineObjectSupport<S,E>public java.lang.String toString()
toString in class java.lang.Objectprotected boolean acceptEvent(org.springframework.messaging.Message<E> message)