Interface SimpleWorkflow

All Known Implementing Classes:
SimpleWorkflowExecution

public interface SimpleWorkflow
Prescribed interface for representing an ordered list of business tasks (SimpleActivity). Responsible for launching execution of activities at any point in the list. Also, responsible for exposing queryable information about the workflow, including execution history and metadata about workflow contents. See SimpleWorkflowExecution for concrete implementation.
  • Method Details

    • shutdown

      void shutdown()
      Stop a running workflow. Generally called at JVM shutdown in case the workflow is still running. Gives the workflow a chance to clean up and pause before exit.
    • start

      void start(Map<String,Object> context)
      Start execution of the list of SimpleActivity items at the first position.
      Parameters:
      context - Any information that needs to be supplied to one or more activities
      Throws:
      WorkflowCancelException - thrown when a cancellation signal is detected at runtime
      WorkflowPauseException - thrown when a pause signal is detected at runtime
    • goToStep

      void goToStep(String name)
      Signal the workflow to circumvent normal execution ordering and skip forward or backward to the position where the SimpleActivity.getName() matches the supplied name. The signal is honored once the currently running activity (if any) finishes.
      Parameters:
      name - The name of the activity to match in order to identify the starting point
    • cancel

      void cancel(boolean fail)
      Cancel execution once the currently running activity (if any) finishes.
      Parameters:
      fail - Whether to mark the workflow as failed. If false, the workflow will be marked completed.
    • pause

      void pause(boolean autoRestart)
      Stop execution once the currently running activity (if any) finishes.
      Parameters:
      autoRestart - Whether to mark the workflow as available for automatic resume. If true, hints to the system infrastructure that it should resume processing of this workflow at the next available processor.
    • getMap

      Return the map of metadata defining order and identifying information about all contained SimpleActivity members.
      Returns:
      The map of metadata defining order and identifying information
      See Also:
    • getHistory

      History getHistory()
      Return the list of start and end times, status, and possible failure information for all SimpleActivity executions that have occurred.
      Returns:
      The list of start and end times, status, and possible failure information
      See Also:
    • execute

      void execute(List<Step> steps, @Nullable Step target, Map<String,Object> context)
      Execute a list of SimpleActivity members identified by their names at the position identified by the activity whose name matches the name parameters. Also, provide the context information to pass to the workflow execution.
      Parameters:
      steps - List of SimpleActivity member names
      target - The activity that represents the starting point in the list. Optional. Start at the first position if null.
      context - Any information that needs to be supplied to one or more activities
      See Also:
    • getNextStep

      @Nullable String getNextStep(@Nullable String lastStep, @Nullable String lastResponse)
      Given a previous step and response (see ActivityResponse), determine what the next step should be in the workflow. Workflow execution is dynamic in this regard based on decision criteria registered as part of Step.getDecisions().
      Parameters:
      lastStep - The name of the previous step to execute
      lastResponse - The response value from the previous step to execute
      Returns:
      The name of the next step that should execute
    • allowHistoricalReset

      default boolean allowHistoricalReset()
      Whether requesting a previously executed step (prior to the last step) in goToStep(String) is allowed. This is different from retry, which is an attempt to re-execute the most recent historical activity.
      Returns:
      Whether requesting a previously executed step (prior to the last step) is allowed
    • allowRetry

      default boolean allowRetry()
      Whether requesting the most recently executed step in goToStep(String) is allowed.
      Returns:
      Whether requesting the most recent executed step is allowed
    • getDescription

      String getDescription()
      A human-readable description for this workflow. Generally also unique like the name to ensure clarity in the admin UI.
      Returns:
      A human-readable description for this workflow.
    • getSteps

      List<Step> getSteps()
      Retrieve the ordered list of names for all the activities supported by this workflow. The names should match Spring bean names for each, as SimpleActivity implementations use Spring as the bean factory for retrieval of instances.
      Returns:
      The ordered list of names for all the activities supported by this workflow
    • getName

      String getName()
      The unique name for this workflow. Should match the Spring bean name for the workflow bean.
      Returns:
      The unique name for this workflow.
    • getCurrentActivity

      String getCurrentActivity()
      The current activity that is running in the workflow.
      Returns:
      The current activity that is running in the workflow.