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,
java.util.UUID uuid)
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.
|
void |
addStateMachineInterceptor(StateMachineInterceptor<S,E> interceptor)
Adds the state machine interceptor.
|
void |
addStateMachineMonitor(StateMachineMonitor<S,E> monitor)
Adds the state machine monitor.
|
protected void |
doDestroy() |
protected void |
doStart()
Subclasses may implement this method with the start behavior.
|
protected void |
doStop()
Subclasses may implement this method with the stop behavior.
|
protected void |
executeTriggerlessTransitions(StateMachine<S,E> stateMachine,
StateContext<S,E> stateContext,
State<S,E> state) |
ExtendedState |
getExtendedState()
Gets the state machine extended state.
|
PseudoState<S,E> |
getHistoryState() |
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.
|
protected StateMachineExecutor<S,E> |
getStateMachineExecutor() |
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. |
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 |
notifyEventNotAccepted(StateContext<S,E> stateContext) |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
void |
removeStateListener(StateMachineListener<S,E> listener)
Removes the state listener.
|
void |
resetStateMachine(StateMachineContext<S,E> stateMachineContext)
Reset state machine.
|
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 |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
void |
setForwardedInitialEvent(org.springframework.messaging.Message<E> message)
Set initial forwarded event which is used for passing in
event and its headers for actions executed when sub state
is entered via initial transition.
|
void |
setHistoryState(PseudoState<S,E> history) |
void |
setId(java.lang.String id)
Sets the machine id.
|
void |
setInitialEnabled(boolean enabled)
Sets if initial state is enabled when a state machine is
using sub states.
|
void |
setParentMachine(StateMachine<S,E> parentMachine)
Sets the parent machine.
|
void |
setRelay(StateMachine<S,E> stateMachine)
Sets the relay state machine.
|
void |
setStateMachineError(java.lang.Exception exception)
Sets the state machine error.
|
void |
setTransitionConflightPolicy(TransitionConflictPolicy transitionConflictPolicy)
Sets the transition conflict policy.
|
protected void |
stateChangedInRelay() |
java.lang.String |
toString() |
getBeanName, getStateListener, getStateMachineEventPublisher, getStateMachineInterceptors, getStateMachineMonitor, notifyActionMonitor, notifyExtendedStateChanged, notifyStateChanged, notifyStateEntered, notifyStateExited, notifyStateMachineError, notifyStateMachineStarted, notifyStateMachineStopped, notifyTransition, notifyTransitionEnd, notifyTransitionMonitor, notifyTransitionStart, setBeanName, setContextEventsEnabled, setStateMachineEventPublisher, setStateMachineInterceptorsafterPropertiesSet, destroy, getBeanFactory, getPhase, getTaskExecutor, getTaskScheduler, isAutoStartup, isRunning, setAutoStartup, 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, java.util.UUID uuid)
states - the states of this machinetransitions - the transitions of this machineinitialState - the initial state of this machineinitialTransition - the initial transitioninitialEvent - the initial event of this machineextendedState - the extended state of this machineuuid - the given uuid for 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)
history - to set internal history state.public PseudoState<S,E> getHistoryState()
public boolean sendEvent(org.springframework.messaging.Message<E> event)
RegionE wrapped with a Message to the region.protected void notifyEventNotAccepted(StateContext<S,E> stateContext)
notifyEventNotAccepted in class StateMachineObjectSupport<S,E>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 - exceptionpublic void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
throws org.springframework.beans.BeansException
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAwaresetBeanFactory in class LifecycleObjectSupportorg.springframework.beans.BeansExceptionprotected void doStart()
LifecycleObjectSupportLifecycleObjectSupport.lifecycleLock.doStart in class StateMachineObjectSupport<S,E>protected void doStop()
LifecycleObjectSupportLifecycleObjectSupport.lifecycleLock.doStop in class LifecycleObjectSupportprotected void doDestroy()
doDestroy in class LifecycleObjectSupportpublic 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 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 setInitialEnabled(boolean enabled)
StateMachineAccesssetInitialEnabled in interface StateMachineAccess<S,E>enabled - the new initial enabledpublic StateMachineAccessor<S,E> getStateMachineAccessor()
StateMachinegetStateMachineAccessor in interface StateMachine<S,E>public void setRelay(StateMachine<S,E> stateMachine)
StateMachineAccesssetRelay in interface StateMachineAccess<S,E>stateMachine - the state machinepublic void setParentMachine(StateMachine<S,E> parentMachine)
StateMachineAccesssetParentMachine in interface StateMachineAccess<S,E>parentMachine - the state machineprotected void stateChangedInRelay()
stateChangedInRelay in class StateMachineObjectSupport<S,E>public void setForwardedInitialEvent(org.springframework.messaging.Message<E> message)
StateMachineAccesssetForwardedInitialEvent in interface StateMachineAccess<S,E>message - the forwarded messagepublic void setTransitionConflightPolicy(TransitionConflictPolicy transitionConflictPolicy)
transitionConflictPolicy - the new transition conflict policypublic java.lang.String toString()
toString in class java.lang.Objectpublic void resetStateMachine(StateMachineContext<S,E> stateMachineContext)
StateMachineAccessresetStateMachine in interface StateMachineAccess<S,E>stateMachineContext - the state machine contextpublic void addStateMachineInterceptor(StateMachineInterceptor<S,E> interceptor)
StateMachineAccessaddStateMachineInterceptor in interface StateMachineAccess<S,E>interceptor - the interceptorpublic void addStateMachineMonitor(StateMachineMonitor<S,E> monitor)
StateMachineAccessaddStateMachineMonitor in interface StateMachineAccess<S,E>monitor - the monitorpublic java.util.UUID getUuid()
Regionpublic java.lang.String getId()
Regionpublic void setId(java.lang.String id)
id - the new machine idprotected void executeTriggerlessTransitions(StateMachine<S,E> stateMachine, StateContext<S,E> stateContext, State<S,E> state)
protected StateMachineExecutor<S,E> getStateMachineExecutor()
protected boolean acceptEvent(org.springframework.messaging.Message<E> message)