Example usage for org.springframework.statemachine.state PseudoState exit

List of usage examples for org.springframework.statemachine.state PseudoState exit

Introduction

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

Prototype

void exit(StateContext<S, E> context);

Source Link

Document

Initiate an exit sequence for the 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//from w  w  w .  j  a v  a2 s .  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);
                }
            });
        }
    }
}