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
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJobExecution(Long id) Constructor that accepts the job execution ID.JobExecution(Long id, JobParameters jobParameters) Constructor that accepts the job execution ID andJobParameters.JobExecution(JobExecution original) Constructor that sets the state of the instance to theJobExecutionparameter.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 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 this JobExecution, including step executions.Returns theExecutionContextfor this execution.Retrieve a list of exceptions.getJobId()Convenience getter for for the id of the enclosing job.Get the date representing the last time this JobExecution was updated in the JobRepository.Accessor for the step executions.booleanTest if thisJobExecutionindicates that it is running.booleanTest if thisJobExecutionindicates that it has been signalled to stop.voidsetCreateTime(Date createTime) voidsetEndTime(Date endTime) Set the end time.voidsetExecutionContext(ExecutionContext executionContext) Sets theExecutionContextfor this executionvoidsetExitStatus(ExitStatus exitStatus) voidsetJobInstance(JobInstance jobInstance) Set theJobInstanceused by theJobExecution.voidsetLastUpdated(Date lastUpdated) Set the last time this JobExecution was updated.voidsetStartTime(Date startTime) Set the start time.voidsetStatus(BatchStatus status) Set the value of the status field.toString()voidupgradeStatus(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
-
Constructor Details
-
JobExecution
Constructor that sets the state of the instance to theJobExecutionparameter.- Parameters:
original- TheJobExecutionto be copied.
-
JobExecution
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 partid-Longthat represents the id for the JobExecution.jobParameters-JobParametersinstance for this JobExecution.
-
JobExecution
Constructor for transient (unsaved) instances.- Parameters:
job- The enclosingJobInstance.jobParameters- TheJobParametersinstance for this JobExecution.
-
JobExecution
Constructor that accepts the job execution ID andJobParameters.- Parameters:
id- The job execution ID.jobParameters- TheJobParametersfor theJobExecution.
-
JobExecution
Constructor that accepts the job execution ID.- Parameters:
id- The job execution ID.
-
-
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- TheDateto be used for the end time.
-
getStartTime
- Returns:
- The current start time.
-
setStartTime
Set the start time.- Parameters:
startTime- TheDateto be used for the start time.
-
getStatus
- Returns:
- The current
BatchStatus.
-
setStatus
Set the value of the status field.- Parameters:
status- the status to set
-
upgradeStatus
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
Convenience getter for for the id of the enclosing job. Useful for DAO implementations.- Returns:
- the id of the enclosing job
-
setExitStatus
- Parameters:
exitStatus-ExitStatusinstance to be used for job execution.
-
getExitStatus
- Returns:
- the exitCode
-
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:
StepExecutionan emptyStepExecutionassociated with thisJobExecution.
-
isRunning
public boolean isRunning()Test if thisJobExecutionindicates 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 thisJobExecutionindicates that it has been signalled to stop.- Returns:
- true if the status is
BatchStatus.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 context
-
getCreateTime
- Returns:
- the time when this execution was created.
-
setCreateTime
- Parameters:
createTime- creation time of this execution.
-
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
Set the last time this JobExecution was updated.- Parameters:
lastUpdated-Dateinstance to mark job execution's lastUpdated attribute.
-
getFailureExceptions
Retrieve a list of exceptions. -
addFailureException
Add the provided throwable to the failure exception list.- Parameters:
t-Throwableinstance to be added failure exception list.
-
getAllFailureExceptions
Return all failure causing exceptions for this JobExecution, including step executions.- Returns:
- List<Throwable> containing all exceptions causing failure for this JobExecution.
-
toString
-
addStepExecutions
Add some step executions. For internal use only.- Parameters:
stepExecutions- step executions to add to the current list
-