diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/DefaultStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/SimpleStepFactoryBean.java similarity index 95% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/DefaultStepFactoryBean.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/SimpleStepFactoryBean.java index f497ff8eb..e789e0bc6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/DefaultStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/SimpleStepFactoryBean.java @@ -32,10 +32,16 @@ import org.springframework.core.task.TaskExecutor; * Most common configuration options for simple steps should be found here. Use * this factory bean instead of creating a {@link Step} implementation manually. * + * This factory does not support configuration of fault-tolerant behavior, use + * appropriate subclass of this factory bean to configure skip or retry. + * + * @see SkipLimitStepFactoryBean + * @see StatefulRetryStepFactoryBean + * * @author Dave Syer * */ -public class DefaultStepFactoryBean extends AbstractStepFactoryBean { +public class SimpleStepFactoryBean extends AbstractStepFactoryBean { private int commitInterval = 0; @@ -72,7 +78,7 @@ public class DefaultStepFactoryBean extends AbstractStepFactoryBean { public void setStreams(ItemStream[] streams) { this.streams = streams; } - + /** * The listeners to inject into the {@link Step}. Any instance of * {@link BatchListener} can be used, and will then receive callbacks at the @@ -176,7 +182,6 @@ public class DefaultStepFactoryBean extends AbstractStepFactoryBean { BatchListenerFactoryHelper helper = new BatchListenerFactoryHelper(); - if (commitInterval > 0) { RepeatTemplate chunkOperations = new RepeatTemplate(); chunkOperations.setCompletionPolicy(new SimpleCompletionPolicy(commitInterval)); @@ -187,7 +192,6 @@ public class DefaultStepFactoryBean extends AbstractStepFactoryBean { StepListener[] stepListeners = helper.getStepListeners(listeners); itemReader = helper.getItemReader(itemReader, listeners); itemWriter = helper.getItemWriter(itemWriter, listeners); - // In case they are used by subclasses: setItemReader(itemReader); @@ -196,7 +200,7 @@ public class DefaultStepFactoryBean extends AbstractStepFactoryBean { step.setStepListeners(stepListeners); stepOperations = new RepeatTemplate(); - + if (taskExecutor != null) { TaskExecutorRepeatTemplate repeatTemplate = new TaskExecutorRepeatTemplate(); repeatTemplate.setTaskExecutor(taskExecutor); @@ -211,5 +215,5 @@ public class DefaultStepFactoryBean extends AbstractStepFactoryBean { step.setItemHandler(itemHandler); } - + } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/SkipLimitStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/SkipLimitStepFactoryBean.java index 8eb878b38..88335a758 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/SkipLimitStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/SkipLimitStepFactoryBean.java @@ -8,7 +8,7 @@ import org.springframework.batch.repeat.exception.SimpleLimitExceptionHandler; * Factory bean for step that allows configuring skip limit. * */ -public class SkipLimitStepFactoryBean extends DefaultStepFactoryBean { +public class SkipLimitStepFactoryBean extends SimpleStepFactoryBean { private int skipLimit = 0; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/StatefulRetryStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/StatefulRetryStepFactoryBean.java index 2b89d7cf6..f862cad20 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/StatefulRetryStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/StatefulRetryStepFactoryBean.java @@ -47,7 +47,7 @@ import org.springframework.batch.retry.support.RetryTemplate; * @author Dave Syer * */ -public class StatefulRetryStepFactoryBean extends DefaultStepFactoryBean { +public class StatefulRetryStepFactoryBean extends SimpleStepFactoryBean { private ItemKeyGenerator itemKeyGenerator; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/DefaultStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/SimpleStepFactoryBeanTests.java similarity index 88% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/DefaultStepFactoryBeanTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/SimpleStepFactoryBeanTests.java index 6509c5679..0169370cb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/DefaultStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/SimpleStepFactoryBeanTests.java @@ -44,7 +44,10 @@ import org.springframework.batch.repeat.support.RepeatTemplate; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; -public class DefaultStepFactoryBeanTests extends TestCase { +/** + * Tests for {@link SimpleStepFactoryBean}. + */ +public class SimpleStepFactoryBeanTests extends TestCase { private List recovered = new ArrayList(); @@ -71,16 +74,16 @@ public class DefaultStepFactoryBeanTests extends TestCase { MapStepExecutionDao.clear(); } - private DefaultStepFactoryBean getStep(String arg) throws Exception { - return getStep(new String[] { arg }); + private SimpleStepFactoryBean getStepFactory(String arg) throws Exception { + return getStepFactory(new String[] { arg }); } - private DefaultStepFactoryBean getStep(String arg0, String arg1) throws Exception { - return getStep(new String[] { arg0, arg1 }); + private SimpleStepFactoryBean getStepFactory(String arg0, String arg1) throws Exception { + return getStepFactory(new String[] { arg0, arg1 }); } - private DefaultStepFactoryBean getStep(String[] args) throws Exception { - DefaultStepFactoryBean factory = new DefaultStepFactoryBean(); + private SimpleStepFactoryBean getStepFactory(String[] args) throws Exception { + SimpleStepFactoryBean factory = new SimpleStepFactoryBean(); List items = TransactionAwareProxyFactory.createTransactionalList(); items.addAll(Arrays.asList(args)); @@ -97,10 +100,10 @@ public class DefaultStepFactoryBeanTests extends TestCase { public void testSimpleJob() throws Exception { job.setSteps(new ArrayList()); - AbstractStep step = (AbstractStep) getStep("foo", "bar").getObject(); + AbstractStep step = (AbstractStep) getStepFactory("foo", "bar").getObject(); step.setName("step1"); job.addStep(step); - step = (AbstractStep) getStep("spam").getObject(); + step = (AbstractStep) getStepFactory("spam").getObject(); step.setName("step2"); job.addStep(step); @@ -130,7 +133,7 @@ public class DefaultStepFactoryBeanTests extends TestCase { * is recovered ("skipped") on the second attempt (see retry policy * definition above)... */ - DefaultStepFactoryBean factory = getStep(new String[] { "foo", "bar", "spam" }); + SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); factory.setItemWriter(new AbstractItemWriter() { public void write(Object data) throws Exception { @@ -163,7 +166,7 @@ public class DefaultStepFactoryBeanTests extends TestCase { } public void testExceptionTerminates() throws Exception { - DefaultStepFactoryBean factory = getStep(new String[] { "foo", "bar", "spam" }); + SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); factory.setBeanName("exceptionStep"); factory.setItemWriter(new AbstractItemWriter() { public void write(Object data) throws Exception { @@ -189,7 +192,7 @@ public class DefaultStepFactoryBeanTests extends TestCase { String[] items = new String[] { "1", "2", "3", "4", "5", "6", "7" }; int commitInterval = 3; - DefaultStepFactoryBean factory = getStep(items); + SimpleStepFactoryBean factory = getStepFactory(items); class CountingChunkListener implements ChunkListener { int beforeCount = 0; int afterCount = 0; diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/support/test-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/support/test-context.xml index 9a59ee0bc..33ec258c1 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/support/test-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/support/test-context.xml @@ -20,7 +20,7 @@ - + diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job.xml index 4a728f1fd..119a9ba1f 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/launch/support/job.xml @@ -15,7 +15,7 @@ class="org.springframework.batch.core.job.JobSupport"> + class="org.springframework.batch.core.step.SimpleStepFactoryBean"> diff --git a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml index 9fa743e21..26e960df5 100644 --- a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml @@ -58,7 +58,7 @@ -