Interface RequestControlContext

All Superinterfaces:
RequestContext
All Known Implementing Classes:
MockRequestControlContext

public interface RequestControlContext extends RequestContext
Mutable control interface used to manipulate an ongoing flow execution in the context of one client request. Primarily used internally by the various flow artifacts when they are invoked.

This interface acts as a facade for core definition constructs such as the central Flow and State classes, abstracting away details about the runtime execution machine.

Note this type is not the same as the FlowExecutionContext. Objects of this type are request specific: they provide a control interface for manipulating exactly one flow execution locally from exactly one request. A FlowExecutionContext provides information about a single flow execution (conversation), and it's scope is not local to a specific request (or thread).

Author:
Keith Donald, Erwin Vervaet
See Also:
  • Method Details

    • setCurrentState

      void setCurrentState(State state)
      Record the current state that has entered in the executing flow. This method will be called as part of entering a new state by the State type itself.
      Parameters:
      state - the current state
      See Also:
    • assignFlowExecutionKey

      FlowExecutionKey assignFlowExecutionKey()
      Assign the ongoing flow execution its flow execution key. This method will be called before a state is about to render a view and pause the flow execution.
    • setCurrentView

      void setCurrentView(View view)
      Sets the current view.
      Parameters:
      view - the current view, or null to mark the current view as null
    • viewRendering

      void viewRendering(View view)
      Called when the current view is about to be rendered in the current view state.
      Parameters:
      view - the view to be rendered
    • viewRendered

      void viewRendered(View view)
      Called when the current view has completed rendering in the current view state.
      Parameters:
      view - the view that rendered
    • handleEvent

      boolean handleEvent(Event event) throws FlowExecutionException
      Signals the occurrence of an event in the current state of this flow execution request context. This method should be called by clients that report internal event occurrences, such as action states. The onEvent() method of the flow involved in the flow execution will be called.
      Parameters:
      event - the event that occurred
      Returns:
      a boolean indicating if handling this event caused the current state to exit and a new state to enter
      Throws:
      FlowExecutionException - if an exception was thrown within a state of the flow during execution of this signalEvent operation
      See Also:
    • execute

      boolean execute(Transition transition)
      Execute this transition out of the current source state. Allows for privileged execution of an arbitrary transition.
      Parameters:
      transition - the transition
      See Also:
    • setCurrentTransition

      void setCurrentTransition(Transition transition)
      Record the transition executing in the flow. This method will be called as part of executing a transition from one state to another.
      Parameters:
      transition - the transition being executed
      See Also:
    • updateCurrentFlowExecutionSnapshot

      void updateCurrentFlowExecutionSnapshot()
      Update the current flow execution snapshot to save the current state.
    • removeCurrentFlowExecutionSnapshot

      void removeCurrentFlowExecutionSnapshot()
      Remove the current flow execution snapshot to invalidate the current state.
    • removeAllFlowExecutionSnapshots

      void removeAllFlowExecutionSnapshots()
      Remove all flow execution snapshots associated with the ongoing conversation. Invalidates previous states.
    • start

      void start(Flow flow, MutableAttributeMap<?> input) throws FlowExecutionException
      Spawn a new flow session and activate it in the currently executing flow. Also transitions the spawned flow to its start state. This method should be called by clients that wish to spawn new flows, such as subflow states.

      This will start a new flow session in the current flow execution, which is already active.

      Parameters:
      flow - the flow to start, its start() method will be called
      input - initial contents of the newly created flow session (may be null, e.g. empty)
      Throws:
      FlowExecutionException - if an exception was thrown within a state of the flow during execution of this start operation
      See Also:
    • endActiveFlowSession

      void endActiveFlowSession(String outcome, MutableAttributeMap<Object> output) throws IllegalStateException
      End the active flow session of the current flow execution. This method should be called by clients that terminate flows, such as end states. The end() method of the flow involved in the flow execution will be called.
      Parameters:
      outcome - the logical outcome the ending session should return
      output - output the ending session should return
      Throws:
      IllegalStateException - when the flow execution is not active
      See Also:
    • getRedirectOnPause

      boolean getRedirectOnPause()
      Returns true if the 'redirect on pause' flow execution attribute is set to true, false otherwise.
      Returns:
      true or false
    • getRedirectInSameState

      boolean getRedirectInSameState()
      Returns the value of the 'redirect in same state' flow execution attribute if set or otherwise it falls back on the value returned by getRedirectOnPause().
      Returns:
      true or false
    • getEmbeddedMode

      boolean getEmbeddedMode()
      Returns true if the flow current flow execution was launched in embedded page mode. When a flow is embedded on a page it can make different assumptions with regards to whether redirect after post is necessary.