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 628598724..184eada50 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 @@ -66,17 +66,6 @@ public interface JobRepository { public JobExecution createJobExecution(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException; - /** - * Update a Job. - * - * Preconditions: Job must contain a valid ID. This can be ensured by first - * obtaining a job from findOrCreateJob. - * - * @param job - * @see JobInstance - */ - public void update(JobInstance jobInstance); - /** * Save or Update a {@link 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 @@ -91,18 +80,6 @@ public interface JobRepository { */ public void saveOrUpdate(JobExecution jobExecution); - /** - * Update a step. - * - * Preconditions: {@link StepInstance} must contain a valid ID. This can be - * ensured by first obtaining a {@link JobInstance} from findOrCreateJob, - * and accessing it's step list. - * - * @param step - * @see StepInstance - */ - public void update(StepInstance stepInstance); - /** * 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 diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/SimpleJob.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/SimpleJob.java index ebcf5e0cf..e033ddf09 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/SimpleJob.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/simple/SimpleJob.java @@ -123,9 +123,7 @@ public class SimpleJob extends JobSupport { } private void updateStatus(JobExecution jobExecution, BatchStatus status) { - JobInstance jobIntance = jobExecution.getJobInstance(); jobExecution.setStatus(status); - jobRepository.update(jobIntance); jobRepository.saveOrUpdate(jobExecution); } 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 6ba02ba0a..b938eed6a 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 @@ -187,7 +187,7 @@ public class SimpleJobRepository implements JobRepository { if (lastExecution.getStartTime().getTime() < execution.getStartTime().getTime()) { lastExecution = execution; } - + if (execution.isRunning()) { throw new JobExecutionAlreadyRunningException("A job execution for this job is already running: " + jobInstance); @@ -243,18 +243,6 @@ public class SimpleJobRepository implements JobRepository { } } - /** - * Update an existing job. A job must have been obtained from the - * findOrCreateJob method, otherwise it is likely that the id is incorrect - * or non-existant. - * - * @param job to be updated. - * @throws IllegalArgumentException if Job or it's Id is null. - */ - public void update(JobInstance job) { - //TODO no-op to be removed - } - /** * Save or Update the given StepExecution. If it's id is null, it will be * saved and an id will be set, otherwise it will be updated. It should be @@ -282,23 +270,6 @@ public class SimpleJobRepository implements JobRepository { } /** - * Update the given step. - * - * @param StepInstance to be updated. - * @throws IllegalArgumentException if step or it's id is null. - */ - public void update(StepInstance step) { - - Assert.notNull(step, "Step cannot be null."); - Assert.notNull(step.getId(), "Step cannot be updated if it's ID is null. It must be obtained" - + "from SimpleJobRepository.findOrCreateJob to be considered valid."); - - //TODO no-op to be removed - //stepInstanceDao.updateStepInstance(step); - - } - - /* * Convenience method for creating a new job. A new job is created by * calling {@link JobDao#createJob(JobRuntimeInformation)} and then it's * list of StepConfigurations is passed to the createSteps method. @@ -311,7 +282,7 @@ public class SimpleJobRepository implements JobRepository { return jobInstance; } - /* + /** * Create steps based on the given Job and list of Steps. */ private List createStepInstances(JobInstance job, List steps) { diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkedStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkedStep.java index cc7c67df0..2cfb33006 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkedStep.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkedStep.java @@ -430,9 +430,7 @@ public class ChunkedStep extends AbstractStep { * @param status the status to set */ private void updateStatus(StepExecution stepExecution, BatchStatus status) { - StepInstance step = stepExecution.getStep(); stepExecution.setStatus(status); - jobRepository.update(step); jobRepository.saveOrUpdate(stepExecution); } } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java index 1db4b69b8..ccf5f7982 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java @@ -528,9 +528,7 @@ public class SimpleStepExecutor implements InitializingBean { * @param status the status to set */ private void updateStatus(StepExecution stepExecution, BatchStatus status) { - StepInstance step = stepExecution.getStep(); stepExecution.setStatus(status); - jobRepository.update(step); jobRepository.saveOrUpdate(stepExecution); } } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java index 27a22ddae..ed4cfab33 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java @@ -356,26 +356,6 @@ public class SimpleJobRepositoryTests extends TestCase { jobRepository.saveOrUpdate(jobExecution); } - public void testUpdateStep() { - - StepInstance step = new StepInstance(null); - - // failure scenario - id not set - try { - jobRepository.update(step); - fail(); - } - catch (Exception ex) { - // expected - } - - // successful update - step = new StepInstance(new Long(0L)); - // stepDao.updateStepInstance(step); - stepDaoControl.replay(); - jobRepository.update(step); - } - public void testUpdateStepExecution() { StepExecution stepExecution = new StepExecution(new StepInstance(new Long(10L)), null, new Long(1)); stepExecution.setId(new Long(11)); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/ChunkedStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/ChunkedStepTests.java index 22f59d191..5b5eac985 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/ChunkedStepTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/ChunkedStepTests.java @@ -178,11 +178,9 @@ public class ChunkedStepTests extends TestCase { // JobExecution jobExecutionContext = new JobExecution(jobInstance); // StepExecution stepExecution = new StepExecution(step, jobExecutionContext); - repository.update(stepInstance); repository.saveOrUpdate(stepExecution); repository.saveOrUpdate(stepExecution); repository.saveOrUpdate(stepExecution); - repository.update(stepInstance); repository.saveOrUpdate(stepExecution); repository.saveOrUpdate(stepExecution); repository.saveOrUpdate(stepExecution); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java index dd5482d19..4740f0fe2 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/dao/JdbcJobRepositoryTests.java @@ -122,9 +122,7 @@ public class JdbcJobRepositoryTests extends AbstractTransactionalDataSourceSprin cacheJobIds(execution); execution.setEndTime(new Timestamp(System.currentTimeMillis())); repository.saveOrUpdate(execution); - JobInstance job = execution.getJobInstance(); execution.setStatus(BatchStatus.FAILED); - repository.update(job); setComplete(); endTransaction();