diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/AbstractStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/AbstractStepFactoryBean.java index 63c22f1a5..2184ba169 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/AbstractStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/AbstractStepFactoryBean.java @@ -32,7 +32,7 @@ import org.springframework.transaction.interceptor.TransactionAttribute; import org.springframework.util.Assert; /** - * Base class for factory beans for {@link ItemOrientedStep}. Ensures that all + * Base class for factory beans for {@link StepHandlerStep}. Ensures that all * the mandatory properties are set, and provides basic support for the * {@link Step} interface responsibilities like start limit. Supports * registration of {@link ItemStream}s and {@link StepListener}s. @@ -233,7 +233,7 @@ public abstract class AbstractStepFactoryBean implements FactoryBean, BeanN * @see org.springframework.beans.factory.FactoryBean#getObject() */ public final Object getObject() throws Exception { - ItemOrientedStep step = new ItemOrientedStep(getName()); + StepHandlerStep step = new StepHandlerStep(getName()); applyConfiguration(step); return step; } @@ -242,7 +242,7 @@ public abstract class AbstractStepFactoryBean implements FactoryBean, BeanN * @param step * */ - protected void applyConfiguration(ItemOrientedStep step) { + protected void applyConfiguration(StepHandlerStep step) { Assert.notNull(getItemReader(), "ItemReader must be provided"); Assert.notNull(getItemWriter(), "ItemWriter must be provided"); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStepHandler.java index ea535c45d..daebc50f2 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStepHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStepHandler.java @@ -28,7 +28,7 @@ import org.springframework.batch.item.ResetFailedException; import org.springframework.batch.repeat.ExitStatus; /** - * Simplest possible implementation of {@link ItemHandler} with no skipping or + * Simplest possible implementation of {@link StepHandler} with no skipping or * recovering. Just delegates all calls to the provided {@link ItemReader} and * {@link ItemWriter}. * @@ -39,7 +39,7 @@ import org.springframework.batch.repeat.ExitStatus; * @author Dave Syer * @author Robert Kasanicky */ -public class ItemOrientedStepHandler implements ItemHandler { +public class ItemOrientedStepHandler implements StepHandler { protected final Log logger = LogFactory.getLog(getClass()); @@ -68,7 +68,7 @@ public class ItemOrientedStepHandler implements ItemHandler { * {@link ItemProcessor} returns null, the write is omitted and another * item taken from the reader. * - * @see org.springframework.batch.core.step.item.ItemHandler#handle(org.springframework.batch.core.StepContribution) + * @see org.springframework.batch.core.step.item.StepHandler#handle(org.springframework.batch.core.StepContribution) */ public ExitStatus handle(StepContribution contribution) throws Exception { boolean processed = false; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBean.java index d2100db7f..e04008604 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBean.java @@ -59,7 +59,7 @@ public class RepeatOperationsStepFactoryBean extends AbstractStepFactoryBea * @param step * */ - protected void applyConfiguration(ItemOrientedStep step) { + protected void applyConfiguration(StepHandlerStep step) { super.applyConfiguration(step); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleStepFactoryBean.java index cdf7e7292..0b6a7c28d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleStepFactoryBean.java @@ -49,7 +49,7 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean { private TaskExecutor taskExecutor; - private ItemHandler itemHandler; + private StepHandler itemHandler; private RepeatTemplate stepOperations; @@ -142,7 +142,7 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean { * Public getter for the ItemHandler. * @return the ItemHandler */ - protected ItemHandler getItemHandler() { + protected StepHandler getItemHandler() { return itemHandler; } @@ -150,7 +150,7 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean { * Public setter for the ItemHandler. * @param itemHandler the ItemHandler to set */ - protected void setItemHandler(ItemHandler itemHandler) { + protected void setItemHandler(StepHandler itemHandler) { this.itemHandler = itemHandler; } @@ -158,7 +158,7 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean { * @param step * */ - protected void applyConfiguration(ItemOrientedStep step) { + protected void applyConfiguration(StepHandlerStep step) { super.applyConfiguration(step); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleItemHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleStepHandler.java similarity index 86% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleItemHandler.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleStepHandler.java index 8fef7f62b..3288a845e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleItemHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleStepHandler.java @@ -20,19 +20,19 @@ import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.support.PassthroughItemProcessor; /** - * Simplest possible implementation of {@link ItemHandler} with no skipping or + * Simplest possible implementation of {@link StepHandler} with no skipping or * recovering or processing. Just delegates all calls to the provided * {@link ItemReader} and {@link ItemWriter}. * * @author Dave Syer */ -public class SimpleItemHandler extends ItemOrientedStepHandler { +public class SimpleStepHandler extends ItemOrientedStepHandler { /** * Creates a {@link PassthroughItemProcessor} and uses it to create an * instance of {@link ItemOrientedStepHandler}. */ - public SimpleItemHandler(ItemReader itemReader, ItemWriter itemWriter) { + public SimpleStepHandler(ItemReader itemReader, ItemWriter itemWriter) { super(itemReader, new PassthroughItemProcessor(), itemWriter); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SkipLimitStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SkipLimitStepFactoryBean.java index f02e9ca3d..ea08514a3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SkipLimitStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SkipLimitStepFactoryBean.java @@ -187,7 +187,7 @@ public class SkipLimitStepFactoryBean extends SimpleStepFactoryBean { * Uses the {@link #setSkipLimit(int)} value to configure item handler and * and exception handler. */ - protected void applyConfiguration(ItemOrientedStep step) { + protected void applyConfiguration(StepHandlerStep step) { super.applyConfiguration(step); if (retryLimit > 0 || skipLimit > 0 || retryPolicy != null) { @@ -268,7 +268,7 @@ public class SkipLimitStepFactoryBean extends SimpleStepFactoryBean { } } }); - StatefulRetryItemHandler itemHandler = new StatefulRetryItemHandler(getItemReader(), getItemProcessor(), getItemWriter(), + StatefulRetryStepHandler itemHandler = new StatefulRetryStepHandler(getItemReader(), getItemProcessor(), getItemWriter(), retryTemplate, itemKeyGenerator, readSkipPolicy, writeSkipPolicy); itemHandler.setSkipListeners(BatchListenerFactoryHelper.getSkipListeners(getListeners())); @@ -306,7 +306,7 @@ public class SkipLimitStepFactoryBean extends SimpleStepFactoryBean { * @author Dave Syer * */ - private static class StatefulRetryItemHandler extends ItemOrientedStepHandler { + private static class StatefulRetryStepHandler extends ItemOrientedStepHandler { final private RetryOperations retryOperations; @@ -324,7 +324,7 @@ public class SkipLimitStepFactoryBean extends SimpleStepFactoryBean { * @param retryTemplate * @param itemKeyGenerator */ - public StatefulRetryItemHandler(ItemReader itemReader, ItemProcessor itemProcessor, ItemWriter itemWriter, + public StatefulRetryStepHandler(ItemReader itemReader, ItemProcessor itemProcessor, ItemWriter itemWriter, RetryOperations retryTemplate, ItemKeyGenerator itemKeyGenerator, ItemSkipPolicy readSkipPolicy, ItemSkipPolicy writeSkipPolicy) { super(itemReader, itemProcessor, itemWriter); @@ -410,7 +410,7 @@ public class SkipLimitStepFactoryBean extends SimpleStepFactoryBean { * exhausted. The listener callback (on write failure) will happen in * the next transaction automatically.
* - * @see org.springframework.batch.core.step.item.SimpleItemHandler#write(java.lang.Object, + * @see org.springframework.batch.core.step.item.SimpleStepHandler#write(java.lang.Object, * org.springframework.batch.core.StepContribution) */ protected boolean write(final T item, final StepContribution contribution) throws Exception { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandler.java similarity index 90% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemHandler.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandler.java index 94aaf11ee..b53ea7438 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandler.java @@ -25,14 +25,14 @@ import org.springframework.batch.item.ResetFailedException; import org.springframework.batch.repeat.ExitStatus; /** - * Strategy for processing a single item in an item-oriented step. Extends - * {@link ItemReader} and {@link ItemWriter} because part of the contract of the - * processor is that it should delegate calls to those interfaces. + * Strategy for processing in a step. Bears a resemblance to {@link ItemReader} + * and {@link ItemWriter} because part of the contract of the processor is that + * it should delegate calls to those interfaces. * * @author Dave Syer * */ -public interface ItemHandler { +public interface StepHandler { /** * Given the current context in the form of a step contribution, do whatever diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandlerStep.java similarity index 97% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStep.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandlerStep.java index 31226f568..a82f22a13 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/StepHandlerStep.java @@ -64,9 +64,9 @@ import org.springframework.transaction.interceptor.TransactionAttribute; * @author Ben Hale * @author Robert Kasanicky */ -public class ItemOrientedStep extends AbstractStep { +public class StepHandlerStep extends AbstractStep { - private static final Log logger = LogFactory.getLog(ItemOrientedStep.class); + private static final Log logger = LogFactory.getLog(StepHandlerStep.class); private RepeatOperations chunkOperations = new RepeatTemplate(); @@ -81,14 +81,14 @@ public class ItemOrientedStep extends AbstractStep { private TransactionAttribute transactionAttribute = new DefaultTransactionAttribute(); - private ItemHandler itemHandler; + private StepHandler itemHandler; private StepExecutionSynchronizer synchronizer; /** * @param name */ - public ItemOrientedStep(String name) { + public StepHandlerStep(String name) { super(name); synchronizer = new StepExecutionSynchronizerFactory().getStepExecutionSynchronizer(); } @@ -111,11 +111,11 @@ public class ItemOrientedStep extends AbstractStep { } /** - * Public setter for the {@link ItemHandler}. + * Public setter for the {@link StepHandler}. * - * @param itemHandler the {@link ItemHandler} to set + * @param itemHandler the {@link StepHandler} to set */ - public void setItemHandler(ItemHandler itemHandler) { + public void setItemHandler(StepHandler itemHandler) { this.itemHandler = itemHandler; } @@ -304,7 +304,7 @@ public class ItemOrientedStep extends AbstractStep { logger.error("Fatal error detected during commit."); throw new FatalException("Fatal error detected during commit", e); } - + getJobRepository().update(stepExecution); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java index a5c843d30..be73f6758 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java @@ -180,7 +180,7 @@ public class SimpleStepFactoryBeanTests extends TestCase { } } }); - ItemOrientedStep step = (ItemOrientedStep) factory.getObject(); + StepHandlerStep step = (StepHandlerStep) factory.getObject(); step.setChunkOperations(chunkOperations); job.setSteps(Collections.singletonList((Step) step)); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java index a2a219c3d..f2d542deb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepExecutorInterruptionTests.java @@ -39,7 +39,7 @@ import org.springframework.batch.support.transaction.ResourcelessTransactionMana public class StepExecutorInterruptionTests extends TestCase { - private ItemOrientedStep step; + private StepHandlerStep step; private JobExecution jobExecution; @@ -56,7 +56,7 @@ public class StepExecutorInterruptionTests extends TestCase { new MapStepExecutionDao(), new MapExecutionContextDao()); JobSupport jobConfiguration = new JobSupport(); - step = new ItemOrientedStep("interruptedStep"); + step = new StepHandlerStep("interruptedStep"); jobConfiguration.addStep(step); jobConfiguration.setBeanName("testJob"); jobExecution = jobRepository.createJobExecution(jobConfiguration, new JobParameters()); @@ -66,7 +66,7 @@ public class StepExecutorInterruptionTests extends TestCase { public void write(Object item) throws Exception { } }; - step.setItemHandler(new SimpleItemHandler(new AbstractItemReader() { + step.setItemHandler(new SimpleStepHandler(new AbstractItemReader() { public Object read() throws Exception { return null; } @@ -106,7 +106,7 @@ public class StepExecutorInterruptionTests extends TestCase { Thread processingThread = createThread(stepExecution); - step.setItemHandler(new SimpleItemHandler(new AbstractItemReader() { + step.setItemHandler(new SimpleStepHandler(new AbstractItemReader() { public Object read() throws Exception { return null; } @@ -144,7 +144,7 @@ public class StepExecutorInterruptionTests extends TestCase { * @return */ private Thread createThread(final StepExecution stepExecution) { - step.setItemHandler(new SimpleItemHandler(new AbstractItemReader() { + step.setItemHandler(new SimpleStepHandler(new AbstractItemReader() { public Object read() throws Exception { // do something non-trivial (and not Thread.sleep()) double foo = 1; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepIntegrationTests.java similarity index 96% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepIntegrationTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepIntegrationTests.java index 528fa98fa..7a71bd15e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepIntegrationTests.java @@ -57,9 +57,9 @@ import org.springframework.transaction.support.TransactionSynchronizationManager */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/org/springframework/batch/core/repository/dao/sql-dao-test.xml") -public class ItemOrientedStepIntegrationTests { +public class StepHandlerStepIntegrationTests { - private ItemOrientedStep step; + private StepHandlerStep step; private Job job; @@ -89,7 +89,7 @@ public class ItemOrientedStepIntegrationTests { jobRepository = (JobRepository) jobRepositoryFactoryBean.getObject(); RepeatTemplate template; - step = new ItemOrientedStep("stepName"); + step = new StepHandlerStep("stepName"); step.setJobRepository(jobRepository); step.setTransactionManager(transactionManager); template = new RepeatTemplate(); @@ -110,7 +110,7 @@ public class ItemOrientedStepIntegrationTests { @Test public void testStatusForCommitFailedException() throws Exception { - step.setItemHandler(new SimpleItemHandler(getReader(new String[] { "a", "b", "c" }), + step.setItemHandler(new SimpleStepHandler(getReader(new String[] { "a", "b", "c" }), new AbstractItemWriter() { public void write(String data) throws Exception { TransactionSynchronizationManager diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepTests.java similarity index 74% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepTests.java index 84dbc613e..fefa08a1d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StepHandlerStepTests.java @@ -62,7 +62,7 @@ import org.springframework.batch.support.transaction.ResourcelessTransactionMana import org.springframework.transaction.TransactionException; import org.springframework.transaction.support.DefaultTransactionStatus; -public class ItemOrientedStepTests extends TestCase { +public class StepHandlerStepTests extends TestCase { List processed = new ArrayList(); @@ -74,7 +74,7 @@ public class ItemOrientedStepTests extends TestCase { } }; - private ItemOrientedStep itemOrientedStep; + private StepHandlerStep step; private Job job; @@ -93,8 +93,8 @@ public class ItemOrientedStepTests extends TestCase { } private AbstractStep getStep(String[] strings) throws Exception { - ItemOrientedStep step = new ItemOrientedStep("stepName"); - step.setItemHandler(new SimpleItemHandler(getReader(strings), itemWriter)); + StepHandlerStep step = new StepHandlerStep("stepName"); + step.setItemHandler(new SimpleStepHandler(getReader(strings), itemWriter)); step.setJobRepository(new JobRepositorySupport()); step.setTransactionManager(transactionManager); return step; @@ -109,28 +109,28 @@ public class ItemOrientedStepTests extends TestCase { RepeatTemplate template; - itemOrientedStep = (ItemOrientedStep) getStep(new String[] { "foo", "bar", "spam" }); + step = (StepHandlerStep) getStep(new String[] { "foo", "bar", "spam" }); template = new RepeatTemplate(); template.setCompletionPolicy(new SimpleCompletionPolicy(1)); - itemOrientedStep.setStepOperations(template); + step.setStepOperations(template); // Only process one item: template = new RepeatTemplate(); template.setCompletionPolicy(new SimpleCompletionPolicy(1)); - itemOrientedStep.setChunkOperations(template); + step.setChunkOperations(template); job = new JobSupport("FOO"); jobInstance = new JobInstance(new Long(0), new JobParameters(), job.getName()); - itemOrientedStep.setTransactionManager(transactionManager); + step.setTransactionManager(transactionManager); } public void testStepExecutor() throws Exception { JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); assertEquals(1, processed.size()); assertEquals(1, stepExecution.getItemCount().intValue()); } @@ -138,14 +138,14 @@ public class ItemOrientedStepTests extends TestCase { public void testStepExecutionUpdates() throws Exception { JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); - itemOrientedStep.setStepOperations(new RepeatTemplate()); + step.setStepOperations(new RepeatTemplate()); JobRepositoryStub jobRepository = new JobRepositoryStub(); - itemOrientedStep.setJobRepository(jobRepository); + step.setJobRepository(jobRepository); - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); assertEquals(3, processed.size()); assertEquals(3, stepExecution.getItemCount().intValue()); @@ -158,13 +158,13 @@ public class ItemOrientedStepTests extends TestCase { // Only process one item: template.setCompletionPolicy(new SimpleCompletionPolicy(1)); - itemOrientedStep.setChunkOperations(template); + step.setChunkOperations(template); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); StepContribution contribution = stepExecution.createStepContribution(); - itemOrientedStep.processChunk(stepExecution, contribution); + step.processChunk(stepExecution, contribution); assertEquals(1, processed.size()); assertEquals(0, stepExecution.getItemCount().intValue()); assertEquals(1, contribution.getItemCount()); @@ -175,12 +175,12 @@ public class ItemOrientedStepTests extends TestCase { SimpleJobRepository repository = new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(), new MapExecutionContextDao()); - itemOrientedStep.setJobRepository(repository); + step.setJobRepository(repository); JobExecution jobExecution = repository.createJobExecution(job, jobInstance.getJobParameters()); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); assertEquals(1, processed.size()); } @@ -194,12 +194,12 @@ public class ItemOrientedStepTests extends TestCase { }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); + step.setItemHandler(new SimpleStepHandler(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); } catch (Exception ex) { assertEquals(stepExecution.getRollbackCount(), new Integer(1)); @@ -218,12 +218,12 @@ public class ItemOrientedStepTests extends TestCase { }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); + step.setItemHandler(new SimpleStepHandler(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); } catch (Exception ex) { ExitStatus status = stepExecution.getExitStatus(); @@ -242,17 +242,17 @@ public class ItemOrientedStepTests extends TestCase { }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); - itemOrientedStep.registerStepExecutionListener(new StepExecutionListenerSupport() { + step.setItemHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.registerStepExecutionListener(new StepExecutionListenerSupport() { public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) { return ExitStatus.FAILED.addExitDescription("FOO"); } }); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); } catch (Exception ex) { ExitStatus status = stepExecution.getExitStatus(); @@ -268,12 +268,12 @@ public class ItemOrientedStepTests extends TestCase { */ public void testNonRestartedJob() throws Exception { MockRestartableItemReader tasklet = new MockRestartableItemReader(); - itemOrientedStep.setItemHandler(new SimpleItemHandler(tasklet, itemWriter)); - itemOrientedStep.registerStream(tasklet); + step.setItemHandler(new SimpleStepHandler(tasklet, itemWriter)); + step.registerStream(tasklet); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); assertFalse(tasklet.isRestoreFromCalled()); assertTrue(tasklet.isGetExecutionAttributesCalled()); @@ -281,13 +281,13 @@ public class ItemOrientedStepTests extends TestCase { public void testSuccessfulExecutionWithExecutionContext() throws Exception { final JobExecution jobExecution = new JobExecution(jobInstance); - final StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); - itemOrientedStep.setJobRepository(new JobRepositorySupport() { + final StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); + step.setJobRepository(new JobRepositorySupport() { public void updateExecutionContext(StepExecution stepExecution) { list.add(stepExecution); } }); - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); // context saved before looping and updated once for every processing // loop (once in this case) and finally in the abstract step (regardless @@ -297,8 +297,8 @@ public class ItemOrientedStepTests extends TestCase { public void testSuccessfulExecutionWithFailureOnSaveOfExecutionContext() throws Exception { final JobExecution jobExecution = new JobExecution(jobInstance); - final StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); - itemOrientedStep.setJobRepository(new JobRepositorySupport() { + final StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); + step.setJobRepository(new JobRepositorySupport() { private int counter = 0; // initial save before item processing succeeds, later calls fail @@ -309,7 +309,7 @@ public class ItemOrientedStepTests extends TestCase { } }); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail(); } catch (RuntimeException e) { @@ -326,12 +326,12 @@ public class ItemOrientedStepTests extends TestCase { */ public void testNoSaveExecutionAttributesRestartableJob() { MockRestartableItemReader tasklet = new MockRestartableItemReader(); - itemOrientedStep.setItemHandler(new SimpleItemHandler(tasklet, itemWriter)); + step.setItemHandler(new SimpleStepHandler(tasklet, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); } catch (Throwable t) { fail(); @@ -346,15 +346,15 @@ public class ItemOrientedStepTests extends TestCase { * Restartable. */ public void testRestartJobOnNonRestartableTasklet() throws Exception { - itemOrientedStep.setItemHandler(new SimpleItemHandler(new AbstractItemReader() { + step.setItemHandler(new SimpleStepHandler(new AbstractItemReader() { public String read() throws Exception { return "foo"; } }, itemWriter)); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); } public void testStreamManager() throws Exception { @@ -367,14 +367,14 @@ public class ItemOrientedStepTests extends TestCase { executionContext.putString("foo", "bar"); } }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(reader, itemWriter)); - itemOrientedStep.registerStream(reader); + step.setItemHandler(new SimpleStepHandler(reader, itemWriter)); + step.registerStream(reader); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); // At least once in that process the statistics service was asked for // statistics... @@ -382,23 +382,23 @@ public class ItemOrientedStepTests extends TestCase { } public void testDirectlyInjectedItemStream() throws Exception { - itemOrientedStep.setStreams(new ItemStream[] { new ItemStreamSupport() { + step.setStreams(new ItemStream[] { new ItemStreamSupport() { public void update(ExecutionContext executionContext) { executionContext.putString("foo", "bar"); } } }); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); assertEquals("bar", stepExecution.getExecutionContext().getString("foo")); } public void testDirectlyInjectedListener() throws Exception { - itemOrientedStep.registerStepExecutionListener(new StepExecutionListenerSupport() { + step.registerStepExecutionListener(new StepExecutionListenerSupport() { public void beforeStep(StepExecution stepExecution) { list.add("foo"); } @@ -409,8 +409,8 @@ public class ItemOrientedStepTests extends TestCase { } }); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); - itemOrientedStep.execute(stepExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); + step.execute(stepExecution); assertEquals(2, list.size()); } @@ -424,10 +424,10 @@ public class ItemOrientedStepTests extends TestCase { assertEquals(1, list.size()); } }; - itemOrientedStep.setStreams(new ItemStream[] { reader }); - itemOrientedStep.registerStepExecutionListener(reader); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), new JobExecution(jobInstance)); - itemOrientedStep.execute(stepExecution); + step.setStreams(new ItemStream[] { reader }); + step.registerStepExecutionListener(reader); + StepExecution stepExecution = new StepExecution(step.getName(), new JobExecution(jobInstance)); + step.execute(stepExecution); assertEquals(1, list.size()); } @@ -435,7 +435,7 @@ public class ItemOrientedStepTests extends TestCase { final ExitStatus customStatus = new ExitStatus(false, "custom code"); - itemOrientedStep.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() { + step.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() { public ExitStatus afterStep(StepExecution stepExecution) { list.add("afterStepCalled"); return customStatus; @@ -444,11 +444,11 @@ public class ItemOrientedStepTests extends TestCase { RepeatTemplate stepTemplate = new RepeatTemplate(); stepTemplate.setCompletionPolicy(new SimpleCompletionPolicy(5)); - itemOrientedStep.setStepOperations(stepTemplate); + step.setStepOperations(stepTemplate); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); - itemOrientedStep.execute(stepExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); + step.execute(stepExecution); assertEquals(1, list.size()); ExitStatus returnedStatus = stepExecution.getExitStatus(); assertEquals(customStatus.getExitCode(), returnedStatus.getExitCode()); @@ -456,21 +456,21 @@ public class ItemOrientedStepTests extends TestCase { } public void testDirectlyInjectedListenerOnError() throws Exception { - itemOrientedStep.registerStepExecutionListener(new StepExecutionListenerSupport() { + step.registerStepExecutionListener(new StepExecutionListenerSupport() { public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) { list.add(e); return null; } }); - itemOrientedStep.setItemHandler(new SimpleItemHandler(new MockRestartableItemReader() { + step.setItemHandler(new SimpleStepHandler(new MockRestartableItemReader() { public String read() throws Exception { throw new RuntimeException("FOO"); } }, itemWriter)); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail("Expected RuntimeException"); } catch (RuntimeException e) { @@ -489,14 +489,14 @@ public class ItemOrientedStepTests extends TestCase { executionContext.putString("foo", "bar"); } }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(reader, itemWriter)); - itemOrientedStep.setStreams(new ItemStream[] { reader }); + step.setItemHandler(new SimpleStepHandler(reader, itemWriter)); + step.setStreams(new ItemStream[] { reader }); JobExecution jobExecution = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecution); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); assertEquals(false, stepExecution.getExecutionContext().containsKey("foo")); - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); // At least once in that process the statistics service was asked for // statistics... @@ -512,7 +512,7 @@ public class ItemOrientedStepTests extends TestCase { } }; - itemOrientedStep.setInterruptionPolicy(interruptionPolicy); + step.setInterruptionPolicy(interruptionPolicy); ItemReader itemReader = new AbstractItemReader() { @@ -523,15 +523,15 @@ public class ItemOrientedStepTests extends TestCase { }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); + step.setItemHandler(new SimpleStepHandler(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); stepExecution.setExecutionContext(foobarEc); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail("Expected JobInterruptedException"); } catch (JobInterruptedException ex) { @@ -550,16 +550,16 @@ public class ItemOrientedStepTests extends TestCase { throw new RuntimeException("Foo"); } }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); + step.setItemHandler(new SimpleStepHandler(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); stepExecution.setExecutionContext(foobarEc); // step.setLastExecution(stepExecution); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail("Expected RuntimeException"); } catch (RuntimeException ex) { @@ -577,16 +577,16 @@ public class ItemOrientedStepTests extends TestCase { throw new Error("Foo"); } }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); + step.setItemHandler(new SimpleStepHandler(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); stepExecution.setExecutionContext(foobarEc); // step.setLastExecution(stepExecution); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail("Expected Error"); } catch (Error ex) { @@ -604,8 +604,8 @@ public class ItemOrientedStepTests extends TestCase { throw new RuntimeException("Foo"); } }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); - itemOrientedStep.setTransactionManager(new ResourcelessTransactionManager() { + step.setItemHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.setTransactionManager(new ResourcelessTransactionManager() { protected void doRollback(DefaultTransactionStatus status) throws TransactionException { // Simulate failure on rollback when stream resets throw new ResetFailedException("Bar"); @@ -613,13 +613,13 @@ public class ItemOrientedStepTests extends TestCase { }); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); stepExecution.setExecutionContext(foobarEc); // step.setLastExecution(stepExecution); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail("Expected UnexpectedJobExecutionException"); } catch (RuntimeException ex) { @@ -633,7 +633,7 @@ public class ItemOrientedStepTests extends TestCase { public void testStatusForCommitFailedException() throws Exception { - itemOrientedStep.setTransactionManager(new ResourcelessTransactionManager() { + step.setTransactionManager(new ResourcelessTransactionManager() { protected void doCommit(DefaultTransactionStatus status) throws TransactionException { // Simulate failure on commit throw new RuntimeException("Bar"); @@ -641,13 +641,13 @@ public class ItemOrientedStepTests extends TestCase { }); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); stepExecution.setExecutionContext(foobarEc); // step.setLastExecution(stepExecution); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail("Expected BatchCriticalException"); } catch (RuntimeException ex) { @@ -663,18 +663,18 @@ public class ItemOrientedStepTests extends TestCase { public void testStatusForFinalUpdateFailedException() throws Exception { - itemOrientedStep.setJobRepository(new JobRepositorySupport()); - itemOrientedStep.setStreams(new ItemStream[] { new ItemStreamSupport() { + step.setJobRepository(new JobRepositorySupport()); + step.setStreams(new ItemStream[] { new ItemStreamSupport() { public void close(ExecutionContext executionContext) throws ItemStreamException { throw new RuntimeException("Bar"); } } }); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail("Expected RuntimeException"); } catch (RuntimeException ex) { @@ -698,17 +698,17 @@ public class ItemOrientedStepTests extends TestCase { throw new RuntimeException("Bar"); } }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(itemReader, itemWriter)); - itemOrientedStep.registerStream(itemReader); + step.setItemHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.registerStream(itemReader); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); stepExecution.setExecutionContext(foobarEc); // step.setLastExecution(stepExecution); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail("Expected InfrastructureException"); } catch (UnexpectedJobExecutionException ex) { @@ -735,13 +735,13 @@ public class ItemOrientedStepTests extends TestCase { throw new RuntimeException("CRASH!"); } }; - itemOrientedStep.setItemHandler(new SimpleItemHandler(reader, itemWriter)); - itemOrientedStep.registerStream(reader); + step.setItemHandler(new SimpleStepHandler(reader, itemWriter)); + step.registerStream(reader); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), new JobExecution(jobInstance)); + StepExecution stepExecution = new StepExecution(step.getName(), new JobExecution(jobInstance)); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail("Expected InfrastructureException"); } catch (RuntimeException expected) { @@ -758,12 +758,12 @@ public class ItemOrientedStepTests extends TestCase { // process all items: template.setCompletionPolicy(new DefaultResultCompletionPolicy()); - itemOrientedStep.setStepOperations(template); + step.setStepOperations(template); JobExecution jobExecutionContext = new JobExecution(jobInstance); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), jobExecutionContext); + StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); assertEquals(3, processed.size()); assertEquals(3, stepExecution.getItemCount().intValue()); } @@ -779,10 +779,10 @@ public class ItemOrientedStepTests extends TestCase { throw new RuntimeException("exception thrown in afterStep to signal failure"); } }; - itemOrientedStep.setStepExecutionListeners(new StepExecutionListener[] { listener }); - StepExecution stepExecution = new StepExecution(itemOrientedStep.getName(), new JobExecution(jobInstance)); + step.setStepExecutionListeners(new StepExecutionListener[] { listener }); + StepExecution stepExecution = new StepExecution(step.getName(), new JobExecution(jobInstance)); try { - itemOrientedStep.execute(stepExecution); + step.execute(stepExecution); fail(); } catch (RuntimeException expected) { @@ -811,8 +811,7 @@ public class ItemOrientedStepTests extends TestCase { } - private class MockRestartableItemReader extends ItemStreamSupport implements ItemReader, - StepExecutionListener { + private class MockRestartableItemReader extends ItemStreamSupport implements ItemReader, StepExecutionListener { private boolean getExecutionAttributesCalled = false;