public boolean execute(Transition transition) { return transition.execute((TransitionableState) getCurrentState(), this); }
/** * Specialization of State's <code>doEnter</code> template method that executes behavior specific to this state type * in polymorphic fashion. * <p> * Simply looks up the first transition that matches the state of the context and executes it. * @param context the control context for the currently executing flow, used by this state to manipulate the flow * execution * @throws FlowExecutionException if an exception occurs in this state */ protected void doEnter(RequestControlContext context) throws FlowExecutionException { getRequiredTransition(context).execute(this, context); } }
boolean execute(Transition transition, RequestControlContext context) { listeners.fireTransitionExecuting(context, transition); return transition.execute((State) getActiveSession().getState(), context); }
/** * Inform this state definition that an event was signaled in it. The signaled event is the last event available in * given request context ({@link RequestContext#getLastEvent()}). * @param context the flow execution control context * @return the selected view * @throws NoMatchingTransitionException when a matching transition cannot be found */ public ViewSelection onEvent(RequestControlContext context) throws NoMatchingTransitionException { return getRequiredTransition(context).execute(this, context); }
/** * Specialization of State's <code>doEnter</code> template method that executes behavior specific to this state type * in polymorphic fashion. * <p> * Simply looks up the first transition that matches the state of the context and executes it. * @param context the control context for the currently executing flow, used by this state to manipulate the flow * execution * @throws FlowExecutionException if an exception occurs in this state */ protected void doEnter(RequestControlContext context) throws FlowExecutionException { getRequiredTransition(context).execute(this, context); } }
/** * Specialization of State's <code>doEnter</code> template method that executes behavior specific to this state * type in polymorphic fashion. * <p> * Simply looks up the first transition that matches the state of the context and executes it. * @param context the control context for the currently executing flow, used by this state to manipulate the flow * execution * @throws FlowExecutionException if an exception occurs in this state */ protected void doEnter(RequestControlContext context) throws FlowExecutionException { getRequiredTransition(context).execute(this, context); } }
public ViewSelection execute(Transition transition) { return transition.execute((TransitionableState) getCurrentState(), this); } }
public boolean execute(Transition transition) { return transition.execute((TransitionableState) getCurrentState(), this); }
public ViewSelection execute(Transition transition) { return transition.execute(getCurrentStateInternal(), this); }
public boolean execute(Transition transition) { return transition.execute((TransitionableState) getCurrentState(), this); }
/** * Specialization of State's <code>doEnter</code> template method that executes behaviour specific to this state * type in polymorphic fashion. * <p> * Simply looks up the first transition that matches the state of the context and executes it. * @param context the control context for the currently executing flow, used by this state to manipulate the flow * execution * @return a view selection containing model and view information needed to render the results of the state * execution * @throws FlowExecutionException if an exception occurs in this state */ protected ViewSelection doEnter(RequestControlContext context) throws FlowExecutionException { return getRequiredTransition(context).execute(this, context); } }
boolean execute(Transition transition, RequestControlContext context) { listeners.fireTransitionExecuting(context, transition); return transition.execute(getCurrentState(), context); }
boolean execute(Transition transition, RequestControlContext context) { listeners.fireTransitionExecuting(context, transition); return transition.execute((State) getActiveSession().getState(), context); }
/** * Inform this flow definition that an event was signaled in the current state of an active flow execution. The * signaled event is the last event available in given request context ({@link RequestContext#getLastEvent()}). * @param context the flow execution control context * @return the selected view * @throws FlowExecutionException when an exception occurs processing the event */ public ViewSelection onEvent(RequestControlContext context) throws FlowExecutionException { TransitionableState currentState = getCurrentTransitionableState(context); try { return currentState.onEvent(context); } catch (NoMatchingTransitionException e) { // try the flow level transition set for a match Transition transition = globalTransitionSet.getTransition(context); if (transition != null) { return transition.execute(currentState, context); } else { // no matching global transition => let the original exception // propagate throw e; } } }
public void testExecuteTransitionWithNullSourceState() { Flow flow = new Flow("flow"); final TransitionableState target = new TransitionableState(flow, "state 2") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; TargetStateResolver targetResolver = (transition, sourceState, context) -> { assertNull(sourceState); return target; }; MockRequestControlContext context = new MockRequestControlContext(flow); Transition t = new Transition(targetResolver); boolean stateChanged = t.execute(null, context); assertTrue(stateChanged); assertSame(target, context.getCurrentState()); }
public void testExecuteTransitionNullTargetState() { Flow flow = new Flow("flow"); final TransitionableState source = new TransitionableState(flow, "state 1") { public void exit(RequestControlContext context) { exitCalled = true; } protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; TargetStateResolver targetResolver = (transition, sourceState, context) -> null; MockRequestControlContext context = new MockRequestControlContext(flow); context.setCurrentState(source); Transition t = new Transition(targetResolver); boolean stateExited = t.execute(source, context); assertFalse(stateExited); assertFalse(exitCalled); assertSame(source, context.getCurrentState()); }
public void testExecuteTransitionNullTargetStateResolver() { Flow flow = new Flow("flow"); final TransitionableState source = new TransitionableState(flow, "state 1") { public void exit(RequestControlContext context) { exitCalled = true; } protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; MockRequestControlContext context = new MockRequestControlContext(flow); context.setCurrentState(source); Transition t = new Transition(); boolean stateExited = t.execute(source, context); assertFalse(stateExited); assertFalse(exitCalled); assertSame(source, context.getCurrentState()); }
public void testExecuteTransitionFromState() { Flow flow = new Flow("flow"); final TransitionableState source = new TransitionableState(flow, "state 1") { public void exit(RequestControlContext context) { exitCalled = true; } protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; final TransitionableState target = new TransitionableState(flow, "state 2") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; TargetStateResolver targetResolver = (transition, sourceState, context) -> { assertSame(source, sourceState); return target; }; MockRequestControlContext context = new MockRequestControlContext(flow); context.setCurrentState(source); Transition t = new Transition(targetResolver); boolean stateExited = t.execute(source, context); assertTrue(stateExited); assertTrue(exitCalled); assertSame(target, context.getCurrentState()); }
public void testTransitionExecutionRefused() { Flow flow = new Flow("flow"); final TransitionableState source = new TransitionableState(flow, "state 1") { public void exit(RequestControlContext context) { exitCalled = true; } protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; final TransitionableState target = new TransitionableState(flow, "state 2") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; TargetStateResolver targetResolver = (transition, sourceState, context) -> { assertSame(source, sourceState); return target; }; MockRequestControlContext context = new MockRequestControlContext(flow); context.setCurrentState(source); Transition t = new Transition(targetResolver); t.setExecutionCriteria(context1 -> false); boolean stateExited = t.execute(source, context); assertFalse(stateExited); assertFalse(exitCalled); assertSame(source, context.getCurrentState()); }