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 |
|---|---|
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()
Subclasses may implement this for destroy logic.
|
protected reactor.core.publisher.Mono<java.lang.Void> |
doPostStartReactively()
Subclasses may implement this for post start logic.
|
protected reactor.core.publisher.Mono<java.lang.Void> |
doPreStartReactively()
Subclasses may implement this for pre start logic.
|
protected reactor.core.publisher.Mono<java.lang.Void> |
doPreStopReactively()
Subclasses may implement this for pre stop logic.
|
protected reactor.core.publisher.Mono<java.lang.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.
|
reactor.core.publisher.Mono<java.lang.Void> |
resetStateMachineReactively(StateMachineContext<S,E> stateMachineContext)
Reset state machine reactively.
|
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. |
reactor.core.publisher.Flux<StateMachineEventResult<S,E>> |
sendEvent(reactor.core.publisher.Mono<org.springframework.messaging.Message<E>> event)
|
reactor.core.publisher.Mono<java.util.List<StateMachineEventResult<S,E>>> |
sendEventCollect(reactor.core.publisher.Mono<org.springframework.messaging.Message<E>> event)
|
reactor.core.publisher.Flux<StateMachineEventResult<S,E>> |
sendEvents(reactor.core.publisher.Flux<org.springframework.messaging.Message<E>> events)
|
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.
|
java.lang.String |
toString() |
doStart, getBeanName, getStateListener, getStateMachineEventPublisher, getStateMachineInterceptors, getStateMachineMonitor, notifyActionMonitor, notifyExtendedStateChanged, notifyStateChanged, notifyStateEntered, notifyStateExited, notifyStateMachineError, notifyStateMachineStarted, notifyStateMachineStopped, notifyTransition, notifyTransitionEnd, notifyTransitionMonitor, notifyTransitionStart, setBeanName, setContextEventsEnabled, setStateMachineEventPublisher, setStateMachineInterceptorsafterPropertiesSet, destroy, doPostStopReactively, getBeanFactory, getPhase, isAutoStartup, isRunning, setAutoStartup, setPhase, start, startReactively, stop, stopReactivelyclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitstartReactively, stopReactivelypublic 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.
NOTE: this method is now deprecated in favour of a reactive methods.
protected void notifyEventNotAccepted(StateContext<S,E> stateContext)
notifyEventNotAccepted in class StateMachineObjectSupport<S,E>public boolean sendEvent(E event)
RegionE to the region.
NOTE: this method is now deprecated in favour of a reactive methods.
public reactor.core.publisher.Flux<StateMachineEventResult<S,E>> sendEvents(reactor.core.publisher.Flux<org.springframework.messaging.Message<E>> events)
RegionFlux of events and return a Flux of
StateMachineEventResults. Events are consumed after returned results
are consumed.sendEvents in interface Region<S,E>events - the eventspublic reactor.core.publisher.Flux<StateMachineEventResult<S,E>> sendEvent(reactor.core.publisher.Mono<org.springframework.messaging.Message<E>> event)
RegionMono of event and return a Flux of
StateMachineEventResults. Events are consumed after returned results
are consumed.public reactor.core.publisher.Mono<java.util.List<StateMachineEventResult<S,E>>> sendEventCollect(reactor.core.publisher.Mono<org.springframework.messaging.Message<E>> event)
RegionMono of event and return a Mono of collected
StateMachineEventResults as a list. Events are consumed after
returned results are consumed.sendEventCollect in interface Region<S,E>event - the eventprotected void onInit()
throws java.lang.Exception
LifecycleObjectSupportInitializingBean phase.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 reactor.core.publisher.Mono<java.lang.Void> doPreStartReactively()
LifecycleObjectSupportdoPreStartReactively in class LifecycleObjectSupportprotected reactor.core.publisher.Mono<java.lang.Void> doPostStartReactively()
LifecycleObjectSupportdoPostStartReactively in class LifecycleObjectSupportprotected reactor.core.publisher.Mono<java.lang.Void> doPreStopReactively()
LifecycleObjectSupportdoPreStopReactively in class LifecycleObjectSupportprotected void doDestroy()
LifecycleObjectSupportdoDestroy 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 machinepublic 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 contextReactiveStateMachineAccess.resetStateMachineReactively(StateMachineContext)public reactor.core.publisher.Mono<java.lang.Void> resetStateMachineReactively(StateMachineContext<S,E> stateMachineContext)
ReactiveStateMachineAccessresetStateMachineReactively in interface ReactiveStateMachineAccess<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 reactor.core.publisher.Mono<java.lang.Void> executeTriggerlessTransitions(StateMachine<S,E> stateMachine, StateContext<S,E> stateContext, State<S,E> state)
protected StateMachineExecutor<S,E> getStateMachineExecutor()