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
ConstructorDescriptionJobExecution
(Long id) Constructor that accepts the job executionid
.JobExecution
(Long id, JobParameters jobParameters) Constructor that accepts the job executionid
andJobParameters
.JobExecution
(JobExecution original) Constructor that sets the state of the instance to theJobExecution
parameter.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 TypeMethodDescriptionvoid
Add the provided throwable to the failure exception list.void
addStepExecutions
(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 theExecutionContext
for this execution.Retrieve a list of exceptions.getJobId()
Convenience getter for theid
of the enclosing job.Get the date representing the last time thisJobExecution
was updated in theJobRepository
.Accessor for the step executions.boolean
Test if thisJobExecution
indicates that it is running.boolean
Test if thisJobExecution
indicates that it has been signalled to stop.void
setCreateTime
(LocalDateTime createTime) void
setEndTime
(LocalDateTime endTime) Set the end time.void
setExecutionContext
(ExecutionContext executionContext) Sets theExecutionContext
for this execution.void
setExitStatus
(ExitStatus exitStatus) void
setJobInstance
(JobInstance jobInstance) Set theJobInstance
used by theJobExecution
.void
setLastUpdated
(LocalDateTime lastUpdated) Set the last time thisJobExecution
was updated.void
setStartTime
(LocalDateTime startTime) Set the start time.void
setStatus
(BatchStatus status) Set the value of thestatus
field.toString()
Creates a string representation of theEntity
, including theid
,version
, and class name.void
upgradeStatus
(BatchStatus status) Upgrade thestatus
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 theJobExecution
parameter.- Parameters:
original
- TheJobExecution
to 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
- ALong
that represents theid
for theJobExecution
.jobParameters
- AJobParameters
instance for thisJobExecution
.
-
JobExecution
Constructor for transient (unsaved) instances.- Parameters:
job
- The enclosingJobInstance
.jobParameters
- TheJobParameters
instance for thisJobExecution
.
-
JobExecution
Constructor that accepts the job executionid
andJobParameters
.- Parameters:
id
- The job executionid
.jobParameters
- TheJobParameters
for 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 theJobInstance
used by theJobExecution
.- Parameters:
jobInstance
- TheJobInstance
used by theJobExecution
.
-
setEndTime
Set the end time.- Parameters:
endTime
- TheLocalDateTime
to be used for the end time.
-
getStartTime
- Returns:
- The current start time.
-
setStartTime
Set the start time.- Parameters:
startTime
- TheLocalDateTime
to be used for the start time.
-
getStatus
- Returns:
- The current
BatchStatus
.
-
setStatus
Set the value of thestatus
field.- Parameters:
status
- The status to set.
-
upgradeStatus
Upgrade thestatus
field 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 theid
of the enclosing job. Useful for DAO implementations.- Returns:
- the @{code id} of the enclosing job.
-
setExitStatus
- Parameters:
exitStatus
- TheExitStatus
instance 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
StepExecution
associated with thisJobExecution
.
-
isRunning
public boolean isRunning()Test if thisJobExecution
indicates that it is running. Note that this does not necessarily mean that it has been persisted.- Returns:
true
if the status is one of the running statuses.- See Also:
-
isStopping
public boolean isStopping()Test if thisJobExecution
indicates that it has been signalled to stop.- Returns:
true
if the status isBatchStatus.STOPPING
.
-
setExecutionContext
Sets theExecutionContext
for this execution.- Parameters:
executionContext
- The context.
-
getExecutionContext
Returns theExecutionContext
for 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 thisJobExecution
was updated in theJobRepository
.- Returns:
- a
LocalDateTime
object representing the last time thisJobExecution
was updated.
-
setLastUpdated
Set the last time thisJobExecution
was updated.- Parameters:
lastUpdated
- TheLocalDateTime
instance to which to set the job execution'slastUpdated
attribute.
-
getFailureExceptions
Retrieve a list of exceptions. -
addFailureException
Add the provided throwable to the failure exception list.- Parameters:
t
- AThrowable
instance 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:Entity
Creates 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.
-