RESOLVED - issue BATCH-451: rename DefaultStepFactoryBean to SimpleStepFactoryBean
http://jira.springframework.org/browse/BATCH-451
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -20,7 +20,7 @@
|
||||
<bean id="test-job"
|
||||
class="org.springframework.batch.core.job.JobSupport">
|
||||
<property name="steps">
|
||||
<bean id="step1" class="org.springframework.batch.core.step.DefaultStepFactoryBean">
|
||||
<bean id="step1" class="org.springframework.batch.core.step.SimpleStepFactoryBean">
|
||||
<property name="itemReader" ref="itemReader" />
|
||||
<property name="itemWriter" ref="itemWriter" />
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
class="org.springframework.batch.core.job.JobSupport">
|
||||
<property name="steps">
|
||||
<bean id="step1"
|
||||
class="org.springframework.batch.core.step.DefaultStepFactoryBean">
|
||||
class="org.springframework.batch.core.step.SimpleStepFactoryBean">
|
||||
<property name="itemReader">
|
||||
<bean
|
||||
class="org.springframework.batch.item.reader.ListItemReader">
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<property name="allowStartIfComplete" value="true" />
|
||||
</bean>
|
||||
|
||||
<bean id="simpleStep" class="org.springframework.batch.core.step.DefaultStepFactoryBean"
|
||||
<bean id="simpleStep" class="org.springframework.batch.core.step.SimpleStepFactoryBean"
|
||||
abstract="true">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
|
||||
Reference in New Issue
Block a user