Example usage for org.springframework.statemachine.state PseudoStateListener PseudoStateListener

List of usage examples for org.springframework.statemachine.state PseudoStateListener PseudoStateListener

Introduction

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

Prototype

PseudoStateListener

Source Link

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// ww w.  jav a2 s  .co  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);
                }
            });
        }
    }
}