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

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

Introduction

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

Prototype

void addPseudoStateListener(PseudoStateListener<S, E> listener);

Source Link

Document

Registers a new PseudoStateListener .

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  ww.  j a v  a  2 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);
                }
            });
        }
    }
}