public class SimpleJobRepository extends java.lang.Object implements JobRepository
Implementation of JobRepository that stores JobInstances,
JobExecutions, and StepExecutions using the injected DAOs.
JobRepository,
JobInstanceDao,
JobExecutionDao,
StepExecutionDao| Constructor and Description |
|---|
SimpleJobRepository(JobInstanceDao jobInstanceDao,
JobExecutionDao jobExecutionDao,
StepExecutionDao stepExecutionDao,
ExecutionContextDao ecDao) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(StepExecution stepExecution)
Save the
StepExecution and its ExecutionContext. |
void |
addAll(java.util.Collection<StepExecution> stepExecutions)
Save a collection of
StepExecutions and each ExecutionContext. |
JobExecution |
createJobExecution(JobInstance jobInstance,
JobParameters jobParameters,
java.lang.String jobConfigurationLocation)
Create a new
JobExecution based upon the JobInstance it's associated
with, the JobParameters used to execute it with and the location of the configuration
file that defines the job. |
JobExecution |
createJobExecution(java.lang.String jobName,
JobParameters jobParameters)
|
JobInstance |
createJobInstance(java.lang.String jobName,
JobParameters jobParameters)
Create a new
JobInstance with the name and job parameters provided. |
JobExecution |
getLastJobExecution(java.lang.String jobName,
JobParameters jobParameters) |
StepExecution |
getLastStepExecution(JobInstance jobInstance,
java.lang.String stepName) |
int |
getStepExecutionCount(JobInstance jobInstance,
java.lang.String stepName) |
boolean |
isJobInstanceExists(java.lang.String jobName,
JobParameters jobParameters)
Check if an instance of this job already exists with the parameters
provided.
|
void |
update(JobExecution jobExecution)
Update the
JobExecution (but not its ExecutionContext). |
void |
update(StepExecution stepExecution)
Update the
StepExecution (but not its ExecutionContext). |
void |
updateExecutionContext(JobExecution jobExecution)
Persist the updated
ExecutionContext of the given
JobExecution. |
void |
updateExecutionContext(StepExecution stepExecution)
Persist the updated
ExecutionContexts of the given
StepExecution. |
public SimpleJobRepository(JobInstanceDao jobInstanceDao, JobExecutionDao jobExecutionDao, StepExecutionDao stepExecutionDao, ExecutionContextDao ecDao)
public boolean isJobInstanceExists(java.lang.String jobName,
JobParameters jobParameters)
JobRepositoryisJobInstanceExists in interface JobRepositoryjobName - the name of the jobjobParameters - the parameters to matchJobInstance already exists for this job name
and job parameterspublic JobExecution createJobExecution(java.lang.String jobName, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException
JobRepository
Create a JobExecution for a given Job and
JobParameters. If matching JobInstance already exists,
the job must be restartable and it's last JobExecution must *not* be
completed. If matching JobInstance does not exist yet it will be
created.
If this method is run in a transaction (as it normally would be) with
isolation level at Isolation.REPEATABLE_READ or better, then this
method should block if another transaction is already executing it (for
the same JobParameters and job name). The first transaction to
complete in this scenario obtains a valid JobExecution, and
others throw JobExecutionAlreadyRunningException (or timeout).
There are no such guarantees if the JobInstanceDao and
JobExecutionDao do not respect the transaction isolation levels
(e.g. if using a non-relational data-store, or if the platform does not
support the higher isolation levels).
createJobExecution in interface JobRepositoryjobName - the name of the job that is to be executedjobParameters - the runtime parameters for the jobJobExecution for the arguments providedJobExecutionAlreadyRunningException - if there is a
JobExecution already running for the job instance with the
provided job and parameters.JobRestartException - if one or more existing JobInstances
is found with the same parameters and Job.isRestartable() is
false.JobInstanceAlreadyCompleteException - if a JobInstance is
found and was already completed successfully.public void update(JobExecution jobExecution)
JobRepositoryJobExecution (but not its ExecutionContext).
Preconditions: JobExecution must contain a valid
JobInstance and be saved (have an id assigned).update in interface JobRepositoryjobExecution - JobExecution instance to be updated in the repo.public void add(StepExecution stepExecution)
JobRepositoryStepExecution and its ExecutionContext. ID will
be assigned - it is not permitted that an ID be assigned before calling
this method. Instead, it should be left blank, to be assigned by a
JobRepository.
Preconditions: StepExecution must have a valid Step.add in interface JobRepositorystepExecution - StepExecution instance to be added to the repo.public void addAll(java.util.Collection<StepExecution> stepExecutions)
JobRepositoryStepExecutions and each ExecutionContext. The
StepExecution ID will be assigned - it is not permitted that an ID be assigned before calling
this method. Instead, it should be left blank, to be assigned by JobRepository.
Preconditions: StepExecution must have a valid Step.addAll in interface JobRepositorystepExecutions - collection of StepExecution instances to be added to the repo.public void update(StepExecution stepExecution)
JobRepositoryStepExecution (but not its ExecutionContext).
Preconditions: StepExecution must be saved (have an id assigned).update in interface JobRepositorystepExecution - StepExecution instance to be updated in the repo.public void updateExecutionContext(StepExecution stepExecution)
JobRepositoryExecutionContexts of the given
StepExecution.updateExecutionContext in interface JobRepositorystepExecution - StepExecution instance to be used to update the context.public void updateExecutionContext(JobExecution jobExecution)
JobRepositoryExecutionContext of the given
JobExecution.updateExecutionContext in interface JobRepositoryjobExecution - JobExecution instance to be used to update the context.@Nullable public StepExecution getLastStepExecution(JobInstance jobInstance, java.lang.String stepName)
getLastStepExecution in interface JobRepositoryjobInstance - JobInstance instance containing the step executions.stepName - the name of the step execution that might have run.public int getStepExecutionCount(JobInstance jobInstance, java.lang.String stepName)
getStepExecutionCount in interface JobRepositoryjobInstance - JobInstance instance containing the step executions.stepName - the name of the step execution that might have run.@Nullable public JobExecution getLastJobExecution(java.lang.String jobName, JobParameters jobParameters)
getLastJobExecution in interface JobRepositoryjobName - the name of the job that might have runjobParameters - parameters identifying the JobInstancepublic JobInstance createJobInstance(java.lang.String jobName, JobParameters jobParameters)
JobRepositoryJobInstance with the name and job parameters provided.createJobInstance in interface JobRepositoryjobName - logical name of the jobjobParameters - parameters used to execute the jobJobInstancepublic JobExecution createJobExecution(JobInstance jobInstance, JobParameters jobParameters, java.lang.String jobConfigurationLocation)
JobRepositoryJobExecution based upon the JobInstance it's associated
with, the JobParameters used to execute it with and the location of the configuration
file that defines the job.createJobExecution in interface JobRepositoryjobInstance - JobInstance instance to initialize the new JobExecution.jobParameters - JobParameters instance to initialize the new JobExecution.jobConfigurationLocation - String instance to initialize the new JobExecution.JobExecution.