diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Job.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Job.java index 6e604ed1c..dd94f8438 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Job.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Job.java @@ -26,7 +26,7 @@ import org.springframework.batch.io.exception.BatchCriticalException; * step. * * @author Dave Syer - * + * */ public interface Job { @@ -38,6 +38,13 @@ public interface Job { boolean isRestartable(); - void run(JobExecution execution) throws BatchCriticalException; + /** + * Run the {@link JobExecution} and update the meta information like status + * and statistics as necessary. + * + * @param execution a {@link JobExecution} + * @throws BatchCriticalException + */ + void execute(JobExecution execution) throws BatchCriticalException; } \ No newline at end of file diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobExecution.java index 3b7c25f4e..784862727 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobExecution.java @@ -43,7 +43,7 @@ public class JobExecution extends Entity { private ExitStatus exitStatus = ExitStatus.UNKNOWN; - // Package private constructor for Hibernate + // Package private constructor for testing JobExecution() { } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobSupport.java index e79e6dcb7..eee92e7a5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/JobSupport.java @@ -133,7 +133,7 @@ public class JobSupport implements BeanNameAware, Job { /* (non-Javadoc) * @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution) */ - public void run(JobExecution execution) throws BatchCriticalException { + public void execute(JobExecution execution) throws BatchCriticalException { throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass."); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java index a555b2489..862d42c67 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Step.java @@ -67,6 +67,6 @@ public interface Step { * @throws BatchCriticalException if there is a problem that needs to be * signalled to the caller */ - void process(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException; + void execute(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException; } \ No newline at end of file diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepSupport.java index a7baba0a5..d8920ff25 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/StepSupport.java @@ -134,9 +134,9 @@ public class StepSupport implements Step, BeanNameAware { * * @throws UnsupportedOperationException always * - * @see org.springframework.batch.core.domain.Step#process(org.springframework.batch.core.domain.StepExecution) + * @see org.springframework.batch.core.domain.Step#execute(org.springframework.batch.core.domain.StepExecution) */ - public void process(StepExecution stepExecution) + public void execute(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException { throw new UnsupportedOperationException( "Cannot process a StepExecution. Use a smarter subclass of StepSupport."); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobSupportTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobSupportTests.java index 07c2b57d4..352fa8131 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobSupportTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/JobSupportTests.java @@ -104,7 +104,7 @@ public class JobSupportTests extends TestCase { public void testRunNotSupported() throws Exception { try { - job.run(null); + job.execute(null); } catch (UnsupportedOperationException e) { // expected String message = e.getMessage(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupportTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupportTests.java index 993253ad2..def1d5d28 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupportTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepSupportTests.java @@ -89,7 +89,7 @@ public class StepSupportTests extends TestCase { public void testUnsuccessfulWrongConfiguration() throws Exception { try { - new StepSupport().process(null); + new StepSupport().execute(null); fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { // expected 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 241672c9b..a3f968330 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 @@ -53,9 +53,9 @@ public class SimpleJob extends JobSupport { * Run the specified job by looping through the steps and delegating to the * {@link Step}. * - * @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution) + * @see org.springframework.batch.core.domain.Job#execute(org.springframework.batch.core.domain.JobExecution) */ - public void run(JobExecution execution) throws BatchCriticalException { + public void execute(JobExecution execution) throws BatchCriticalException { JobInstance jobInstance = execution.getJobInstance(); updateStatus(execution, BatchStatus.STARTING); @@ -78,7 +78,7 @@ public class SimpleJob extends JobSupport { startedCount++; updateStatus(execution, BatchStatus.STARTED); StepExecution stepExecution = execution.createStepExecution(stepInstance); - step.process(stepExecution); + step.execute(stepExecution); status = stepExecution.getExitStatus(); } } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java index c68ad4327..89e4f6d5a 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/launch/SimpleJobLauncher.java @@ -82,7 +82,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { public void run() { try { logger.info("Job: [" + job + "] launched with the following parameters: [" + jobParameters + "]"); - job.run(jobExecution); + job.execute(jobExecution); logger.info("Job: [" + job + "] completed successfully with the following parameters: [" + jobParameters + "]"); } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/AbstractStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/AbstractStep.java index cbaf5c6fa..97468faba 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/AbstractStep.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/AbstractStep.java @@ -111,9 +111,9 @@ public abstract class AbstractStep extends StepSupport { /* (non-Javadoc) * @see org.springframework.batch.core.domain.StepSupport#process(org.springframework.batch.core.domain.StepExecution) */ - public void process(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException { + public void execute(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException { SimpleStepExecutor executor = createStepExecutor(); - executor.process(stepExecution); + executor.execute(stepExecution); } /** diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/RepeatOperationsStep.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/RepeatOperationsStep.java index 743cef001..bdc046cf5 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/RepeatOperationsStep.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/RepeatOperationsStep.java @@ -77,7 +77,7 @@ public class RepeatOperationsStep extends AbstractStep implements RepeatOperatio /* (non-Javadoc) * @see org.springframework.batch.execution.step.simple.AbstractStep#process(org.springframework.batch.core.domain.StepExecution) */ - public void process(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException { + public void execute(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException { assertMandatoryProperties(); SimpleStepExecutor executor = (SimpleStepExecutor) super.createStepExecutor(); if (stepOperations != null) { @@ -86,6 +86,6 @@ public class RepeatOperationsStep extends AbstractStep implements RepeatOperatio if (chunkOperations != null) { executor.setChunkOperations(chunkOperations); } - executor.process(stepExecution); + executor.execute(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 4215746cd..2e0cb2d97 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 @@ -171,9 +171,9 @@ public class SimpleStepExecutor { * @throws StepInterruptedException if the step or a chunk is interrupted * @throws RuntimeException if there is an exception during a chunk * execution - * @see StepExecutor#process(StepExecution) + * @see StepExecutor#execute(StepExecution) */ - public void process(final StepExecution stepExecution) throws BatchCriticalException, + public void execute(final StepExecution stepExecution) throws BatchCriticalException, StepInterruptedException { final StepInstance stepInstance = stepExecution.getStep(); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/simple/SimpleJobTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/simple/SimpleJobTests.java index f2abe69c4..aa013cfe1 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/simple/SimpleJobTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/simple/SimpleJobTests.java @@ -126,7 +126,7 @@ public class SimpleJobTests extends TestCase { public void testRunNormally() throws Exception { stepConfiguration1.setStartLimit(5); stepConfiguration2.setStartLimit(5); - job.run(jobExecution); + job.execute(jobExecution); assertEquals(2, list.size()); checkRepository(BatchStatus.COMPLETED); } @@ -149,7 +149,7 @@ public class SimpleJobTests extends TestCase { return ExitStatus.FINISHED; } }); - job.run(jobExecution); + job.execute(jobExecution); assertEquals(2, list.size()); checkRepository(BatchStatus.COMPLETED, ExitStatus.FINISHED); @@ -169,7 +169,7 @@ public class SimpleJobTests extends TestCase { final StepInterruptedException exception = new StepInterruptedException("Interrupt!"); stepConfiguration1.setProcessException(exception); try { - job.run(jobExecution); + job.execute(jobExecution); } catch (BatchCriticalException e) { assertEquals(exception, e.getCause()); @@ -184,7 +184,7 @@ public class SimpleJobTests extends TestCase { final RuntimeException exception = new RuntimeException("Foo!"); stepConfiguration1.setProcessException(exception); try { - job.run(jobExecution); + job.execute(jobExecution); } catch (RuntimeException e) { assertEquals(exception, e); @@ -198,7 +198,7 @@ public class SimpleJobTests extends TestCase { stepConfiguration1.setStartLimit(0); try { - job.run(jobExecution); + job.execute(jobExecution); fail("Expected BatchCriticalException"); } catch (BatchCriticalException ex) { @@ -211,7 +211,7 @@ public class SimpleJobTests extends TestCase { public void testNoSteps() throws Exception { job.setSteps(new ArrayList()); - job.run(jobExecution); + job.execute(jobExecution); ExitStatus exitStatus = jobExecution.getExitStatus(); assertTrue("Wrong message in execution: " + exitStatus, exitStatus.getExitDescription().indexOf( "No steps configured") >= 0); @@ -221,7 +221,7 @@ public class SimpleJobTests extends TestCase { step1.setStatus(BatchStatus.COMPLETED); step2.setStatus(BatchStatus.COMPLETED); - job.run(jobExecution); + job.execute(jobExecution); ExitStatus exitStatus = jobExecution.getExitStatus(); assertTrue("Wrong message in execution: " + exitStatus, exitStatus.getExitDescription().indexOf( "steps already completed") >= 0); @@ -272,7 +272,7 @@ public class SimpleJobTests extends TestCase { this.runnable = runnable; } - public void process(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException { + public void execute(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException { if (exception instanceof RuntimeException) { throw (RuntimeException)exception; } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java index e0b86c8b8..e0ae3fc81 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobLauncherTests.java @@ -41,7 +41,7 @@ public class SimpleJobLauncherTests extends TestCase { private MockControl repositoryControl = MockControl.createControl(JobRepository.class); private Job job = new JobSupport("foo") { - public void run(JobExecution execution) { + public void execute(JobExecution execution) { execution.setExitStatus(ExitStatus.FINISHED); return; } @@ -89,7 +89,7 @@ public class SimpleJobLauncherTests extends TestCase { public void testRunWithException() throws Exception { job = new JobSupport() { - public void run(JobExecution execution) { + public void execute(JobExecution execution) { execution.setExitStatus(ExitStatus.FAILED); throw new RuntimeException("foo"); } @@ -105,7 +105,7 @@ public class SimpleJobLauncherTests extends TestCase { public void testRunWithError() throws Exception { job = new JobSupport() { - public void run(JobExecution execution) { + public void execute(JobExecution execution) { execution.setExitStatus(ExitStatus.FAILED); throw new Error("foo"); } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java index 7245d4fea..2b0f2fad3 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/launch/SimpleJobTests.java @@ -113,7 +113,7 @@ public class SimpleJobTests extends TestCase { JobExecution jobExecutionContext = new JobExecution(jobInstance); - job.run(jobExecutionContext); + job.execute(jobExecutionContext); assertEquals(BatchStatus.COMPLETED, jobInstance.getStatus()); assertEquals(3, processed.size()); assertTrue(processed.contains("foo")); @@ -153,7 +153,7 @@ public class SimpleJobTests extends TestCase { job.setSteps(Collections.singletonList(step)); JobExecution jobExecution = repository.createJobExecution(job, new JobParameters()); - job.run(jobExecution); + job.execute(jobExecution); assertEquals(BatchStatus.COMPLETED, jobExecution.getJobInstance().getStatus()); assertEquals(0, processed.size()); @@ -178,7 +178,7 @@ public class SimpleJobTests extends TestCase { JobExecution jobExecution = repository.createJobExecution(job, new JobParameters()); try { - job.run(jobExecution); + job.execute(jobExecution); fail("Expected RuntimeException"); } catch (RuntimeException e) { diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/RepeatOperationsStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/RepeatOperationsStepTests.java index f2eddd15c..74cf4d393 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/RepeatOperationsStepTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/RepeatOperationsStepTests.java @@ -80,7 +80,7 @@ public class RepeatOperationsStepTests extends TestCase { new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobParameters()), new Long(12))); try { - configuration.process(stepExecution); + configuration.execute(stepExecution); fail("Expected RuntimeException"); } catch (NullPointerException e) { // expected @@ -118,7 +118,7 @@ public class RepeatOperationsStepTests extends TestCase { StepExecution stepExecution = new StepExecution(new StepInstance( new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobParameters()), new Long(12))); - configuration.process(stepExecution); + configuration.execute(stepExecution); assertEquals(2, list.size()); assertEquals(1, steps.size()); } diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorTests.java index 1e2f671d8..2c16bede2 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepExecutorTests.java @@ -123,7 +123,7 @@ public class SimpleStepExecutorTests extends TestCase { StepExecution stepExecution = new StepExecution(step, jobExecutionContext); - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); assertEquals(1, processed.size()); assertEquals(1, stepExecution.getTaskCount().intValue()); } @@ -170,7 +170,7 @@ public class SimpleStepExecutorTests extends TestCase { } }); - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); assertEquals(1, processed.size()); } @@ -198,7 +198,7 @@ public class SimpleStepExecutorTests extends TestCase { } }); - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); assertEquals(1, processed.size()); } @@ -213,7 +213,7 @@ public class SimpleStepExecutorTests extends TestCase { StepExecution stepExecution = new StepExecution(step, jobExecutionContext); - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); assertEquals(1, processed.size()); } @@ -241,7 +241,7 @@ public class SimpleStepExecutorTests extends TestCase { jobExecutionContext); try { - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); } catch (Exception ex) { assertEquals(stepExecution.getRollbackCount(), new Integer(1)); @@ -273,7 +273,7 @@ public class SimpleStepExecutorTests extends TestCase { jobExecutionContext); try { - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); } catch (Exception ex) { ExitStatus status = stepExecution.getExitStatus(); @@ -295,7 +295,7 @@ public class SimpleStepExecutorTests extends TestCase { jobExecutionContext); try { - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); } catch (Throwable t) { fail(); @@ -320,7 +320,7 @@ public class SimpleStepExecutorTests extends TestCase { jobExecutionContext); try { - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); } catch (Throwable t) { fail(); @@ -345,7 +345,7 @@ public class SimpleStepExecutorTests extends TestCase { jobExecutionContext); try { - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); } catch (Throwable t) { fail(); @@ -372,7 +372,7 @@ public class SimpleStepExecutorTests extends TestCase { StepExecution stepExecution = new StepExecution(step, jobExecution); try { - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); } catch (Throwable t) { fail(); @@ -443,7 +443,7 @@ public class SimpleStepExecutorTests extends TestCase { }); try { - stepExecutor.process(stepExecution); + stepExecutor.execute(stepExecution); } catch (Throwable t) { fail(); diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepTests.java index 1c6256526..18619ee26 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/SimpleStepTests.java @@ -60,7 +60,7 @@ public class SimpleStepTests extends TestCase { new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobParameters()), new Long(12))); try { - executor.process(stepExecution); + executor.execute(stepExecution); fail("Expected RuntimeException"); } catch (NullPointerException e) { throw e; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/StepExecutorInterruptionTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/StepExecutorInterruptionTests.java index ba0a519b9..822411666 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/StepExecutorInterruptionTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/simple/StepExecutorInterruptionTests.java @@ -86,7 +86,7 @@ public class StepExecutorInterruptionTests extends TestCase { Thread processingThread = new Thread() { public void run() { try { - stepConfiguration.process(stepExecution); + stepConfiguration.execute(stepExecution); } catch (StepInterruptedException e) { // do nothing... diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/OrderItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/OrderItemReader.java index 787444b25..46da0c23d 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/OrderItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/OrderItemReader.java @@ -75,7 +75,7 @@ public class OrderItemReader extends AbstractItemReader { } /** - * @see org.springframework.batch.execution.io.FieldSetCallback#process(StepExecution) + * @see org.springframework.batch.execution.io.FieldSetCallback#execute(StepExecution) */ private void process(FieldSet fieldSet) { //finish processing if we hit the end of file