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 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.
|
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. |
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 |
setStateMachineError(java.lang.Exception exception)
Sets the state machine error.
|
java.lang.String |
toString() |
afterPropertiesSet, destroy, doDestroy, doPostStartReactively, doPostStopReactively, getBeanFactory, getPhase, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, start, startReactively, stop, stopReactivelyclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitstartReactively, stopReactivelypublic 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.onInit in class LifecycleObjectSupportjava.lang.Exception - exceptionprotected reactor.core.publisher.Mono<java.lang.Void> doPreStartReactively()
LifecycleObjectSupportdoPreStartReactively in class LifecycleObjectSupportprotected reactor.core.publisher.Mono<java.lang.Void> doPreStopReactively()
LifecycleObjectSupportdoPreStopReactively in class LifecycleObjectSupportpublic 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.
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>> 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 eventpublic 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 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