org.springframework.batch.core.repository
Interface JobRepository

All Known Implementing Classes:
SimpleJobRepository

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.

Author:
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

createJobExecution

JobExecution createJobExecution(Job job,
                                JobParameters jobParameters)
                                throws JobExecutionAlreadyRunningException,
                                       JobRestartException,
                                       JobInstanceAlreadyCompleteException
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

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

saveOrUpdate

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.

Parameters:
jobExecution -

saveOrUpdate

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.

Parameters:
stepExecution -

saveOrUpdateExecutionContext

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.

Parameters:
stepExecution - the StepExecution containing the ExecutionContext to be saved.

getLastStepExecution

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

getStepExecutionCount

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


Copyright © 2008 SpringSource. All Rights Reserved.