Interface StateMachineInterceptor<S,E>

Type Parameters:
S - the type of state
E - 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 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 message
      stateMachine - 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 state
      message - the message
      transition - the transition
      stateMachine - the state machine
      rootStateMachine - 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 state
      message - the message
      transition - the transition
      stateMachine - the state machine
      rootStateMachine - the root state machine
    • preTransition

      StateContext<S,E> preTransition(StateContext<S,E> stateContext)
      Called prior of a start of a transition. Returning null from this method will break the transtion chain.
      Parameters:
      stateContext - the state context
      Returns:
      the state context
    • postTransition

      StateContext<S,E> postTransition(StateContext<S,E> stateContext)
      Called after of a transition if transition happened.
      Parameters:
      stateContext - the state context
      Returns:
      the state context
    • stateMachineError

      Exception stateMachineError(StateMachine<S,E> stateMachine, Exception exception)
      State when state machine is about to enter error it can't recover.
      Parameters:
      stateMachine - the state machine
      exception - the exception
      Returns:
      the exception