Class JobExecution
java.lang.Object
org.springframework.batch.core.Entity
org.springframework.batch.core.job.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, JobInstance jobInstance, JobParameters jobParameters) Create a newJobExecutioninstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the provided throwable to the failure exception list.voidaddStepExecution(StepExecution stepExecution) Add a step execution.voidaddStepExecutions(List<StepExecution> stepExecutions) Add some step executions.Return all failure causing exceptions for thisJobExecution, including step executions.@Nullable LocalDateTimeReturns theExecutionContextfor this execution.Retrieve a list of exceptions.longConvenience getter for theidof the enclosing job instance.@Nullable LocalDateTimeGet the date representing the last time thisJobExecutionwas updated in theJobRepository.@Nullable LocalDateTimeAccessor 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 Entity
equals, getId, getVersion, hashCode, incrementVersion, setVersion
-
Constructor Details
-
JobExecution
Create a newJobExecutioninstance. Because a JobExecution is not valid unless the job instance is set, this constructor is the only valid one from a modeling point of view.- Parameters:
id- of theJobExecution.jobInstance- The job instance of which this execution is a part.jobParameters- AJobParametersinstance for thisJobExecution.
-
-
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.
-
getJobInstanceId
public long getJobInstanceId()Convenience getter for theidof the enclosing job instance. Useful for DAO implementations.- Returns:
- the
idof the enclosing job instance.
-
setExitStatus
- Parameters:
exitStatus- TheExitStatusinstance to be used for job execution.
-
getExitStatus
- Returns:
- the
exitStatus.
-
getJobInstance
- Returns:
- the Job instance that is executing.
-
getStepExecutions
Accessor for the step executions.- Returns:
- the step executions that were registered.
-
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.
-
addStepExecution
Add a step execution.- Parameters:
stepExecution- ThestepExecutionexecution to be added.
-
addStepExecutions
Add some step executions.- Parameters:
stepExecutions- The step executions to add to the current list.
-
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
-
addFailureException
-
getAllFailureExceptions
-
toString
-