Package org.springframework.batch.core
Class JobExecution
java.lang.Object
org.springframework.batch.core.Entity
org.springframework.batch.core.JobExecution
- All Implemented Interfaces:
Serializable
Batch domain object representing the execution of a job.
- Author:
- Lucas Ward, Michael Minella, Mahmoud Ben Hassine, Dimitrios Liapis, Taeik Lim
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJobExecution(Long id) Constructor that accepts the job executionid.JobExecution(Long id, JobParameters jobParameters) Constructor that accepts the job executionidandJobParameters.JobExecution(JobExecution original) Constructor that sets the state of the instance to theJobExecutionparameter.JobExecution(JobInstance job, Long id, JobParameters jobParameters) Because a JobExecution is not 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 TypeMethodDescriptionvoidAdd the provided throwable to the failure exception list.voidaddStepExecutions(List<StepExecution> stepExecutions) Add some step executions.createStepExecution(String stepName) Register a step execution with the current job execution.Return all failure causing exceptions for thisJobExecution, including step executions.Returns theExecutionContextfor this execution.Retrieve a list of exceptions.getJobId()Convenience getter for theidof the enclosing job.Get the date representing the last time thisJobExecutionwas updated in theJobRepository.Accessor for the step executions.booleanTest if thisJobExecutionindicates that it is running.booleanTest if thisJobExecutionindicates that it has been signalled to stop.voidsetCreateTime(LocalDateTime createTime) voidsetEndTime(LocalDateTime endTime) Set the end time.voidsetExecutionContext(ExecutionContext executionContext) Sets theExecutionContextfor this execution.voidsetExitStatus(ExitStatus exitStatus) voidsetJobInstance(JobInstance jobInstance) Set theJobInstanceused by theJobExecution.voidsetLastUpdated(LocalDateTime lastUpdated) Set the last time thisJobExecutionwas updated.voidsetStartTime(LocalDateTime startTime) Set the start time.voidsetStatus(BatchStatus status) Set the value of thestatusfield.toString()Creates a string representation of theEntity, including theid,version, and class name.voidupgradeStatus(BatchStatus status) Upgrade thestatusfield 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
-
Constructor Details
-
JobExecution
Constructor that sets the state of the instance to theJobExecutionparameter.- Parameters:
original- TheJobExecutionto be copied.
-
JobExecution
Because a JobExecution is not 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- ALongthat represents theidfor theJobExecution.jobParameters- AJobParametersinstance for thisJobExecution.
-
JobExecution
Constructor for transient (unsaved) instances.- Parameters:
job- The enclosingJobInstance.jobParameters- TheJobParametersinstance for thisJobExecution.
-
JobExecution
Constructor that accepts the job executionidandJobParameters.- Parameters:
id- The job executionid.jobParameters- TheJobParametersfor theJobExecution.
-
JobExecution
Constructor that accepts the job executionid.- Parameters:
id- The job executionid.
-
-
Method Details
-
getJobParameters
- Returns:
- The current
JobParameters.
-
getEndTime
- Returns:
- The current end time.
-
setJobInstance
Set theJobInstanceused by theJobExecution.- Parameters:
jobInstance- TheJobInstanceused by theJobExecution.
-
setEndTime
Set the end time.- Parameters:
endTime- TheLocalDateTimeto be used for the end time.
-
getStartTime
- Returns:
- The current start time.
-
setStartTime
Set the start time.- Parameters:
startTime- TheLocalDateTimeto be used for the start time.
-
getStatus
- Returns:
- The current
BatchStatus.
-
setStatus
Set the value of thestatusfield.- Parameters:
status- The status to set.
-
upgradeStatus
Upgrade thestatusfield if the provided value is greater than the existing one. Clients using this method to set the status can be sure to not overwrite a failed status with a successful one.- Parameters:
status- The new status value.
-
getJobId
Convenience getter for theidof the enclosing job. Useful for DAO implementations.- Returns:
- the @{code id} of the enclosing job.
-
setExitStatus
- Parameters:
exitStatus- TheExitStatusinstance to be used for job execution.
-
getExitStatus
- Returns:
- the
exitStatus.
-
getJobInstance
- Returns:
- the Job that is executing.
-
getStepExecutions
Accessor for the step executions.- Returns:
- the step executions that were registered.
-
createStepExecution
Register a step execution with the current job execution.- Parameters:
stepName- the name of the step the new execution is associated with.- Returns:
- an empty
StepExecutionassociated with thisJobExecution.
-
isRunning
public boolean isRunning()Test if thisJobExecutionindicates that it is running. Note that this does not necessarily mean that it has been persisted.- Returns:
trueif the status is one of the running statuses.- See Also:
-
isStopping
public boolean isStopping()Test if thisJobExecutionindicates that it has been signalled to stop.- Returns:
trueif the status isBatchStatus.STOPPING.
-
setExecutionContext
Sets theExecutionContextfor this execution.- Parameters:
executionContext- The context.
-
getExecutionContext
Returns theExecutionContextfor this execution. The content is expected to be persisted after each step completion (successful or not).- Returns:
- The
ExecutionContext.
-
getCreateTime
- Returns:
- the time when this execution was created.
-
setCreateTime
- Parameters:
createTime- The creation time of this execution.
-
getLastUpdated
Get the date representing the last time thisJobExecutionwas updated in theJobRepository.- Returns:
- a
LocalDateTimeobject representing the last time thisJobExecutionwas updated.
-
setLastUpdated
Set the last time thisJobExecutionwas updated.- Parameters:
lastUpdated- TheLocalDateTimeinstance to which to set the job execution'slastUpdatedattribute.
-
getFailureExceptions
Retrieve a list of exceptions. -
addFailureException
Add the provided throwable to the failure exception list.- Parameters:
t- AThrowableinstance to be added failure exception list.
-
getAllFailureExceptions
Return all failure causing exceptions for thisJobExecution, including step executions.- Returns:
- a
List<Throwable>containing all exceptions causing failure for thisJobExecution.
-
toString
Description copied from class:EntityCreates a string representation of theEntity, including theid,version, and class name. -
addStepExecutions
Add some step executions. For internal use only.- Parameters:
stepExecutions- The step executions to add to the current list.
-