org.springframework.batch.core.job.flow

## Class JobFlowExecutor

- java.lang.Object
- - org.springframework.batch.core.job.flow.JobFlowExecutor

- All Implemented Interfaces:
    FlowExecutor
  Direct Known Subclasses:
    JsrFlowExecutor

      public class JobFlowExecutor
      extends java.lang.Object
      implements FlowExecutor

  Implementation of `FlowExecutor` for use in components that need to execute a flow related to a `JobExecution`.
  Author:
    Dave Syer, Michael Minella, Mahmoud Ben Hassine

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ExitStatus` | `exitStatus`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JobFlowExecutor(JobRepository jobRepository, StepHandler stepHandler, JobExecution execution)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `abandonStepExecution()` Handle any status changes that might be needed at the start of a state.
    `void` | `addExitStatus(java.lang.String code)`
    `void` | `close(FlowExecution result)` Chance to clean up resources at the end of a flow (whether it completed successfully or not).
    `java.lang.String` | `executeStep(Step step)`
    `protected BatchStatus` | `findBatchStatus(FlowExecutionStatus status)`
    `JobExecution` | `getJobExecution()`
    `StepExecution` | `getStepExecution()`
    `boolean` | `isRestart()`
    `void` | `updateJobExecutionStatus(FlowExecutionStatus status)` Handle any status changes that might be needed in the `JobExecution`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### exitStatus

          protected ExitStatus exitStatus

  - ### Constructor Detail

    - #### JobFlowExecutor

          public JobFlowExecutor(JobRepository jobRepository,
                                 StepHandler stepHandler,
                                 JobExecution execution)

      Parameters:
        `jobRepository` - instance of `JobRepository`.
        `stepHandler` - instance of `StepHandler`.
        `execution` - instance of `JobExecution`.

  - ### Method Detail

    - #### executeStep

          public java.lang.String executeStep(Step step)
                                       throws JobInterruptedException,
                                              JobRestartException,
                                              StartLimitExceededException

      Specified by:
        `executeStep` in interface `FlowExecutor`
      Parameters:
        `step` - a `Step` to execute
      Returns:
        the exit status that drives the surrounding `Flow`
      Throws:
        `JobInterruptedException` - thrown if job was interrupted.
        `JobRestartException` - thrown if job restart is not allowed.
        `StartLimitExceededException` - thrown if start limit is exceeded.

    - #### abandonStepExecution

          public void abandonStepExecution()

      Description copied from interface: `FlowExecutor`
      Handle any status changes that might be needed at the start of a state.
      Specified by:
        `abandonStepExecution` in interface `FlowExecutor`

    - #### updateJobExecutionStatus

          public void updateJobExecutionStatus(FlowExecutionStatus status)

      Description copied from interface: `FlowExecutor`
      Handle any status changes that might be needed in the `JobExecution`.
      Specified by:
        `updateJobExecutionStatus` in interface `FlowExecutor`
      Parameters:
        `status` - status to update the `JobExecution` to.

    - #### getJobExecution

          public JobExecution getJobExecution()

      Specified by:
        `getJobExecution` in interface `FlowExecutor`
      Returns:
        the current `JobExecution`

    - #### getStepExecution

          @Nullable
          public StepExecution getStepExecution()

      Specified by:
        `getStepExecution` in interface `FlowExecutor`
      Returns:
        the latest `StepExecution` or null if there is none

    - #### close

          public void close(FlowExecution result)

      Description copied from interface: `FlowExecutor`
      Chance to clean up resources at the end of a flow (whether it completed successfully or not).
      Specified by:
        `close` in interface `FlowExecutor`
      Parameters:
        `result` - the final `FlowExecution`

    - #### isRestart

          public boolean isRestart()

      Specified by:
        `isRestart` in interface `FlowExecutor`
      Returns:
        true if the flow is at the beginning of a restart

    - #### addExitStatus

          public void addExitStatus(java.lang.String code)

      Specified by:
        `addExitStatus` in interface `FlowExecutor`
      Parameters:
        `code` - the label for the exit status when a flow or sub-flow ends

    - #### findBatchStatus

          protected BatchStatus findBatchStatus(FlowExecutionStatus status)

      Parameters:
        `status` - `FlowExecutionStatus` to convert.
      Returns:
        A `BatchStatus` appropriate for the `FlowExecutionStatus` provided