Package org.springframework.statemachine
Interface StateContext<S,E>
- All Known Implementing Classes:
DefaultStateContext
public interface StateContext<S,E>
StateContext
is representing of a current context used in
various stages in a state machine execution. These include for example
Transition
s, Action
s and Guard
s order to get access
to event headers and ExtendedState
.
Context really is not a current state of a state machine but more like a snapshot of where state machine is when this context is passed to various methods.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Enumeration of possible stages context is attached. -
Method Summary
Modifier and TypeMethodDescriptiongetEvent()
Gets the event associated with a context.Gets the exception associated with a context.Gets the state machine extended state.org.springframework.messaging.Message<E>
Gets the message associated with a context.getMessageHeader
(Object header) Gets the message header.org.springframework.messaging.MessageHeaders
Gets the event message headers.Gets the source state of this context.Collection<State<S,
E>> Gets the source states of this context.getStage()
Gets the stage this context is attached.Gets the state machine.Gets the target state of this context.Collection<State<S,
E>> Gets the target states of this context.Transition<S,
E> Gets the transition.
-
Method Details
-
getStage
StateContext.Stage getStage()Gets the stage this context is attached.- Returns:
- the stage
-
getMessage
org.springframework.messaging.Message<E> getMessage()Gets the message associated with a context. Message may be null if transition is not triggered by a signal.- Returns:
- the message
-
getEvent
E getEvent()Gets the event associated with a context. Event may be null if transition is not triggered by a signal.- Returns:
- the event
-
getMessageHeaders
org.springframework.messaging.MessageHeaders getMessageHeaders()Gets the event message headers.- Returns:
- the event message headers
-
getMessageHeader
Gets the message header. If header is not aString
object'sObject.toString()
method is used to resolve a key name.- Parameters:
header
- the header- Returns:
- the message header
-
getExtendedState
ExtendedState getExtendedState()Gets the state machine extended state.- Returns:
- the state machine extended state
-
getTransition
Transition<S,E> getTransition()Gets the transition.- Returns:
- the transition
-
getStateMachine
StateMachine<S,E> getStateMachine()Gets the state machine.- Returns:
- the state machine
-
getSource
Gets the source state of this context. Generally source is where a state machine is coming from which may be different than what the transition source is.- Returns:
- the source state
-
getSources
Collection<State<S,E>> getSources()Gets the source states of this context. Multiple sources are only valid during a context when machine is joining from multiple orthogonal regions.- Returns:
- the source state
- See Also:
-
getTarget
Gets the target state of this context. Generally target is where a state machine going to which may be different than what the transition target is.- Returns:
- the target state
-
getTargets
Collection<State<S,E>> getTargets()Gets the target states of this context. Multiple targets are only valid during a context when machine is forking into multiple orthogonal regions.- Returns:
- the target states
- See Also:
-
getException
Exception getException()Gets the exception associated with a context.- Returns:
- the exception
-