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 StateMachineContexts.
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.-
Constructor Summary
Constructors -
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.voidpostStateChange(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.voidpreStateChange(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> ReadStateMachineContextfrom persistent store.voidsetExtendedStateVariablesFunction(Function<StateMachine<S, E>, Map<Object, Object>> extendedStateVariablesFunction) Sets the function creating extended state variables.abstract voidwrite(StateMachineContext<S, E> context, T contextObj) WriteStateMachineContextinto 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:StateMachineInterceptorCalled prior of a state change. Throwing an exception from this method will stop a state change logic.- Specified by:
preStateChangein interfaceStateMachineInterceptor<S,E> - Overrides:
preStateChangein 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:StateMachineInterceptorCalled after a state change.- Specified by:
postStateChangein interfaceStateMachineInterceptor<S,E> - Overrides:
postStateChangein classStateMachineInterceptorAdapter<S,E> - Parameters:
state- the statemessage- the messagetransition- the transitionstateMachine- the state machinerootStateMachine- the root state machine
-
write
WriteStateMachineContextinto persistent store. -
read
ReadStateMachineContextfrom 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
@Deprecated 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)