Interface JobRepository

All Known Implementing Classes:

public interface JobRepository

Repository for storing batch JobExecution and StepExecutions. Before using any methods, a JobExecution must first be obtained using the createJobExecution method. Once a JobExecution is obtained, they can be updated.

Lucas Ward

Method Summary
 JobExecution createJobExecution(Job job, JobParameters jobParameters)
          Find or create a JobExecution for a given Job and JobParameters.
 StepExecution getLastStepExecution(JobInstance jobInstance, Step step)
 int getStepExecutionCount(JobInstance jobInstance, Step step)
 void saveOrUpdate(JobExecution jobExecution)
          Save or Update a JobExecution.
 void saveOrUpdate(StepExecution stepExecution)
          Save or update a StepExecution.
 void saveOrUpdateExecutionContext(StepExecution stepExecution)
          Save the ExecutionContext of the given StepExecution.

Method Detail


JobExecution createJobExecution(Job job,
                                JobParameters jobParameters)
                                throws JobExecutionAlreadyRunningException,
Find or create a JobExecution for a given Job and JobParameters. If the Job was already executed with these JobParameters, its persisted values (including ID) will be returned in a new JobInstance, associated with the JobExecution. If no previous instance is found, the execution will be associated with a new JobInstance

jobParameters - the runtime parameters for the job
job - the job the execution should be associated with.
a valid job JobExecution for the arguments provided
JobExecutionAlreadyRunningException - 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.


void saveOrUpdate(JobExecution jobExecution)
Save or Update a JobExecution. If no ID is found a new instance will be saved. If an ID does exist it will be updated. The ID should only be assigned to a JobExecution by calling this method - it should be left blank on the first call, and assigned by the JobRepository. Preconditions: JobExecution must contain a valid JobInstance.

jobExecution -


void saveOrUpdate(StepExecution stepExecution)
Save or update a StepExecution. If no ID is found a new instance will be created (and saved). If an ID does exist it will be updated. It is not advisable that an ID be assigned before calling this method. Instead, it should be left blank, to be assigned by a JobRepository. The ExecutionContext of the StepExecution is not saved: see saveOrUpdateExecutionContext(StepExecution). Preconditions: StepExecution must have a valid Step.

stepExecution -


void saveOrUpdateExecutionContext(StepExecution stepExecution)
Save the ExecutionContext of the given StepExecution. Implementations are allowed to ensure that the StepExecution is already saved by calling saveOrUpdate(StepExecution) before saving the ExecutionContext.

stepExecution - the StepExecution containing the ExecutionContext to be saved.


StepExecution getLastStepExecution(JobInstance jobInstance,
                                   Step step)
the last execution of step for the given job instance.


int getStepExecutionCount(JobInstance jobInstance,
                          Step step)
the execution count of the step within the given job instance.

Copyright © 2008 SpringSource. All Rights Reserved.