diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java index 986015051..af8e01484 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java @@ -81,18 +81,31 @@ public interface JobRepository { public void saveOrUpdate(JobExecution jobExecution); /** - * Save or Update a StepExecution. If no ID is found a new instance will be - * created. (saved). If an ID does exist it will be updated. It is not - * advisable that an ID be assigned to a JobExecution before calling this - * method. Instead, it should be left blank, to be assigned by a - * JobRepository. + * Save or update a {@link 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 + * {@link JobRepository}. The {@link ExecutionContext} of the + * {@link StepExecution} is not saved: see + * {@link #saveExecutionContext(StepExecution)}. * - * Preconditions: StepExecution must have a valid StepId. + * Preconditions: {@link StepExecution} must have a valid {@link Step}. * * @param jobInstance */ public void saveOrUpdate(StepExecution stepExecution); + /** + * Save the {@link ExecutionContext} of the given {@link StepExecution}. + * Implementations are allowed to ensure that the {@link StepExecution} is + * already saved by calling {@link #saveOrUpdate(StepExecution)} before + * saving the {@link ExecutionContext}. + * + * @param stepExecution the {@link StepExecution} containing the + * {@link ExecutionContext} to be saved. + */ + void saveOrUpdateExecutionContext(StepExecution stepExecution); + /** * @return the last execution of step for the given job instance. */ @@ -103,5 +116,4 @@ public interface JobRepository { */ public int getStepExecutionCount(JobInstance jobInstance, Step step); - } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/AbstractJob.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/AbstractJob.java index 21ef40067..6de446cb5 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/AbstractJob.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/AbstractJob.java @@ -20,9 +20,7 @@ import java.util.ArrayList; import java.util.List; import org.springframework.batch.core.domain.Job; -import org.springframework.batch.core.domain.JobExecution; import org.springframework.batch.core.domain.Step; -import org.springframework.batch.io.exception.BatchCriticalException; import org.springframework.beans.factory.BeanNameAware; import org.springframework.util.ClassUtils; diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java index 9db70a515..27ad8ab33 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java @@ -108,8 +108,8 @@ public class SimpleJobRepository implements JobRepository { *