Package org.springframework.batch.core

# Class JobExecution

java.lang.Object
org.springframework.batch.core.Entity
org.springframework.batch.core.JobExecution

All Implemented Interfaces:
  `Serializable`

public class JobExecution extends Entity
Batch domain object representing the execution of a job.

Author:
  Lucas Ward, Michael Minella, Mahmoud Ben Hassine, Dimitrios Liapis
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JobExecution(Long id)`
  `JobExecution(Long id, JobParameters jobParameters)`
  `JobExecution(JobExecution original)`
  `JobExecution(JobInstance job, Long id, JobParameters jobParameters)`
  Because a JobExecution isn't valid unless the job is set, this constructor is the only valid one from a modeling point of view.
  `JobExecution(JobInstance job, JobParameters jobParameters)`
  Constructor for transient (unsaved) instances.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addFailureException(Throwable t)`
  Add the provided throwable to the failure exception list.
  `void`
  `addStepExecutions(List<StepExecution> stepExecutions)`
  Add some step executions.
  `StepExecution`
  `createStepExecution(String stepName)`
  Register a step execution with the current job execution.
  `List<Throwable>`
  `getAllFailureExceptions()`
  Return all failure causing exceptions for this JobExecution, including step executions.
  `Date`
  `getCreateTime()`
  `Date`
  `getEndTime()`
  `ExecutionContext`
  `getExecutionContext()`
  Returns the `ExecutionContext` for this execution.
  `ExitStatus`
  `getExitStatus()`
  `List<Throwable>`
  `getFailureExceptions()`
  `Long`
  `getJobId()`
  Convenience getter for for the id of the enclosing job.
  `JobInstance`
  `getJobInstance()`
  `JobParameters`
  `getJobParameters()`
  `Date`
  `getLastUpdated()`
  Get the date representing the last time this JobExecution was updated in the JobRepository.
  `Date`
  `getStartTime()`
  `BatchStatus`
  `getStatus()`
  `Collection<StepExecution>`
  `getStepExecutions()`
  Accessor for the step executions.
  `boolean`
  `isRunning()`
  Test if this `JobExecution` indicates that it is running.
  `boolean`
  `isStopping()`
  Test if this `JobExecution` indicates that it has been signalled to stop.
  `void`
  `setCreateTime(Date createTime)`
  `void`
  `setEndTime(Date endTime)`
  `void`
  `setExecutionContext(ExecutionContext executionContext)`
  Sets the `ExecutionContext` for this execution
  `void`
  `setExitStatus(ExitStatus exitStatus)`
  `void`
  `setJobInstance(JobInstance jobInstance)`
  `void`
  `setLastUpdated(Date lastUpdated)`
  Set the last time this JobExecution was updated.
  `void`
  `setStartTime(Date startTime)`
  `void`
  `setStatus(BatchStatus status)`
  Set the value of the status field.
  `String`
  `toString()`
  `void`
  `upgradeStatus(BatchStatus status)`
  Upgrade the status field if the provided value is greater than the existing one.

  ### Methods inherited from class org.springframework.batch.core.Entity

  `equals, getId, getVersion, hashCode, incrementVersion, setId, setVersion`

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

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

- ## Constructor Details

  - ### JobExecution

    public JobExecution(JobExecution original)

  - ### JobExecution

    public JobExecution(JobInstance job, Long id, @Nullable JobParameters jobParameters)
    Because a JobExecution isn't valid unless the job is set, this constructor is the only valid one from a modeling point of view.
    Parameters:
      `job` - the job of which this execution is a part
      `id` - `Long` that represents the id for the JobExecution.
      `jobParameters` - `JobParameters` instance for this JobExecution.

  - ### JobExecution

    public JobExecution(JobInstance job, JobParameters jobParameters)
    Constructor for transient (unsaved) instances.
    Parameters:
      `job` - the enclosing `JobInstance`
      `jobParameters` - `JobParameters` instance for this JobExecution.

  - ### JobExecution

    public JobExecution(Long id, JobParameters jobParameters)

  - ### JobExecution

    public JobExecution(Long id)

- ## Method Details

  - ### getJobParameters

    public JobParameters getJobParameters()

  - ### getEndTime

    public Date getEndTime()

  - ### setJobInstance

    public void setJobInstance(JobInstance jobInstance)

  - ### setEndTime

    public void setEndTime(Date endTime)

  - ### getStartTime

    public Date getStartTime()

  - ### setStartTime

    public void setStartTime(Date startTime)

  - ### getStatus

    public BatchStatus getStatus()

  - ### setStatus

    public void setStatus(BatchStatus status)
    Set the value of the status field.
    Parameters:
      `status` - the status to set

  - ### upgradeStatus

    public void upgradeStatus(BatchStatus status)
    Upgrade the status field if the provided value is greater than the existing one. Clients using this method to set the status can be sure that they don't overwrite a failed status with an successful one.
    Parameters:
      `status` - the new status value

  - ### getJobId

    public Long getJobId()
    Convenience getter for for the id of the enclosing job. Useful for DAO implementations.
    Returns:
      the id of the enclosing job

  - ### setExitStatus

    public void setExitStatus(ExitStatus exitStatus)
    Parameters:
      `exitStatus` - `ExitStatus` instance to be used for job execution.

  - ### getExitStatus

    public ExitStatus getExitStatus()
    Returns:
      the exitCode

  - ### getJobInstance

    public JobInstance getJobInstance()
    Returns:
      the Job that is executing.

  - ### getStepExecutions

    public Collection<StepExecution> getStepExecutions()
    Accessor for the step executions.
    Returns:
      the step executions that were registered

  - ### createStepExecution

    public StepExecution createStepExecution(String stepName)
    Register a step execution with the current job execution.
    Parameters:
      `stepName` - the name of the step the new execution is associated with
    Returns:
      `StepExecution` an empty `StepExecution` associated with this `JobExecution`.

  - ### isRunning

    public boolean isRunning()
    Test if this `JobExecution` indicates that it is running. It should be noted that this does not necessarily mean that it has been persisted as such yet.
    Returns:
      true if the end time is null and the start time is not null

  - ### isStopping

    public boolean isStopping()
    Test if this `JobExecution` indicates that it has been signalled to stop.
    Returns:
      true if the status is `BatchStatus.STOPPING`

  - ### setExecutionContext

    public void setExecutionContext(ExecutionContext executionContext)
    Sets the `ExecutionContext` for this execution
    Parameters:
      `executionContext` - the context

  - ### getExecutionContext

    public ExecutionContext getExecutionContext()
    Returns the `ExecutionContext` for this execution. The content is expected to be persisted after each step completion (successful or not).
    Returns:
      the context

  - ### getCreateTime

    public Date getCreateTime()
    Returns:
      the time when this execution was created.

  - ### setCreateTime

    public void setCreateTime(Date createTime)
    Parameters:
      `createTime` - creation time of this execution.

  - ### getLastUpdated

    public Date getLastUpdated()
    Get the date representing the last time this JobExecution was updated in the JobRepository.
    Returns:
      Date representing the last time this JobExecution was updated.

  - ### setLastUpdated

    public void setLastUpdated(Date lastUpdated)
    Set the last time this JobExecution was updated.
    Parameters:
      `lastUpdated` - `Date` instance to mark job execution's lastUpdated attribute.

  - ### getFailureExceptions

    public List<Throwable> getFailureExceptions()

  - ### addFailureException

    public void addFailureException(Throwable t)
    Add the provided throwable to the failure exception list.
    Parameters:
      `t` - `Throwable` instance to be added failure exception list.

  - ### getAllFailureExceptions

    public List<Throwable> getAllFailureExceptions()
    Return all failure causing exceptions for this JobExecution, including step executions.
    Returns:
      List<Throwable> containing all exceptions causing failure for this JobExecution.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Entity`

  - ### addStepExecutions

    public void addStepExecutions(List<StepExecution> stepExecutions)
    Add some step executions. For internal use only.
    Parameters:
      `stepExecutions` - step executions to add to the current list