org.springframework.batch.core.step.job

## Class JobStep

- java.lang.Object
- - org.springframework.batch.core.step.AbstractStep
  - - org.springframework.batch.core.step.job.JobStep

- All Implemented Interfaces:
    Step, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean

      public class JobStep
      extends AbstractStep

  A `Step` that delegates to a `Job` to do its work. This is a great tool for managing dependencies between jobs, and also to modularise complex step logic into something that is testable in isolation. The job is executed with parameters that can be extracted from the step execution, hence this step can also be usefully used as the worker in a parallel or partitioned execution.
  Author:
    Dave Syer

- - ### Field Summary

    - ### Fields inherited from interface org.springframework.batch.core.Step

      `STEP_TYPE_KEY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JobStep()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()`
    `protected void` | `doExecute(StepExecution stepExecution)` Execute the job provided by delegating to the `JobLauncher` to prevent duplicate executions.
    `void` | `setJob(Job job)` The `Job` to delegate to in this step.
    `void` | `setJobLauncher(JobLauncher jobLauncher)` A `JobLauncher` is required to be able to run the enclosed `Job`.
    `void` | `setJobParametersExtractor(JobParametersExtractor jobParametersExtractor)` The `JobParametersExtractor` is used to extract `JobParametersExtractor` from the `StepExecution` to run the `Job`.

    - ### Methods inherited from class org.springframework.batch.core.step.AbstractStep

      `close, doExecutionRegistration, doExecutionRelease, execute, getCompositeListener, getJobRepository, getName, getStartLimit, isAllowStartIfComplete, open, registerStepExecutionListener, setAllowStartIfComplete, setBeanName, setJobRepository, setName, setStartLimit, setStepExecutionListeners, toString`

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

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

- - ### Constructor Detail

    - #### JobStep

          public JobStep()

  - ### Method Detail

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws java.lang.Exception

      Specified by:
        `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
      Overrides:
        `afterPropertiesSet` in class `AbstractStep`
      Throws:
        `java.lang.Exception`

    - #### setJob

          public void setJob(Job job)

      The `Job` to delegate to in this step.
      Parameters:
        `job` - a `Job`

    - #### setJobLauncher

          public void setJobLauncher(JobLauncher jobLauncher)

      A `JobLauncher` is required to be able to run the enclosed `Job`.
      Parameters:
        `jobLauncher` - the `JobLauncher` to set

    - #### setJobParametersExtractor

          public void setJobParametersExtractor(JobParametersExtractor jobParametersExtractor)

      The `JobParametersExtractor` is used to extract `JobParametersExtractor` from the `StepExecution` to run the `Job`. By default an instance will be provided that simply copies the `JobParameters` from the parent job.
      Parameters:
        `jobParametersExtractor` - the `JobParametersExtractor` to set

    - #### doExecute

          protected void doExecute(StepExecution stepExecution)
                            throws java.lang.Exception

      Execute the job provided by delegating to the `JobLauncher` to prevent duplicate executions. The job parameters will be generated by the `JobParametersExtractor` provided (if any), otherwise empty. On a restart, the job parameters will be the same as the last (failed) execution.
      Specified by:
        `doExecute` in class `AbstractStep`
      Parameters:
        `stepExecution` - the current step context
      Throws:
        `java.lang.Exception`
      See Also:
        `AbstractStep.doExecute(StepExecution)`