Class ReactiveStateMachineExecutor<S,E>
java.lang.Object
org.springframework.statemachine.support.LifecycleObjectSupport
org.springframework.statemachine.support.ReactiveStateMachineExecutor<S,E>
- Type Parameters:
S
- the type of stateE
- the type of event
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.Lifecycle
,org.springframework.context.Phased
,org.springframework.context.SmartLifecycle
,StateMachineExecutor<S,
,E> StateMachineReactiveLifecycle
public class ReactiveStateMachineExecutor<S,E>
extends LifecycleObjectSupport
implements StateMachineExecutor<S,E>
Default reactive implementation of a
StateMachineExecutor
.- Author:
- Janne Valkealahti
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.statemachine.support.StateMachineExecutor
StateMachineExecutor.ExecutorExceptionHolder, StateMachineExecutor.MonoSinkStateMachineExecutorCallback, StateMachineExecutor.StateMachineExecutorCallback, StateMachineExecutor.StateMachineExecutorTransit<S,
E> -
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionReactiveStateMachineExecutor
(StateMachine<S, E> stateMachine, StateMachine<S, E> relayStateMachine, Collection<Transition<S, E>> transitions, Map<Trigger<S, E>, Transition<S, E>> triggerToTransitionMap, List<Transition<S, E>> triggerlessTransitions, Transition<S, E> initialTransition, org.springframework.messaging.Message<E> initialEvent, TransitionConflictPolicy transitionConflictPolicy) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStateMachineInterceptor
(StateMachineInterceptor<S, E> interceptor) Adds the state machine interceptor.protected reactor.core.publisher.Mono<Void>
Subclasses may implement this for pre start logic.protected reactor.core.publisher.Mono<Void>
Subclasses may implement this for pre stop logic.reactor.core.publisher.Mono<Void>
executeTriggerlessTransitions
(StateContext<S, E> context, State<S, E> state) Execute and check all triggerless transitions.protected void
onInit()
Subclasses may implement this for initialization logic.void
queueDeferredEvent
(org.springframework.messaging.Message<E> message) Queue deferred event.reactor.core.publisher.Mono<Void>
queueEvent
(reactor.core.publisher.Mono<org.springframework.messaging.Message<E>> message, StateMachineExecutor.StateMachineExecutorCallback callback) Queue event.void
setForwardedInitialEvent
(org.springframework.messaging.Message<E> message) Set initial forwarded event.void
setInitialEnabled
(boolean enabled) Sets the if initial stage is enabled.void
setStateMachineExecutorTransit
(StateMachineExecutor.StateMachineExecutorTransit<S, E> stateMachineExecutorTransit) Sets the state machine executor transit.Methods inherited from class org.springframework.statemachine.support.LifecycleObjectSupport
afterPropertiesSet, destroy, doDestroy, doPostStartReactively, doPostStopReactively, getBeanFactory, getPhase, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, start, startReactively, stop, stopReactively
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.SmartLifecycle
stop
Methods inherited from interface org.springframework.statemachine.support.StateMachineReactiveLifecycle
startReactively, stopReactively
-
Constructor Details
-
ReactiveStateMachineExecutor
public ReactiveStateMachineExecutor(StateMachine<S, E> stateMachine, StateMachine<S, E> relayStateMachine, Collection<Transition<S, E>> transitions, Map<Trigger<S, E>, Transition<S, E>> triggerToTransitionMap, List<Transition<S, E>> triggerlessTransitions, Transition<S, E> initialTransition, org.springframework.messaging.Message<E> initialEvent, TransitionConflictPolicy transitionConflictPolicy)
-
-
Method Details
-
onInit
Description copied from class:LifecycleObjectSupport
Subclasses may implement this for initialization logic. Called during theInitializingBean
phase.- Overrides:
onInit
in classLifecycleObjectSupport
- Throws:
Exception
- exception
-
doPreStartReactively
Description copied from class:LifecycleObjectSupport
Subclasses may implement this for pre start logic.- Overrides:
doPreStartReactively
in classLifecycleObjectSupport
- Returns:
- the mono for completion
-
doPreStopReactively
Description copied from class:LifecycleObjectSupport
Subclasses may implement this for pre stop logic.- Overrides:
doPreStopReactively
in classLifecycleObjectSupport
- Returns:
- the mono for completion
-
queueDeferredEvent
Description copied from interface:StateMachineExecutor
Queue deferred event.- Specified by:
queueDeferredEvent
in interfaceStateMachineExecutor<S,
E> - Parameters:
message
- the message
-
executeTriggerlessTransitions
public reactor.core.publisher.Mono<Void> executeTriggerlessTransitions(StateContext<S, E> context, State<S, E> state) Description copied from interface:StateMachineExecutor
Execute and check all triggerless transitions.- Specified by:
executeTriggerlessTransitions
in interfaceStateMachineExecutor<S,
E> - Parameters:
context
- the state contextstate
- the state- Returns:
- completion when handled
-
setInitialEnabled
public void setInitialEnabled(boolean enabled) Description copied from interface:StateMachineExecutor
Sets the if initial stage is enabled.- Specified by:
setInitialEnabled
in interfaceStateMachineExecutor<S,
E> - Parameters:
enabled
- the new flag
-
setForwardedInitialEvent
Description copied from interface:StateMachineExecutor
Set initial forwarded event.- Specified by:
setForwardedInitialEvent
in interfaceStateMachineExecutor<S,
E> - Parameters:
message
- the forwarded message- See Also:
-
setStateMachineExecutorTransit
public void setStateMachineExecutorTransit(StateMachineExecutor.StateMachineExecutorTransit<S, E> stateMachineExecutorTransit) Description copied from interface:StateMachineExecutor
Sets the state machine executor transit.- Specified by:
setStateMachineExecutorTransit
in interfaceStateMachineExecutor<S,
E> - Parameters:
stateMachineExecutorTransit
- the state machine executor transit
-
addStateMachineInterceptor
Description copied from interface:StateMachineExecutor
Adds the state machine interceptor.- Specified by:
addStateMachineInterceptor
in interfaceStateMachineExecutor<S,
E> - Parameters:
interceptor
- the interceptor
-
queueEvent
public reactor.core.publisher.Mono<Void> queueEvent(reactor.core.publisher.Mono<org.springframework.messaging.Message<E>> message, StateMachineExecutor.StateMachineExecutorCallback callback) Description copied from interface:StateMachineExecutor
Queue event.- Specified by:
queueEvent
in interfaceStateMachineExecutor<S,
E> - Parameters:
message
- the messagecallback
- the executor callback- Returns:
- completion when event is queued
-