List of usage examples for org.springframework.statemachine.support StateMachineUtils isTransientPseudoState
public static <S, E> boolean isTransientPseudoState(State<S, E> state)
From source file:org.springframework.statemachine.support.AbstractStateMachine.java
private void switchToState(State<S, E> state, Message<E> message, Transition<S, E> transition, StateMachine<S, E> stateMachine) { if (!isInitialTransition(transition) && !StateMachineUtils.isTransientPseudoState(state) && !callPreStateChangeInterceptors(state, message, transition, stateMachine)) { return;/*from w w w . j a v a 2 s . c o m*/ } StateContext<S, E> stateContext = buildStateContext(Stage.STATE_CHANGED, message, transition, stateMachine); State<S, E> toState = followLinkedPseudoStates(state, stateContext); PseudoStateKind kind = state.getPseudoState() != null ? state.getPseudoState().getKind() : null; if (kind != null && (kind != PseudoStateKind.INITIAL && kind != PseudoStateKind.JOIN && kind != PseudoStateKind.FORK)) { callPreStateChangeInterceptors(toState, message, transition, stateMachine); } // need to check for from original state passed in kind = toState.getPseudoState() != null ? toState.getPseudoState().getKind() : null; if (kind == PseudoStateKind.FORK) { exitCurrentState(toState, message, transition, stateMachine); ForkPseudoState<S, E> fps = (ForkPseudoState<S, E>) toState.getPseudoState(); for (State<S, E> ss : fps.getForks()) { callPreStateChangeInterceptors(ss, message, transition, stateMachine); setCurrentState(ss, message, transition, false, stateMachine, null, fps.getForks()); } } else { Collection<State<S, E>> targets = new ArrayList<>(); targets.add(toState); setCurrentState(toState, message, transition, true, stateMachine, null, targets); } callPostStateChangeInterceptors(state, message, transition, stateMachine); stateMachineExecutor.execute(); if (isComplete()) { stop(); } }
From source file:org.springframework.statemachine.support.AbstractStateMachine.java
private void entryToState(State<S, E> state, Message<E> message, Transition<S, E> transition, StateMachine<S, E> stateMachine, Collection<State<S, E>> sources, Collection<State<S, E>> targets) { if (state == null) { return;/* w w w . j a v a 2s . c om*/ } log.trace("Trying Enter state=[" + state + "]"); StateContext<S, E> stateContext = buildStateContext(Stage.STATE_ENTRY, message, transition, stateMachine, sources, targets); if (transition != null) { State<S, E> findDeep1 = findDeepParent(transition.getTarget()); State<S, E> findDeep2 = findDeepParent(transition.getSource()); boolean isComingFromOtherSubmachine = findDeep1 != null && findDeep2 != null && findDeep2 != currentState; boolean isSubOfSource = StateMachineUtils.isSubstate(transition.getSource(), currentState); boolean isSubOfTarget = StateMachineUtils.isSubstate(transition.getTarget(), currentState); if (transition.getKind() == TransitionKind.LOCAL && StateMachineUtils.isSubstate(transition.getSource(), transition.getTarget()) && transition.getSource() == currentState) { return; } else if (transition.getKind() == TransitionKind.LOCAL && StateMachineUtils.isSubstate(transition.getTarget(), transition.getSource()) && transition.getTarget() == currentState) { return; } if (currentState == transition.getSource() && currentState == transition.getTarget()) { } else if (!isSubOfSource && !isSubOfTarget && currentState == transition.getTarget()) { } else if (isComingFromOtherSubmachine) { } else if (!isSubOfSource && !isSubOfTarget && findDeep2 == null) { } else if (isSubOfSource && !isSubOfTarget && currentState == transition.getTarget()) { if (isDirectSubstate(transition.getSource(), transition.getTarget()) && transition.getKind() != TransitionKind.LOCAL && isInitial(transition.getTarget())) { return; } } else if (!isSubOfSource && !isSubOfTarget && (transition.getSource() == currentState && StateMachineUtils.isSubstate(currentState, transition.getTarget()))) { } else if (!isSubOfSource && !isSubOfTarget) { if (!StateMachineUtils.isTransientPseudoState(transition.getTarget())) { return; } } } // with linked joins, we need to enter state but should not notify. // state entries are needed to track join logic. if (!StateMachineUtils.isPseudoState(state, PseudoStateKind.JOIN)) { notifyStateEntered( buildStateContext(Stage.STATE_ENTRY, message, transition, getRelayStateMachine(), null, state)); } log.debug("Enter state=[" + state + "]"); state.entry(stateContext); }