Interface StateMachineInterceptor<S,E>
- Type Parameters:
S- the type of stateE- the type of event
- All Known Implementing Classes:
AbstractPersistingStateMachineInterceptor,JpaPersistingStateMachineInterceptor,MongoDbPersistingStateMachineInterceptor,RedisPersistingStateMachineInterceptor,StateMachineInterceptorAdapter,StateMachineSecurityInterceptor
public interface StateMachineInterceptor<S,E>
Interface which can be registered with a state machine and can be used
to intercept and break a state change chain.
- Author:
- Janne Valkealahti
-
Method Summary
Modifier and TypeMethodDescriptionvoidpostStateChange(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.postTransition(StateContext<S, E> stateContext) Called after of a transition if transition happened.org.springframework.messaging.Message<E>preEvent(org.springframework.messaging.Message<E> message, StateMachine<S, E> stateMachine) Called before message is sent to processing.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.preTransition(StateContext<S, E> stateContext) Called prior of a start of a transition.stateMachineError(StateMachine<S, E> stateMachine, Exception exception) State when state machine is about to enter error it can't recover.
-
Method Details
-
preEvent
org.springframework.messaging.Message<E> preEvent(org.springframework.messaging.Message<E> message, StateMachine<S, E> stateMachine) Called before message is sent to processing. Throwing exception or returning null will skip the message.- Parameters:
message- the messagestateMachine- the state machine- Returns:
- the intercepted message
-
preStateChange
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. Throwing an exception from this method will stop a state change logic.- Parameters:
state- the statemessage- the messagetransition- the transitionstateMachine- the state machinerootStateMachine- the root state machine
-
postStateChange
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.- Parameters:
state- the statemessage- the messagetransition- the transitionstateMachine- the state machinerootStateMachine- the root state machine
-
preTransition
Called prior of a start of a transition. Returningnullfrom this method will break the transtion chain.- Parameters:
stateContext- the state context- Returns:
- the state context
-
postTransition
Called after of a transition if transition happened.- Parameters:
stateContext- the state context- Returns:
- the state context
-
stateMachineError
State when state machine is about to enter error it can't recover.- Parameters:
stateMachine- the state machineexception- the exception- Returns:
- the exception
-