Class AbstractPersistingStateMachineInterceptor<S,E,T>
java.lang.Object
org.springframework.statemachine.support.StateMachineInterceptorAdapter<S,E>
org.springframework.statemachine.persist.AbstractPersistingStateMachineInterceptor<S,E,T>
- Type Parameters:
S
- the type of stateE
- the type of eventT
- the type of persister context object
- All Implemented Interfaces:
StateMachinePersist<S,
,E, T> StateMachineInterceptor<S,
E>
- Direct Known Subclasses:
JpaPersistingStateMachineInterceptor
,MongoDbPersistingStateMachineInterceptor
,RedisPersistingStateMachineInterceptor
public abstract class AbstractPersistingStateMachineInterceptor<S,E,T>
extends StateMachineInterceptorAdapter<S,E>
implements StateMachinePersist<S,E,T>
Base class for
StateMachineInterceptor
persisting StateMachineContext
s.
This class is to be used as a base implementation which wants to persist a machine which
is about to kept running as normal use case for persistence is to stop machine, persist and
then start it again.- Author:
- Janne Valkealahti
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected StateMachineContext<S,
E> buildStateMachineContext
(StateMachine<S, E> stateMachine, StateMachine<S, E> rootStateMachine, State<S, E> state) Deprecated.protected StateMachineContext<S,
E> buildStateMachineContext
(StateMachine<S, E> stateMachine, StateMachine<S, E> rootStateMachine, State<S, E> state, org.springframework.messaging.Message<E> message) Builds the state machine context.void
postStateChange
(State<S, E> state, org.springframework.messaging.Message<E> message, Transition<S, E> transition, StateMachine<S, E> stateMachine, StateMachine<S, E> rootStateMachine) Called after a state change.void
preStateChange
(State<S, E> state, org.springframework.messaging.Message<E> message, Transition<S, E> transition, StateMachine<S, E> stateMachine, StateMachine<S, E> rootStateMachine) Called prior of a state change.abstract StateMachineContext<S,
E> ReadStateMachineContext
from persistent store.void
setExtendedStateVariablesFunction
(Function<StateMachine<S, E>, Map<Object, Object>> extendedStateVariablesFunction) Sets the function creating extended state variables.abstract void
write
(StateMachineContext<S, E> context, T contextObj) WriteStateMachineContext
into persistent store.Methods inherited from class org.springframework.statemachine.support.StateMachineInterceptorAdapter
postTransition, preEvent, preTransition, stateMachineError
-
Constructor Details
-
AbstractPersistingStateMachineInterceptor
public AbstractPersistingStateMachineInterceptor()
-
-
Method Details
-
preStateChange
public void preStateChange(State<S, E> state, org.springframework.messaging.Message<E> message, Transition<S, E> transition, StateMachine<S, E> stateMachine, StateMachine<S, E> rootStateMachine) Description copied from interface:StateMachineInterceptor
Called prior of a state change. Throwing an exception from this method will stop a state change logic.- Specified by:
preStateChange
in interfaceStateMachineInterceptor<S,
E> - Overrides:
preStateChange
in classStateMachineInterceptorAdapter<S,
E> - Parameters:
state
- the statemessage
- the messagetransition
- the transitionstateMachine
- the state machinerootStateMachine
- the root state machine
-
postStateChange
public void postStateChange(State<S, E> state, org.springframework.messaging.Message<E> message, Transition<S, E> transition, StateMachine<S, E> stateMachine, StateMachine<S, E> rootStateMachine) Description copied from interface:StateMachineInterceptor
Called after a state change.- Specified by:
postStateChange
in interfaceStateMachineInterceptor<S,
E> - Overrides:
postStateChange
in classStateMachineInterceptorAdapter<S,
E> - Parameters:
state
- the statemessage
- the messagetransition
- the transitionstateMachine
- the state machinerootStateMachine
- the root state machine
-
write
WriteStateMachineContext
into persistent store. -
read
ReadStateMachineContext
from persistent store. -
setExtendedStateVariablesFunction
public void setExtendedStateVariablesFunction(Function<StateMachine<S, E>, Map<Object, Object>> extendedStateVariablesFunction) Sets the function creating extended state variables.- Parameters:
extendedStateVariablesFunction
- the extended state variables function
-
buildStateMachineContext
protected StateMachineContext<S,E> buildStateMachineContext(StateMachine<S, E> stateMachine, StateMachine<S, E> rootStateMachine, State<S, E> state) Deprecated.Builds the state machine context. Note, for backward compatibility this method doesn't pass event or headers into aStateMachineContext
. Implementor of this class, if using this method should move over tobuildStateMachineContext(StateMachine, StateMachine, State, Message)
.- Parameters:
stateMachine
- the state machinerootStateMachine
- the root state machinestate
- the state- Returns:
- the state machine context
-
buildStateMachineContext
protected StateMachineContext<S,E> buildStateMachineContext(StateMachine<S, E> stateMachine, StateMachine<S, E> rootStateMachine, State<S, E> state, org.springframework.messaging.Message<E> message) Builds the state machine context.- Parameters:
stateMachine
- the state machinerootStateMachine
- the root state machinestate
- the statemessage
- the message- Returns:
- the state machine context
-
buildStateMachineContext(StateMachine, StateMachine, State, Message)