Search in sources :

Example 1 with State

use of org.webpieces.javasm.api.State in project webpieces by deanhiller.

the class Level5AStates method fireToStatemachineImpl.

private void fireToStatemachineImpl(Stream stream, Http2Event event) {
    Memento currentState = stream.getCurrentState();
    State old = currentState.getCurrentState();
    State result = stateMachine.fireEvent(currentState, event);
    log.info(logId + "done firing evt=" + event + " " + old + " -> " + result);
}
Also used : Memento(org.webpieces.javasm.api.Memento) State(org.webpieces.javasm.api.State)

Example 2 with State

use of org.webpieces.javasm.api.State in project webpieces by deanhiller.

the class StateImpl method fireEvent.

/**
     * @param smState
     * @param evt
     */
public void fireEvent(StateMachineState smState, Object evt) {
    TransitionImpl transition = evtToTransition.get(evt);
    if (transition == null) {
        transition = evtToTransition.get(StateMachineFactory.ANY_EVENT);
    }
    if (transition == null) {
        smState.getLogger().debug(() -> smState + "No Transition: " + getName() + " -> <no transition found>, event=" + evt);
        this.fireNoTransition(smState, evt);
        return;
    }
    StateImpl endState = transition.getEndState();
    State nextState = transition.getEndState();
    smState.getLogger().debug(() -> smState + "Transition: " + getName() + " -> " + nextState + ", event=" + evt);
    try {
        this.fireExitActions(smState);
        transition.fireTransitionActions(smState);
        endState.fireEntryActions(smState);
        smState.setCurrentState(nextState);
    } catch (RuntimeException e) {
        smState.getLogger().warn(smState + "Transition FAILED: " + getName() + " -> " + nextState + ", event=" + evt);
        throw e;
    }
}
Also used : State(org.webpieces.javasm.api.State)

Aggregations

State (org.webpieces.javasm.api.State)2 Memento (org.webpieces.javasm.api.Memento)1