public void exit(RequestControlContext context) { super.exit(context); updateHistory(context); destroyVariables(context); context.setCurrentView(null); }
/** * Handle an exception that occurred during an execution of this flow. * @param exception the exception that occurred * @param context the flow execution control context */ public boolean handleException(FlowExecutionException exception, RequestControlContext context) throws FlowExecutionException { return getExceptionHandlerSet().handleException(exception, context); }
/** * Handle an exception that occurred in this state during the context of the current flow execution request. * @param exception the exception that occurred * @param context the flow execution control context */ public boolean handleException(FlowExecutionException exception, RequestControlContext context) { return getExceptionHandlerSet().handleException(exception, context); }
/** * Configure common properties for a transitionable state. */ private void configureCommonProperties(TransitionableState state, Action[] entryActions, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap<?> attributes) { configureCommonProperties(state, entryActions, exceptionHandlers, attributes); state.getTransitionSet().addAll(transitions); state.getExitActionList().addAll(exitActions); }
/** * Configure common properties for a state. */ private void configureCommonProperties(State state, Action[] entryActions, FlowExecutionExceptionHandler[] exceptionHandlers, AttributeMap<?> attributes) { state.getEntryActionList().addAll(entryActions); state.getExceptionHandlerSet().addAll(exceptionHandlers); state.getAttributes().putAll(attributes); } }
/** * Creates a new exception. * @param state the action state * @param resultEvent the action result event */ public NoMatchingActionResultTransitionException(ActionState state, Event resultEvent) { super(state.getFlow().getId(), state.getId(), resultEvent, "Cannot find a transition matching an action result event; continuing with next action..."); } }
public Transition getRequiredTransition(RequestContext context) throws NoMatchingTransitionException { Transition transition = getTransitionSet().getTransition(context); if (transition == null) { throw new NoMatchingActionResultTransitionException(this, context.getCurrentEvent()); } return transition; }
/** * Set the start state for this flow to the state with the provided <code>stateId</code>; a state must exist by the * provided <code>stateId</code>. * @param stateId the id of the new start state * @throws IllegalArgumentException when no state exists with the id you provided */ public void setStartState(String stateId) throws IllegalArgumentException { setStartState(getStateInstance(stateId)); }
public TransitionDefinition[] getTransitions() { return getTransitionSet().toArray(); }
/** * Convenience accessor that returns an ordered array of the String <code>ids</code> for the state definitions * associated with this flow definition. * @return the state ids */ public String[] getStateIds() { String[] stateIds = new String[getStateCount()]; int i = 0; for (State state : states) { stateIds[i++] = state.getId(); } return stateIds; }
/** * Resume a paused session for this flow in its current view state. * @param context the flow execution control context * @throws FlowExecutionException when an exception occurs during the resume operation */ public void resume(RequestControlContext context) throws FlowExecutionException { restoreVariables(context); getCurrentViewState(context).resume(context); }
/** * Returns the de-serialized id indicating the flow id of this session. */ String getFlowId() { if (flow == null) { return flowId; } else { return flow.getId(); } }
/** * 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#getCurrentEvent()}). * @param context the flow execution control context * @throws NoMatchingTransitionException when a matching transition cannot be found */ public boolean handleEvent(RequestControlContext context) throws NoMatchingTransitionException { return context.execute(getRequiredTransition(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); } }
/** * Adds flow variables. * @param variables the variables */ public void addVariables(FlowVariable... variables) { if (variables == null) { return; } for (FlowVariable variable : variables) { addVariable(variable); } }
/** * Returns whether or not this list has a transition that will fire for given flow execution request context. * @param context a flow execution context */ public boolean hasMatchingTransition(RequestContext context) { return getTransition(context) != null; }
/** * Checks if this transition is eligible for execution given the state of the provided flow execution request * context. * @param context the flow execution request context * @return true if this transition should execute, false otherwise */ public boolean matches(RequestContext context) { return matchingCriteria.test(context); }
/** * Create a new subflow state. * @param flow the owning flow * @param id the state identifier (must be unique to the flow) * @param subflow the subflow to spawn * @throws IllegalArgumentException when this state cannot be added to given flow, e.g. because the id is not unique * @see #setAttributeMapper(SubflowAttributeMapper) */ public SubflowState(Flow flow, String id, Expression subflow) throws IllegalArgumentException { super(flow, id); setSubflow(subflow); }
/** * Adds a set of view variables. * @param variables the variables */ public void addVariables(ViewVariable... variables) { for (ViewVariable variable : variables) { addVariable(variable); } }
/** * Exit this state. This is typically called when a transition takes the flow out of this state into another state. * By default just executes any registered exit actions. * @param context the flow control context */ public void exit(RequestControlContext context) { exitActionList.execute(context); }