Example usage for org.springframework.statemachine.state PseudoStateContext getPseudoState

List of usage examples for org.springframework.statemachine.state PseudoStateContext getPseudoState

Introduction

In this page you can find the example usage for org.springframework.statemachine.state PseudoStateContext getPseudoState.

Prototype

PseudoState<S, E> getPseudoState();

Source Link

Document

Gets the pseudo state.

Usage

From source file:org.springframework.statemachine.support.AbstractStateMachine.java

private void registerPseudoStateListener() {
    for (State<S, E> state : states) {
        PseudoState<S, E> p = state.getPseudoState();
        if (p != null) {
            p.addPseudoStateListener(new PseudoStateListener<S, E>() {
                @Override//  w  w w.  j  a va  2s. c o  m
                public void onContext(PseudoStateContext<S, E> context) {
                    PseudoState<S, E> pseudoState = context.getPseudoState();
                    State<S, E> toStateOrig = findStateWithPseudoState(pseudoState);
                    StateContext<S, E> stateContext = buildStateContext(Stage.STATE_EXIT, null, null,
                            getRelayStateMachine());
                    State<S, E> toState = followLinkedPseudoStates(toStateOrig, stateContext);
                    // TODO: try to find matching transition based on direct link.
                    // should make this built-in in pseudostates
                    Transition<S, E> transition = findTransition(toStateOrig, toState);
                    switchToState(toState, null, transition, getRelayStateMachine());
                    pseudoState.exit(stateContext);
                }
            });
        }
    }
}