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 theJobExecution
parameter.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 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 this JobExecution, including step executions.Returns theExecutionContext
for 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.boolean
Test if thisJobExecution
indicates that it is running.boolean
Test if thisJobExecution
indicates that it has been signalled to stop.void
setCreateTime
(Date createTime) void
setEndTime
(Date endTime) Set the end time.void
setExecutionContext
(ExecutionContext executionContext) Sets theExecutionContext
for this executionvoid
setExitStatus
(ExitStatus exitStatus) void
setJobInstance
(JobInstance jobInstance) Set theJobInstance
used by theJobExecution
.void
setLastUpdated
(Date lastUpdated) Set the last time this JobExecution was updated.void
setStartTime
(Date startTime) Set the start time.void
setStatus
(BatchStatus status) Set the value of the status field.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
-
Constructor Details
-
JobExecution
Constructor that sets the state of the instance to theJobExecution
parameter.- Parameters:
original
- TheJobExecution
to 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
-Long
that represents the id for the JobExecution.jobParameters
-JobParameters
instance for this JobExecution.
-
JobExecution
Constructor for transient (unsaved) instances.- Parameters:
job
- The enclosingJobInstance
.jobParameters
- TheJobParameters
instance for this JobExecution.
-
JobExecution
Constructor that accepts the job execution ID andJobParameters
.- Parameters:
id
- The job execution ID.jobParameters
- TheJobParameters
for 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 theJobInstance
used by theJobExecution
.- Parameters:
jobInstance
- TheJobInstance
used by theJobExecution
.
-
setEndTime
Set the end time.- Parameters:
endTime
- TheDate
to be used for the end time.
-
getStartTime
- Returns:
- The current start time.
-
setStartTime
Set the start time.- Parameters:
startTime
- TheDate
to 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
-ExitStatus
instance 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:
StepExecution
an emptyStepExecution
associated with thisJobExecution
.
-
isRunning
public boolean isRunning()Test if thisJobExecution
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 thisJobExecution
indicates that it has been signalled to stop.- Returns:
- true if the status is
BatchStatus.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 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
-Date
instance 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
-Throwable
instance 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
-