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/ChunkOrientedTasklet.java similarity index 94% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ItemOrientedStepHandler.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java index 115c41699..6112a50b1 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/ChunkOrientedTasklet.java @@ -22,7 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.StepListener; import org.springframework.batch.core.listener.MulticasterBatchListener; -import org.springframework.batch.core.step.tasklet.StepHandler; +import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; @@ -33,7 +33,7 @@ import org.springframework.batch.repeat.RepeatOperations; import org.springframework.core.AttributeAccessor; /** - * Simplest possible implementation of {@link StepHandler} with no skipping or + * Simplest possible implementation of {@link Tasklet} with no skipping or * recovering. Just delegates all calls to the provided {@link ItemReader} and * {@link ItemWriter}. * @@ -44,7 +44,7 @@ import org.springframework.core.AttributeAccessor; * @author Dave Syer * @author Robert Kasanicky */ -public class ItemOrientedStepHandler implements StepHandler { +public class ChunkOrientedTasklet implements Tasklet { private static final String INPUT_BUFFER_KEY = "INPUT_BUFFER_KEY"; @@ -68,7 +68,7 @@ public class ItemOrientedStepHandler implements StepHandler { * @param itemWriter * @param repeatOperations */ - public ItemOrientedStepHandler(ItemReader itemReader, + public ChunkOrientedTasklet(ItemReader itemReader, ItemProcessor itemProcessor, ItemWriter itemWriter, RepeatOperations repeatOperations) { super(); @@ -114,10 +114,10 @@ public class ItemOrientedStepHandler implements StepHandler { * {@link ItemProcessor} returns null, the write is omitted and another item * taken from the reader. * - * @see org.springframework.batch.core.step.tasklet.StepHandler#handle(org.springframework.batch.core.StepContribution, + * @see org.springframework.batch.core.step.tasklet.Tasklet#execute(org.springframework.batch.core.StepContribution, * AttributeAccessor) */ - public ExitStatus handle(final StepContribution contribution, AttributeAccessor attributes) throws Exception { + public ExitStatus execute(final StepContribution contribution, AttributeAccessor attributes) throws Exception { // TODO: check flags to see if these need to be saved or not (e.g. JMS not) final Chunk inputs = getInputBuffer(attributes); 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 c334b101c..5889a73e6 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 @@ -21,7 +21,7 @@ import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.core.StepListener; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.step.tasklet.StepHandlerStep; +import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; @@ -262,7 +262,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { * @see org.springframework.beans.factory.FactoryBean#getObject() */ public final Object getObject() throws Exception { - StepHandlerStep step = new StepHandlerStep(getName()); + TaskletStep step = new TaskletStep(getName()); applyConfiguration(step); return step; } @@ -387,7 +387,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { * @param step * */ - protected void applyConfiguration(StepHandlerStep step) { + protected void applyConfiguration(TaskletStep step) { Assert.notNull(getItemReader(), "ItemReader must be provided"); Assert.notNull(getItemWriter(), "ItemWriter must be provided"); @@ -457,9 +457,9 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { step.setStepOperations(stepOperations); - ItemOrientedStepHandler stepHandler = new ItemOrientedStepHandler(itemReader, itemProcessor, itemWriter, chunkOperations); - stepHandler.setListeners(getListeners()); - step.setStepHandler(stepHandler); + ChunkOrientedTasklet tasklet = new ChunkOrientedTasklet(itemReader, itemProcessor, itemWriter, chunkOperations); + tasklet.setListeners(getListeners()); + step.setTasklet(tasklet); } 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 d346af677..4338b3590 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 @@ -13,7 +13,7 @@ import org.springframework.batch.core.step.skip.ItemSkipPolicy; import org.springframework.batch.core.step.skip.LimitCheckingItemSkipPolicy; import org.springframework.batch.core.step.skip.SkipLimitExceededException; import org.springframework.batch.core.step.skip.SkipListenerFailedException; -import org.springframework.batch.core.step.tasklet.StepHandlerStep; +import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; @@ -194,7 +194,7 @@ public class SkipLimitStepFactoryBean extends SimpleStepFactoryBean * Uses the {@link #setSkipLimit(int)} value to configure item handler and * and exception handler. */ - protected void applyConfiguration(StepHandlerStep step) { + protected void applyConfiguration(TaskletStep step) { super.applyConfiguration(step); if (retryLimit > 0 || skipLimit > 0 || retryPolicy != null) { @@ -261,12 +261,12 @@ public class SkipLimitStepFactoryBean extends SimpleStepFactoryBean exceptions.addAll(new ArrayList>(retryableExceptionClasses)); ItemSkipPolicy writeSkipPolicy = new LimitCheckingItemSkipPolicy(skipLimit, exceptions, new ArrayList>(fatalExceptionClasses)); - ItemOrientedStepHandler stepHandler = new StatefulRetryStepHandler(getItemReader(), + ChunkOrientedTasklet tasklet = new StatefulRetryTasklet(getItemReader(), getItemProcessor(), getItemWriter(), getChunkOperations(), retryTemplate, readSkipPolicy, writeSkipPolicy); - stepHandler.setListeners(getListeners()); + tasklet.setListeners(getListeners()); - step.setStepHandler(stepHandler); + step.setTasklet(tasklet); } @@ -296,7 +296,7 @@ public class SkipLimitStepFactoryBean extends SimpleStepFactoryBean * @author Dave Syer * */ - static class StatefulRetryStepHandler extends ItemOrientedStepHandler { + static class StatefulRetryTasklet extends ChunkOrientedTasklet { final private RetryOperations retryOperations; @@ -309,7 +309,7 @@ public class SkipLimitStepFactoryBean extends SimpleStepFactoryBean * @param itemWriter * @param retryTemplate */ - public StatefulRetryStepHandler(ItemReader itemReader, + public StatefulRetryTasklet(ItemReader itemReader, ItemProcessor itemProcessor, ItemWriter itemWriter, RepeatOperations chunkOperations, RetryOperations retryTemplate, ItemSkipPolicy readSkipPolicy, ItemSkipPolicy writeSkipPolicy) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java similarity index 85% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapter.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java index 1338ef1f3..92d5197c0 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java @@ -25,12 +25,12 @@ import org.springframework.util.Assert; /** * Adapts a {@link Callable}<{@link ExitStatus}> to the - * {@link StepHandler} interface. + * {@link Tasklet} interface. * * @author Dave Syer * */ -public class CallableStepHandlerAdapter implements StepHandler, InitializingBean { +public class CallableTaskletAdapter implements Tasklet, InitializingBean { private Callable callable; @@ -54,9 +54,9 @@ public class CallableStepHandlerAdapter implements StepHandler, InitializingBean /** * Execute the provided Callable and return its {@link ExitStatus}. Ignores * the {@link StepContribution} and the attributes. - * @see StepHandler#handle(StepContribution, AttributeAccessor) + * @see Tasklet#execute(StepContribution, AttributeAccessor) */ - public ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception { + public ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception { return callable.call(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java similarity index 84% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapter.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java index f11b5a395..91f260608 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java @@ -21,7 +21,7 @@ import org.springframework.batch.repeat.ExitStatus; import org.springframework.core.AttributeAccessor; /** - * A {@link StepHandler} that wraps a method in a POJO. By default the return + * A {@link Tasklet} that wraps a method in a POJO. By default the return * value is {@link ExitStatus#FINISHED} unless the delegate POJO itself returns * an {@link ExitStatus}. The POJO method is usually going to have no arguments, * but a static argument or array of arguments can be used by setting the @@ -32,16 +32,16 @@ import org.springframework.core.AttributeAccessor; * @author Dave Syer * */ -public class StepHandlerAdapter extends AbstractMethodInvokingDelegator implements StepHandler { +public class MethodInvokingTaskletAdapter extends AbstractMethodInvokingDelegator implements Tasklet { /** * Delegate execution to the target object and translate the return value to * an {@link ExitStatus} by invoking a method in the delegate POJO. Ignores * the {@link StepContribution} and the attributes. * - * @see StepHandler#handle(StepContribution, AttributeAccessor) + * @see Tasklet#execute(StepContribution, AttributeAccessor) */ - public ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception { + public ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception { return mapResult(invokeDelegateMethod()); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java similarity index 92% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandler.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java index 9c920b507..a5126017d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java @@ -14,7 +14,7 @@ import org.springframework.core.AttributeAccessor; import org.springframework.util.Assert; /** - * {@link StepHandler} that executes a system command. + * {@link Tasklet} that executes a system command. * * The system command is executed in a new thread - timeout value is required to * be set, so that the batch job does not hang forever if the external process @@ -31,7 +31,7 @@ import org.springframework.util.Assert; * * @author Robert Kasanicky */ -public class SystemCommandStepHandler extends StepExecutionListenerSupport implements StepHandler, InitializingBean { +public class SystemCommandTasklet extends StepExecutionListenerSupport implements Tasklet, InitializingBean { private String command; @@ -51,7 +51,7 @@ public class SystemCommandStepHandler extends StepExecutionListenerSupport imple * Execute system command and map its exit code to {@link ExitStatus} using * {@link SystemProcessExitCodeMapper}. */ - public ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception { + public ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception { ExecutorThread executorThread = new ExecutorThread(); executorThread.start(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemProcessExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemProcessExitCodeMapper.java index b4ea518a3..47603d2ce 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemProcessExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemProcessExitCodeMapper.java @@ -1,12 +1,12 @@ package org.springframework.batch.core.step.tasklet; -import org.springframework.batch.core.step.tasklet.SystemCommandStepHandler; +import org.springframework.batch.core.step.tasklet.SystemCommandTasklet; import org.springframework.batch.repeat.ExitStatus; /** * Maps the exit code of a system process to ExitStatus value * returned by a system command. Designed for use with the - * {@link SystemCommandStepHandler}. + * {@link SystemCommandTasklet}. * * @author Robert Kasanicky */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/Tasklet.java similarity index 60% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandler.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/Tasklet.java index 9c771fcab..4be2f89b1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/Tasklet.java @@ -16,34 +16,30 @@ package org.springframework.batch.core.step.tasklet; import org.springframework.batch.core.StepContribution; -import org.springframework.batch.item.ItemReader; -import org.springframework.batch.item.ItemWriter; import org.springframework.batch.repeat.ExitStatus; import org.springframework.core.AttributeAccessor; /** - * 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. + * Strategy for processing in a step. * * @author Dave Syer * */ -public interface StepHandler { +public interface Tasklet { /** * Given the current context in the form of a step contribution, do whatever - * is necessary to process this unit inside a chunk. Implementations obtain - * the item and return {@link ExitStatus#FINISHED} if it is null. If it is - * not null process the item and return {@link ExitStatus#CONTINUABLE}. On - * failure throws an exception. + * is necessary to process this unit inside a transaction. Implementations + * return {@link ExitStatus#FINISHED} if finished. If not they return + * {@link ExitStatus#CONTINUABLE}. On failure throws an exception. * * @param contribution mutable state to be passed back to update the current * step execution - * @param attributes attributes shared between invocations + * @param attributes attributes shared between invocations but not between + * restarts * @return an {@link ExitStatus} indicating whether processing is * continuable. */ - ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception; + ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java similarity index 92% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerStep.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java index f3139dfd7..37d5a9f54 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java @@ -25,7 +25,6 @@ import org.springframework.batch.core.JobInterruptedException; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; -import org.springframework.batch.core.StepListener; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.step.AbstractStep; import org.springframework.batch.core.step.StepExecutionSynchronizer; @@ -49,10 +48,11 @@ import org.springframework.transaction.interceptor.DefaultTransactionAttribute; import org.springframework.transaction.interceptor.TransactionAttribute; /** - * Simple implementation of executing the step as a set of chunks, each chunk - * surrounded by a transaction. The structure is therefore that of a loop with - * transaction boundary inside the loop. The loop is controlled by the step - * operations ( {@link #setStepOperations(RepeatOperations)}).
+ * Simple implementation of executing the step as a call to a {@link Tasklet}, + * possibly repeated, and each call surrounded by a transaction. The structure + * is therefore that of a loop with transaction boundary inside the loop. The + * loop is controlled by the step operations ( + * {@link #setStepOperations(RepeatOperations)}).

* * Clients can use interceptors in the step operations to intercept or listen to * the iteration on a step-wide basis, for instance to get a callback when the @@ -64,9 +64,9 @@ import org.springframework.transaction.interceptor.TransactionAttribute; * @author Ben Hale * @author Robert Kasanicky */ -public class StepHandlerStep extends AbstractStep { +public class TaskletStep extends AbstractStep { - private static final Log logger = LogFactory.getLog(StepHandlerStep.class); + private static final Log logger = LogFactory.getLog(TaskletStep.class); private RepeatOperations stepOperations = new RepeatTemplate(); @@ -79,21 +79,21 @@ public class StepHandlerStep extends AbstractStep { private TransactionAttribute transactionAttribute = new DefaultTransactionAttribute(); - private StepHandler stepHandler; + private Tasklet tasklet; private StepExecutionSynchronizer synchronizer; /** * Default constructor. */ - public StepHandlerStep() { + public TaskletStep() { this(null); } /** * @param name */ - public StepHandlerStep(String name) { + public TaskletStep(String name) { super(name); synchronizer = new StepExecutionSynchronizerFactory().getStepExecutionSynchronizer(); } @@ -116,14 +116,14 @@ public class StepHandlerStep extends AbstractStep { } /** - * Public setter for the {@link StepHandler}. + * Public setter for the {@link Tasklet}. * - * @param stepHandler the {@link StepHandler} to set + * @param tasklet the {@link Tasklet} to set */ - public void setStepHandler(StepHandler stepHandler) { - this.stepHandler = stepHandler; - if (stepHandler instanceof StepExecutionListener) { - registerStepExecutionListener((StepExecutionListener) stepHandler); + public void setTasklet(Tasklet tasklet) { + this.tasklet = tasklet; + if (tasklet instanceof StepExecutionListener) { + registerStepExecutionListener((StepExecutionListener) tasklet); } } @@ -249,7 +249,7 @@ public class StepHandlerStep extends AbstractStep { try { try { - exitStatus = stepHandler.handle(contribution, attributes); + exitStatus = tasklet.execute(contribution, attributes); } catch (Error e) { if (transactionAttribute.rollbackOn(e)) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepHandlerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java similarity index 91% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepHandlerTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java index d485b6dc4..879f656ef 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ItemOrientedStepHandlerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java @@ -42,7 +42,7 @@ import org.springframework.core.AttributeAccessor; * @author Dave Syer * */ -public class ItemOrientedStepHandlerTests { +public class ChunkOrientedTaskletTests { private StubItemReader itemReader = new StubItemReader(); @@ -59,22 +59,22 @@ public class ItemOrientedStepHandlerTests { @Test public void testHandle() throws Exception { - ItemOrientedStepHandler handler = new ItemOrientedStepHandler(itemReader, + ChunkOrientedTasklet handler = new ChunkOrientedTasklet(itemReader, new PassthroughItemProcessor(), itemWriter, repeatTemplate); StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(new JobInstance( 123L, new JobParameters(), "job")))); - handler.handle(contribution, context); + handler.execute(contribution, context); assertEquals(2, itemReader.count); assertEquals("12", itemWriter.values); } @Test public void testHandleCompositeItem() throws Exception { - ItemOrientedStepHandler handler = new ItemOrientedStepHandler(itemReader, + ChunkOrientedTasklet handler = new ChunkOrientedTasklet(itemReader, new AgrgegateItemProcessor(), itemWriter, repeatTemplate); StepContribution contribution = new StepContribution(new StepExecution("foo", new JobExecution(new JobInstance( 123L, new JobParameters(), "job")))); - handler.handle(contribution, context); + handler.execute(contribution, context); assertEquals(2, itemReader.count); assertEquals("12", itemWriter.values); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepHandlerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryTaskletTests.java similarity index 87% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepHandlerTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryTaskletTests.java index 2ca038319..12465ddd8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepHandlerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryTaskletTests.java @@ -28,7 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.StepExecution; -import org.springframework.batch.core.step.item.SkipLimitStepFactoryBean.StatefulRetryStepHandler; +import org.springframework.batch.core.step.item.SkipLimitStepFactoryBean.StatefulRetryTasklet; import org.springframework.batch.core.step.skip.ItemSkipPolicy; import org.springframework.batch.core.step.skip.SkipLimitExceededException; import org.springframework.batch.core.step.tasklet.BasicAttributeAccessor; @@ -47,7 +47,7 @@ import org.springframework.batch.retry.support.RetryTemplate; * @author Dave Syer * */ -public class StatefulRetryStepHandlerTests { +public class StatefulRetryTaskletTests { private Log logger = LogFactory.getLog(getClass()); @@ -59,7 +59,7 @@ public class StatefulRetryStepHandlerTests { protected List written = new ArrayList(); - private StatefulRetryStepHandler handler; + private StatefulRetryTasklet handler; private RepeatTemplate chunkOperations = new RepeatTemplate(); @@ -101,16 +101,16 @@ public class StatefulRetryStepHandlerTests { @Test public void testBasicHandle() throws Exception { - handler = new StatefulRetryStepHandler(itemReader, itemProcessor, itemWriter, chunkOperations, + handler = new StatefulRetryTasklet(itemReader, itemProcessor, itemWriter, chunkOperations, retryTemplate, readSkipPolicy, writeSkipPolicy); StepContribution contribution = new StepExecution("foo", null).createStepContribution(); - handler.handle(contribution, new BasicAttributeAccessor()); + handler.execute(contribution, new BasicAttributeAccessor()); assertEquals(limit, contribution.getItemCount()); } @Test public void testSkipOnRead() throws Exception { - handler = new StatefulRetryStepHandler(new ItemReader() { + handler = new StatefulRetryTasklet(new ItemReader() { public Integer read() throws Exception, UnexpectedInputException, NoWorkFoundException, ParseException { throw new RuntimeException("Barf!"); } @@ -119,7 +119,7 @@ public class StatefulRetryStepHandlerTests { StepContribution contribution = new StepExecution("foo", null).createStepContribution(); BasicAttributeAccessor attributes = new BasicAttributeAccessor(); try { - handler.handle(contribution, attributes); + handler.execute(contribution, attributes); fail("Expected SkipLimitExceededException"); } catch (SkipLimitExceededException e) { @@ -131,7 +131,7 @@ public class StatefulRetryStepHandlerTests { @Test public void testSkipSingleItemOnWrite() throws Exception { - handler = new StatefulRetryStepHandler(itemReader, itemProcessor, new ItemWriter() { + handler = new StatefulRetryTasklet(itemReader, itemProcessor, new ItemWriter() { public void write(List items) throws Exception { written.addAll(items); throw new RuntimeException("Barf!"); @@ -141,14 +141,14 @@ public class StatefulRetryStepHandlerTests { StepContribution contribution = new StepExecution("foo", null).createStepContribution(); BasicAttributeAccessor attributes = new BasicAttributeAccessor(); try { - handler.handle(contribution, attributes); + handler.execute(contribution, attributes); fail("Expected RuntimeException"); } catch (Exception e) { assertEquals("Barf!", e.getMessage()); } assertTrue(attributes.hasAttribute("OUTPUT_BUFFER_KEY")); - handler.handle(contribution, attributes); + handler.execute(contribution, attributes); assertEquals(1, contribution.getItemCount()); assertEquals(1, contribution.getWriteSkipCount()); assertEquals(1, written.size()); @@ -156,7 +156,7 @@ public class StatefulRetryStepHandlerTests { @Test public void testSkipMultipleItems() throws Exception { - handler = new StatefulRetryStepHandler(itemReader, itemProcessor, new ItemWriter() { + handler = new StatefulRetryTasklet(itemReader, itemProcessor, new ItemWriter() { public void write(List items) throws Exception { logger.debug("Writing items: "+items); written.addAll(items); @@ -170,7 +170,7 @@ public class StatefulRetryStepHandlerTests { // Count to 3: (try + skip + skip) for (int i = 0; i < 3; i++) { try { - handler.handle(contribution, attributes); + handler.execute(contribution, attributes); fail("Expected RuntimeException on i="+i); } catch (Exception e) { @@ -182,18 +182,18 @@ public class StatefulRetryStepHandlerTests { Chunk chunk = (Chunk) attributes.getAttribute("OUTPUT_BUFFER_KEY"); assertEquals(1, chunk.getSkips().size()); // The last recovery for this chunk... - handler.handle(contribution, attributes); + handler.execute(contribution, attributes); attributes = new BasicAttributeAccessor(); try { - handler.handle(contribution, attributes); + handler.execute(contribution, attributes); fail("Expected RuntimeException on i="); } catch (Exception e) { assertEquals("Barf!", e.getMessage()); } try { - handler.handle(contribution, attributes); + handler.execute(contribution, attributes); fail("Expected SkipLimitExceededException"); } catch (SkipLimitExceededException e) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java similarity index 82% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapterTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java index 744da4d5d..1f8766491 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java @@ -21,12 +21,12 @@ import static org.junit.Assert.fail; import java.util.concurrent.Callable; import org.junit.Test; -import org.springframework.batch.core.step.tasklet.CallableStepHandlerAdapter; +import org.springframework.batch.core.step.tasklet.CallableTaskletAdapter; import org.springframework.batch.repeat.ExitStatus; -public class CallableStepHandlerAdapterTests { +public class CallableTaskletAdapterTests { - private CallableStepHandlerAdapter adapter = new CallableStepHandlerAdapter(); + private CallableTaskletAdapter adapter = new CallableTaskletAdapter(); @Test public void testHandle() throws Exception { @@ -35,7 +35,7 @@ public class CallableStepHandlerAdapterTests { return ExitStatus.FINISHED; } }); - assertEquals(ExitStatus.FINISHED, adapter.handle(null,null)); + assertEquals(ExitStatus.FINISHED, adapter.execute(null,null)); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java similarity index 95% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepIntegrationTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java index 2d5858991..d60490fa9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java @@ -39,7 +39,7 @@ import org.springframework.batch.core.repository.dao.MapJobExecutionDao; import org.springframework.batch.core.repository.dao.MapJobInstanceDao; import org.springframework.batch.core.repository.dao.MapStepExecutionDao; import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; -import org.springframework.batch.core.step.tasklet.StepHandlerStep; +import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; @@ -59,9 +59,9 @@ import org.springframework.transaction.support.TransactionSynchronizationManager */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/org/springframework/batch/core/repository/dao/sql-dao-test.xml") -public class StepHandlerStepIntegrationTests { +public class ChunkOrientedStepIntegrationTests { - private StepHandlerStep step; + private TaskletStep step; private Job job; @@ -92,7 +92,7 @@ public class StepHandlerStepIntegrationTests { jobRepositoryFactoryBean.afterPropertiesSet(); jobRepository = (JobRepository) jobRepositoryFactoryBean.getObject(); - step = new StepHandlerStep("stepName"); + step = new TaskletStep("stepName"); step.setJobRepository(jobRepository); step.setTransactionManager(transactionManager); RepeatTemplate template = new RepeatTemplate(); @@ -112,7 +112,7 @@ public class StepHandlerStepIntegrationTests { @Test public void testStatusForCommitFailedException() throws Exception { - step.setStepHandler(new SimpleStepHandler(getReader(new String[] { "a", "b", "c" }), + step.setTasklet(new SimpleChunkOrientedTasklet(getReader(new String[] { "a", "b", "c" }), new ItemWriter() { public void write(List data) throws Exception { TransactionSynchronizationManager diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleStepHandler.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleChunkOrientedTasklet.java similarity index 75% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleStepHandler.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleChunkOrientedTasklet.java index bf6f46bbc..9398dae10 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleStepHandler.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleChunkOrientedTasklet.java @@ -15,8 +15,8 @@ */ package org.springframework.batch.core.step.tasklet; -import org.springframework.batch.core.step.item.ItemOrientedStepHandler; -import org.springframework.batch.core.step.tasklet.StepHandler; +import org.springframework.batch.core.step.item.ChunkOrientedTasklet; +import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.support.PassthroughItemProcessor; @@ -25,13 +25,13 @@ import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; import org.springframework.batch.repeat.support.RepeatTemplate; /** - * Simplest possible implementation of {@link StepHandler} with no skipping or + * Simplest possible implementation of {@link Tasklet} with no skipping or * recovering or processing. Just delegates all calls to the provided * {@link ItemReader} and {@link ItemWriter}. * * @author Dave Syer */ -public class SimpleStepHandler extends ItemOrientedStepHandler { +public class SimpleChunkOrientedTasklet extends ChunkOrientedTasklet { /** * @@ -45,17 +45,17 @@ public class SimpleStepHandler extends ItemOrientedStepHandler { /** * Creates a {@link PassthroughItemProcessor} and uses it to create an - * instance of {@link ItemOrientedStepHandler}. + * instance of {@link ChunkOrientedTasklet}. */ - public SimpleStepHandler(ItemReader itemReader, ItemWriter itemWriter) { + public SimpleChunkOrientedTasklet(ItemReader itemReader, ItemWriter itemWriter) { super(itemReader, new PassthroughItemProcessor(), itemWriter, repeatTemplate); } /** * Creates a {@link PassthroughItemProcessor} and uses it to create an - * instance of {@link ItemOrientedStepHandler}. + * instance of {@link ChunkOrientedTasklet}. */ - public SimpleStepHandler(ItemReader itemReader, ItemWriter itemWriter, RepeatOperations repeatOperations) { + public SimpleChunkOrientedTasklet(ItemReader itemReader, ItemWriter itemWriter, RepeatOperations repeatOperations) { super(itemReader, new PassthroughItemProcessor(), itemWriter, repeatOperations); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java index 7cc3ffd91..5296c0d4f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java @@ -33,7 +33,7 @@ import org.springframework.batch.core.repository.dao.MapJobInstanceDao; import org.springframework.batch.core.repository.dao.MapStepExecutionDao; import org.springframework.batch.core.repository.support.SimpleJobRepository; import org.springframework.batch.core.step.StepExecutionSynchronizer; -import org.springframework.batch.core.step.tasklet.StepHandlerStep; +import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; @@ -42,7 +42,7 @@ import org.springframework.batch.support.transaction.ResourcelessTransactionMana public class StepExecutorInterruptionTests extends TestCase { - private StepHandlerStep step; + private TaskletStep step; private JobExecution jobExecution; @@ -59,7 +59,7 @@ public class StepExecutorInterruptionTests extends TestCase { new MapStepExecutionDao(), new MapExecutionContextDao()); JobSupport jobConfiguration = new JobSupport(); - step = new StepHandlerStep("interruptedStep"); + step = new TaskletStep("interruptedStep"); jobConfiguration.addStep(step); jobConfiguration.setBeanName("testJob"); jobExecution = jobRepository.createJobExecution(jobConfiguration, new JobParameters()); @@ -79,7 +79,7 @@ public class StepExecutorInterruptionTests extends TestCase { RepeatTemplate template = new RepeatTemplate(); // N.B, If we don't set the completion policy it might run forever template.setCompletionPolicy(new SimpleCompletionPolicy(2)); - step.setStepHandler(new SimpleStepHandler(new ItemReader() { + step.setTasklet(new SimpleChunkOrientedTasklet(new ItemReader() { public Object read() throws Exception { // do something non-trivial (and not Thread.sleep()) double foo = 1; @@ -116,7 +116,7 @@ public class StepExecutorInterruptionTests extends TestCase { Thread processingThread = createThread(stepExecution); - step.setStepHandler(new SimpleStepHandler(new ItemReader() { + step.setTasklet(new SimpleChunkOrientedTasklet(new ItemReader() { public Object read() throws Exception { return null; } @@ -153,7 +153,7 @@ public class StepExecutorInterruptionTests extends TestCase { public void testLockNotReleasedIfChunkFails() throws Exception { - step.setStepHandler(new SimpleStepHandler(new ItemReader() { + step.setTasklet(new SimpleChunkOrientedTasklet(new ItemReader() { public Object read() throws Exception { throw new RuntimeException("Planned!"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java index 2a1a97bb3..265678016 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; -import org.springframework.batch.core.step.tasklet.StepHandlerAdapter; +import org.springframework.batch.core.step.tasklet.MethodInvokingTaskletAdapter; import org.springframework.batch.repeat.ExitStatus; /** @@ -28,7 +28,7 @@ import org.springframework.batch.repeat.ExitStatus; */ public class StepHandlerAdapterTests { - private StepHandlerAdapter tasklet = new StepHandlerAdapter(); + private MethodInvokingTaskletAdapter tasklet = new MethodInvokingTaskletAdapter(); private Object result = null; public ExitStatus execute() { @@ -47,20 +47,20 @@ public class StepHandlerAdapterTests { @Test public void testExecuteWithExitStatus() throws Exception { tasklet.setTargetMethod("execute"); - assertEquals(ExitStatus.NOOP, tasklet.handle(null,null)); + assertEquals(ExitStatus.NOOP, tasklet.execute(null,null)); } @Test public void testMapResultWithNull() throws Exception { tasklet.setTargetMethod("process"); - assertEquals(ExitStatus.FINISHED, tasklet.handle(null,null)); + assertEquals(ExitStatus.FINISHED, tasklet.execute(null,null)); } @Test public void testMapResultWithNonNull() throws Exception { tasklet.setTargetMethod("process"); this.result = "foo"; - assertEquals(ExitStatus.FINISHED, tasklet.handle(null,null)); + assertEquals(ExitStatus.FINISHED, tasklet.execute(null,null)); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandlerIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java similarity index 88% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandlerIntegrationTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java index 5598b03f4..44b57c645 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandlerIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java @@ -16,19 +16,19 @@ import org.springframework.batch.core.JobInterruptedException; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.step.tasklet.SystemCommandException; -import org.springframework.batch.core.step.tasklet.SystemCommandStepHandler; +import org.springframework.batch.core.step.tasklet.SystemCommandTasklet; import org.springframework.batch.core.step.tasklet.SystemProcessExitCodeMapper; import org.springframework.batch.repeat.ExitStatus; import org.springframework.util.Assert; /** - * Tests for {@link SystemCommandStepHandler}. + * Tests for {@link SystemCommandTasklet}. */ -public class SystemCommandStepHandlerIntegrationTests { +public class SystemCommandTaskletIntegrationTests { - private static final Log log = LogFactory.getLog(SystemCommandStepHandlerIntegrationTests.class); + private static final Log log = LogFactory.getLog(SystemCommandTaskletIntegrationTests.class); - private SystemCommandStepHandler tasklet = new SystemCommandStepHandler(); + private SystemCommandTasklet tasklet = new SystemCommandTasklet(); private StepExecution stepExecution = new StepExecution("systemCommandStep", new JobExecution(new JobInstance( 1L, new JobParameters(), "systemCommandJob"))); @@ -56,7 +56,7 @@ public class SystemCommandStepHandlerIntegrationTests { tasklet.afterPropertiesSet(); log.info("Executing command: " + command); - ExitStatus exitStatus = tasklet.handle(null,null); + ExitStatus exitStatus = tasklet.execute(null,null); assertEquals(ExitStatus.FINISHED, exitStatus); } @@ -71,7 +71,7 @@ public class SystemCommandStepHandlerIntegrationTests { tasklet.afterPropertiesSet(); log.info("Executing command: " + command); - ExitStatus exitStatus = tasklet.handle(null,null); + ExitStatus exitStatus = tasklet.execute(null,null); assertEquals(ExitStatus.FAILED, exitStatus); } @@ -88,7 +88,7 @@ public class SystemCommandStepHandlerIntegrationTests { log.info("Executing command: " + command); try { - tasklet.handle(null,null); + tasklet.execute(null,null); fail(); } catch (SystemCommandException e) { @@ -108,7 +108,7 @@ public class SystemCommandStepHandlerIntegrationTests { stepExecution.setTerminateOnly(); try { - tasklet.handle(null,null); + tasklet.execute(null,null); fail(); } catch (JobInterruptedException e) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TasketStepTests.java similarity index 94% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TasketStepTests.java index 70108bccc..83063b72c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TasketStepTests.java @@ -47,7 +47,7 @@ import org.springframework.batch.core.repository.dao.MapStepExecutionDao; import org.springframework.batch.core.repository.support.SimpleJobRepository; import org.springframework.batch.core.step.JobRepositorySupport; import org.springframework.batch.core.step.StepInterruptionPolicy; -import org.springframework.batch.core.step.tasklet.StepHandlerStep; +import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; @@ -64,7 +64,7 @@ import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.transaction.TransactionException; import org.springframework.transaction.support.DefaultTransactionStatus; -public class StepHandlerStepTests { +public class TasketStepTests { List processed = new ArrayList(); @@ -76,7 +76,7 @@ public class StepHandlerStepTests { } }; - private StepHandlerStep step; + private TaskletStep step; private Job job; @@ -94,12 +94,12 @@ public class StepHandlerStepTests { return new ListItemReader(Arrays.asList(args)); } - private StepHandlerStep getStep(String[] strings) throws Exception { - StepHandlerStep step = new StepHandlerStep("stepName"); + private TaskletStep getStep(String[] strings) throws Exception { + TaskletStep step = new TaskletStep("stepName"); // Only process one item: RepeatTemplate template = new RepeatTemplate(); template.setCompletionPolicy(new SimpleCompletionPolicy(1)); - step.setStepHandler(new SimpleStepHandler(getReader(strings), itemWriter, template)); + step.setTasklet(new SimpleChunkOrientedTasklet(getReader(strings), itemWriter, template)); step.setJobRepository(new JobRepositorySupport()); step.setTransactionManager(transactionManager); return step; @@ -210,7 +210,7 @@ public class StepHandlerStepTests { }; - step.setStepHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); @@ -235,7 +235,7 @@ public class StepHandlerStepTests { }; - step.setStepHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); @@ -260,7 +260,7 @@ public class StepHandlerStepTests { }; - step.setStepHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(itemReader, itemWriter)); step.registerStepExecutionListener(new StepExecutionListenerSupport() { public ExitStatus onErrorInStep(StepExecution stepExecution, Throwable e) { return ExitStatus.FAILED.addExitDescription("FOO"); @@ -287,7 +287,7 @@ public class StepHandlerStepTests { @Test public void testNonRestartedJob() throws Exception { MockRestartableItemReader tasklet = new MockRestartableItemReader(); - step.setStepHandler(new SimpleStepHandler(tasklet, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(tasklet, itemWriter)); step.registerStream(tasklet); JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); @@ -348,7 +348,7 @@ public class StepHandlerStepTests { @Test public void testNoSaveExecutionAttributesRestartableJob() { MockRestartableItemReader tasklet = new MockRestartableItemReader(); - step.setStepHandler(new SimpleStepHandler(tasklet, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(tasklet, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); @@ -369,7 +369,7 @@ public class StepHandlerStepTests { */ @Test public void testRestartJobOnNonRestartableTasklet() throws Exception { - step.setStepHandler(new SimpleStepHandler(new ItemReader() { + step.setTasklet(new SimpleChunkOrientedTasklet(new ItemReader() { public String read() throws Exception { return "foo"; } @@ -391,7 +391,7 @@ public class StepHandlerStepTests { executionContext.putString("foo", "bar"); } }; - step.setStepHandler(new SimpleStepHandler(reader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(reader, itemWriter)); step.registerStream(reader); JobExecution jobExecution = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); @@ -491,7 +491,7 @@ public class StepHandlerStepTests { return null; } }); - step.setStepHandler(new SimpleStepHandler(new MockRestartableItemReader() { + step.setTasklet(new SimpleChunkOrientedTasklet(new MockRestartableItemReader() { public String read() throws Exception { throw new RuntimeException("FOO"); } @@ -519,7 +519,7 @@ public class StepHandlerStepTests { executionContext.putString("foo", "bar"); } }; - step.setStepHandler(new SimpleStepHandler(reader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(reader, itemWriter)); step.setStreams(new ItemStream[] { reader }); JobExecution jobExecution = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); @@ -554,7 +554,7 @@ public class StepHandlerStepTests { }; - step.setStepHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); @@ -582,7 +582,7 @@ public class StepHandlerStepTests { throw new RuntimeException("Foo"); } }; - step.setStepHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); @@ -610,7 +610,7 @@ public class StepHandlerStepTests { throw new Error("Foo"); } }; - step.setStepHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(itemReader, itemWriter)); JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); @@ -638,7 +638,7 @@ public class StepHandlerStepTests { throw new RuntimeException("Foo"); } }; - step.setStepHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(itemReader, itemWriter)); step.setTransactionManager(new ResourcelessTransactionManager() { protected void doRollback(DefaultTransactionStatus status) throws TransactionException { // Simulate failure on rollback when stream resets @@ -735,7 +735,7 @@ public class StepHandlerStepTests { throw new RuntimeException("Bar"); } }; - step.setStepHandler(new SimpleStepHandler(itemReader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(itemReader, itemWriter)); step.registerStream(itemReader); JobExecution jobExecutionContext = new JobExecution(jobInstance); @@ -773,7 +773,7 @@ public class StepHandlerStepTests { throw new RuntimeException("CRASH!"); } }; - step.setStepHandler(new SimpleStepHandler(reader, itemWriter)); + step.setTasklet(new SimpleChunkOrientedTasklet(reader, itemWriter)); step.registerStream(reader); StepExecution stepExecution = new StepExecution(step.getName(), new JobExecution(jobInstance)); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/job/TestStepHandler.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/job/TestTasklet.java similarity index 78% rename from spring-batch-integration/src/test/java/org/springframework/batch/integration/job/TestStepHandler.java rename to spring-batch-integration/src/test/java/org/springframework/batch/integration/job/TestTasklet.java index 065b4af40..ff5917177 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/job/TestStepHandler.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/job/TestTasklet.java @@ -16,7 +16,7 @@ package org.springframework.batch.integration.job; import org.springframework.batch.core.StepContribution; -import org.springframework.batch.core.step.tasklet.StepHandler; +import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.ExitStatus; import org.springframework.core.AttributeAccessor; @@ -24,13 +24,13 @@ import org.springframework.core.AttributeAccessor; * @author Dave Syer * */ -public class TestStepHandler implements StepHandler { +public class TestTasklet implements Tasklet { /* * (non-Javadoc) * */ - public ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception { + public ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception { return ExitStatus.FINISHED; } diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/launch/JobLaunchingMessageHandlerIntegrationTests-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/launch/JobLaunchingMessageHandlerIntegrationTests-context.xml index 02fea4840..cb8a5df78 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/launch/JobLaunchingMessageHandlerIntegrationTests-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/launch/JobLaunchingMessageHandlerIntegrationTests-context.xml @@ -33,9 +33,9 @@ - - - + + + diff --git a/spring-batch-integration/src/test/resources/simple-job-launcher-context.xml b/spring-batch-integration/src/test/resources/simple-job-launcher-context.xml index 849fe2b78..016653605 100644 --- a/spring-batch-integration/src/test/resources/simple-job-launcher-context.xml +++ b/spring-batch-integration/src/test/resources/simple-job-launcher-context.xml @@ -4,11 +4,11 @@ xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> - + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> + @@ -27,8 +27,7 @@ + class="org.springframework.batch.core.step.tasklet.TaskletStep" abstract="true"> diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageReceivingStepHandler.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageReceivingTasklet.java similarity index 69% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageReceivingStepHandler.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageReceivingTasklet.java index 62842b756..543b17815 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageReceivingStepHandler.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageReceivingTasklet.java @@ -5,7 +5,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.listener.StepExecutionListenerSupport; -import org.springframework.batch.core.step.tasklet.StepHandler; +import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; import org.springframework.core.AttributeAccessor; @@ -13,19 +13,19 @@ import org.springframework.core.AttributeAccessor; /** * Dummy tasklet that retrieves message from the job execution context. */ -public class DummyMessageReceivingStepHandler extends StepExecutionListenerSupport implements StepHandler { +public class DummyMessageReceivingTasklet extends StepExecutionListenerSupport implements Tasklet { - private static final Log logger = LogFactory.getLog(DummyMessageReceivingStepHandler.class); + private static final Log logger = LogFactory.getLog(DummyMessageReceivingTasklet.class); private String receivedMessage = null; public void beforeStep(StepExecution stepExecution) { ExecutionContext ctx = stepExecution.getJobExecution().getExecutionContext(); - receivedMessage = ctx.getString(DummyMessageSendingStepHandler.MESSAGE_KEY); + receivedMessage = ctx.getString(DummyMessageSendingTasklet.MESSAGE_KEY); logger.info("Got message from context: " + receivedMessage); } - public ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception { + public ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception { return ExitStatus.FINISHED; } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageSendingStepHandler.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageSendingTasklet.java similarity index 68% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageSendingStepHandler.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageSendingTasklet.java index 2166f99f3..8f8fcacd0 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageSendingStepHandler.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/DummyMessageSendingTasklet.java @@ -2,10 +2,11 @@ package org.springframework.batch.sample.tasklet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.derby.impl.sql.compile.GetCurrentConnectionNode; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.listener.StepExecutionListenerSupport; -import org.springframework.batch.core.step.tasklet.StepHandler; +import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; import org.springframework.core.AttributeAccessor; @@ -13,11 +14,11 @@ import org.springframework.core.AttributeAccessor; /** * Dummy tasklet that stores a message in the job execution context. */ -public class DummyMessageSendingStepHandler extends StepExecutionListenerSupport implements StepHandler { +public class DummyMessageSendingTasklet extends StepExecutionListenerSupport implements Tasklet { - private static final Log logger = LogFactory.getLog(DummyMessageSendingStepHandler.class); + private static final Log logger = LogFactory.getLog(DummyMessageSendingTasklet.class); - public static final String MESSAGE_KEY = "DummyMessageSendingStepHandler.MESSAGE"; + public static final String MESSAGE_KEY = DummyMessageSendingTasklet.class.getSimpleName()+".MESSAGE"; private String message = "Hello!"; @@ -28,7 +29,7 @@ public class DummyMessageSendingStepHandler extends StepExecutionListenerSupport return null; } - public ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception { + public ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception { return ExitStatus.FINISHED; } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/FileDeletingStepHandler.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/FileDeletingTasklet.java similarity index 78% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/FileDeletingStepHandler.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/FileDeletingTasklet.java index 8c2b30470..f4a8c942b 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/FileDeletingStepHandler.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/tasklet/FileDeletingTasklet.java @@ -2,7 +2,7 @@ package org.springframework.batch.sample.tasklet; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.UnexpectedJobExecutionException; -import org.springframework.batch.core.step.tasklet.StepHandler; +import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.AttributeAccessor; @@ -15,11 +15,11 @@ import org.springframework.util.Assert; * * @author Robert Kasanicky */ -public class FileDeletingStepHandler implements StepHandler, InitializingBean { +public class FileDeletingTasklet implements Tasklet, InitializingBean { private Resource[] resources; - public ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception { + public ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception { for (Resource resource : resources) { boolean deleted = resource.getFile().delete(); if (!deleted) { diff --git a/spring-batch-samples/src/main/resources/jobs/jobExecutionContextSample.xml b/spring-batch-samples/src/main/resources/jobs/jobExecutionContextSample.xml index c91314214..b47a82eee 100644 --- a/spring-batch-samples/src/main/resources/jobs/jobExecutionContextSample.xml +++ b/spring-batch-samples/src/main/resources/jobs/jobExecutionContextSample.xml @@ -12,21 +12,21 @@ - + - + + class="org.springframework.batch.sample.tasklet.DummyMessageSendingTasklet"> + class="org.springframework.batch.sample.tasklet.DummyMessageReceivingTasklet" /> diff --git a/spring-batch-samples/src/main/resources/jobs/taskletJob.xml b/spring-batch-samples/src/main/resources/jobs/taskletJob.xml index 6e9bfd67b..4ad469200 100644 --- a/spring-batch-samples/src/main/resources/jobs/taskletJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/taskletJob.xml @@ -17,15 +17,15 @@ - - + + - - + + diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/config/common-context.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/config/common-context.xml index b67814229..7d67fac65 100644 --- a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/config/common-context.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -12,7 +12,7 @@ - + diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobExecutionContextSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobExecutionContextSampleFunctionalTests.java index beb5001f5..e02821902 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobExecutionContextSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobExecutionContextSampleFunctionalTests.java @@ -3,8 +3,8 @@ package org.springframework.batch.sample; import static org.junit.Assert.assertEquals; import org.junit.runner.RunWith; -import org.springframework.batch.sample.tasklet.DummyMessageReceivingStepHandler; -import org.springframework.batch.sample.tasklet.DummyMessageSendingStepHandler; +import org.springframework.batch.sample.tasklet.DummyMessageReceivingTasklet; +import org.springframework.batch.sample.tasklet.DummyMessageSendingTasklet; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -14,10 +14,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; public class JobExecutionContextSampleFunctionalTests extends AbstractValidatingBatchLauncherTests { @Autowired - private DummyMessageSendingStepHandler sender; + private DummyMessageSendingTasklet sender; @Autowired - private DummyMessageReceivingStepHandler receiver; + private DummyMessageReceivingTasklet receiver; protected void validatePostConditions() throws Exception { assertEquals(sender.getMessage(), receiver.getReceivedMessage());