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 0bf0ba10b..115c41699 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 @@ -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.handler.StepHandler; +import org.springframework.batch.core.step.tasklet.StepHandler; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; @@ -114,7 +114,7 @@ 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.handler.StepHandler#handle(org.springframework.batch.core.StepContribution, + * @see org.springframework.batch.core.step.tasklet.StepHandler#handle(org.springframework.batch.core.StepContribution, * AttributeAccessor) */ public ExitStatus handle(final StepContribution contribution, AttributeAccessor attributes) throws Exception { 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 74a6ca9f7..c334b101c 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.handler.StepHandlerStep; +import org.springframework.batch.core.step.tasklet.StepHandlerStep; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; 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 c7afc42ec..d346af677 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 @@ -9,11 +9,11 @@ import java.util.List; import org.springframework.batch.core.SkipListener; import org.springframework.batch.core.StepContribution; -import org.springframework.batch.core.step.handler.StepHandlerStep; 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.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/BasicAttributeAccessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/BasicAttributeAccessor.java similarity index 75% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/BasicAttributeAccessor.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/BasicAttributeAccessor.java index bc9e51632..874500af4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/BasicAttributeAccessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/BasicAttributeAccessor.java @@ -1,4 +1,4 @@ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import org.springframework.core.AttributeAccessorSupport; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/CallableStepHandlerAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapter.java similarity index 97% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/CallableStepHandlerAdapter.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapter.java index d1d7c0da3..1338ef1f3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/CallableStepHandlerAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import java.util.concurrent.Callable; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/ConfigurableSystemProcessExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java similarity index 92% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/ConfigurableSystemProcessExitCodeMapper.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java index a690dfcdb..67da87557 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/ConfigurableSystemProcessExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java @@ -1,4 +1,4 @@ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import java.util.Map; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SimpleSystemProcessExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java similarity index 86% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SimpleSystemProcessExitCodeMapper.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java index 715b72e78..7415a38a1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SimpleSystemProcessExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java @@ -1,4 +1,4 @@ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import org.springframework.batch.repeat.ExitStatus; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/StepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandler.java similarity index 97% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/StepHandler.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandler.java index e65d7e524..9c771fcab 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/StepHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandler.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import org.springframework.batch.core.StepContribution; import org.springframework.batch.item.ItemReader; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/StepHandlerAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapter.java similarity index 97% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/StepHandlerAdapter.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapter.java index 3865c4f89..f11b5a395 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/StepHandlerAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import org.springframework.batch.core.StepContribution; import org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/StepHandlerStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerStep.java similarity index 95% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/StepHandlerStep.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerStep.java index d5a68fff2..f3139dfd7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/StepHandlerStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/StepHandlerStep.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import java.util.Queue; import java.util.concurrent.LinkedBlockingQueue; @@ -25,6 +25,7 @@ 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; @@ -82,6 +83,13 @@ public class StepHandlerStep extends AbstractStep { private StepExecutionSynchronizer synchronizer; + /** + * Default constructor. + */ + public StepHandlerStep() { + this(null); + } + /** * @param name */ @@ -114,6 +122,9 @@ public class StepHandlerStep extends AbstractStep { */ public void setStepHandler(StepHandler stepHandler) { this.stepHandler = stepHandler; + if (stepHandler instanceof StepExecutionListener) { + registerStepExecutionListener((StepExecutionListener) stepHandler); + } } /** @@ -195,9 +206,9 @@ public class StepHandlerStep extends AbstractStep { * Process the step and update its context so that progress can be monitored * by the caller. The step is broken down into chunks, each one executing in * a transaction. The step and its execution and execution context are all - * given an up to date {@link BatchStatus}, and the {@link JobRepository} is - * used to store the result. Various reporting information are also added to - * the current context (the {@link RepeatContext} governing the step + * given an up to date {@link BatchStatus}, and the {@link JobRepository} + * is used to store the result. Various reporting information are also added + * to the current context (the {@link RepeatContext} governing the step * execution, which would normally be available to the caller somehow * through the step's {@link ExecutionContext}.
* @@ -369,8 +380,8 @@ public class StepHandlerStep extends AbstractStep { } catch (Exception e) { /* - * If we already failed to commit, it doesn't help to do this again - * - it's better to allow the CommitFailedException to propagate + * If we already failed to commit, it doesn't help to do this again - + * it's better to allow the CommitFailedException to propagate */ if (!fatalException.hasException()) { fatalException.setException(e); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SystemCommandException.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandException.java similarity index 84% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SystemCommandException.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandException.java index d4e11dacc..c5a234612 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SystemCommandException.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandException.java @@ -1,4 +1,4 @@ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; /** * Exception indicating failed execution of system command. diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SystemCommandStepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandler.java similarity index 96% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SystemCommandStepHandler.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandler.java index b3103e0eb..9c920b507 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SystemCommandStepHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandler.java @@ -1,4 +1,4 @@ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import java.io.File; import java.io.IOException; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SystemProcessExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemProcessExitCodeMapper.java similarity index 79% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SystemProcessExitCodeMapper.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemProcessExitCodeMapper.java index 7705f956e..b4ea518a3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/SystemProcessExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemProcessExitCodeMapper.java @@ -1,6 +1,6 @@ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; -import org.springframework.batch.core.step.handler.SystemCommandStepHandler; +import org.springframework.batch.core.step.tasklet.SystemCommandStepHandler; import org.springframework.batch.repeat.ExitStatus; /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/package.html b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/package.html similarity index 100% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/handler/package.html rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/package.html 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/StatefulRetryStepHandlerTests.java index 5f7c0f4ac..2ca038319 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/StatefulRetryStepHandlerTests.java @@ -28,10 +28,10 @@ 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.handler.BasicAttributeAccessor; import org.springframework.batch.core.step.item.SkipLimitStepFactoryBean.StatefulRetryStepHandler; import org.springframework.batch.core.step.skip.ItemSkipPolicy; import org.springframework.batch.core.step.skip.SkipLimitExceededException; +import org.springframework.batch.core.step.tasklet.BasicAttributeAccessor; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/CallableStepHandlerAdapterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapterTests.java similarity index 91% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/CallableStepHandlerAdapterTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapterTests.java index 153f2235b..744da4d5d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/CallableStepHandlerAdapterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableStepHandlerAdapterTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -21,6 +21,7 @@ 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.repeat.ExitStatus; public class CallableStepHandlerAdapterTests { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/ConfigurableSystemProcessExitCodeMapperTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapperTests.java similarity index 91% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/ConfigurableSystemProcessExitCodeMapperTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapperTests.java index f7b67be76..7f7310105 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/ConfigurableSystemProcessExitCodeMapperTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapperTests.java @@ -1,4 +1,4 @@ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; @@ -7,7 +7,7 @@ import java.util.HashMap; import java.util.Map; import org.junit.Test; -import org.springframework.batch.core.step.handler.ConfigurableSystemProcessExitCodeMapper; +import org.springframework.batch.core.step.tasklet.ConfigurableSystemProcessExitCodeMapper; import org.springframework.batch.repeat.ExitStatus; /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/SimpleStepHandler.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleStepHandler.java similarity index 95% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/SimpleStepHandler.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleStepHandler.java index 438326791..bf6f46bbc 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/SimpleStepHandler.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleStepHandler.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; -import org.springframework.batch.core.step.handler.StepHandler; import org.springframework.batch.core.step.item.ItemOrientedStepHandler; +import org.springframework.batch.core.step.tasklet.StepHandler; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.support.PassthroughItemProcessor; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/SimpleSystemProcessExitCodeMapperTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapperTests.java similarity index 79% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/SimpleSystemProcessExitCodeMapperTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapperTests.java index f98f66203..36bc2928f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/SimpleSystemProcessExitCodeMapperTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapperTests.java @@ -1,8 +1,9 @@ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.springframework.batch.core.step.tasklet.SimpleSystemProcessExitCodeMapper; import org.springframework.batch.repeat.ExitStatus; /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java similarity index 98% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepExecutorInterruptionTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java index dc8d29203..7cc3ffd91 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import java.util.List; @@ -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.handler.StepHandlerStep; +import org.springframework.batch.core.step.tasklet.StepHandlerStep; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepHandlerAdapterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java similarity index 93% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepHandlerAdapterTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java index 6c83b52d2..2a1a97bb3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepHandlerAdapterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerAdapterTests.java @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; 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.repeat.ExitStatus; /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepHandlerStepIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepIntegrationTests.java similarity index 98% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepHandlerStepIntegrationTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepIntegrationTests.java index ab1dcd8df..2d5858991 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepHandlerStepIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepIntegrationTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -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.handler.StepHandlerStep; +import org.springframework.batch.core.step.tasklet.StepHandlerStep; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepHandlerStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepTests.java similarity index 99% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepHandlerStepTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepTests.java index d2d9a9685..70108bccc 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/StepHandlerStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepHandlerStepTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -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.handler.StepHandlerStep; +import org.springframework.batch.core.step.tasklet.StepHandlerStep; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/SystemCommandStepHandlerIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandlerIntegrationTests.java similarity index 91% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/SystemCommandStepHandlerIntegrationTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandlerIntegrationTests.java index 32c315dac..5598b03f4 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/handler/SystemCommandStepHandlerIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandStepHandlerIntegrationTests.java @@ -1,4 +1,4 @@ -package org.springframework.batch.core.step.handler; +package org.springframework.batch.core.step.tasklet; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -15,6 +15,9 @@ import org.springframework.batch.core.JobInstance; 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.SystemProcessExitCodeMapper; import org.springframework.batch.repeat.ExitStatus; import org.springframework.util.Assert; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java index e1269186b..f68ac91bd 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/retry/support/RetryTemplate.java @@ -44,7 +44,7 @@ import org.springframework.batch.retry.policy.SimpleRetryPolicy; * Template class that simplifies the execution of operations with retry * semantics.
Retryable operations are encapsulated in implementations of * the {@link RetryCallback} interface and are executed using one of the - * supplied {@link #execute} methods.
+ * supplied execute methods.
* * By default, an operation is retried if is throws any {@link Exception} or * subclass of {@link Exception}. This behaviour can be changed by using the 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/TestStepHandler.java index 1192b7695..065b4af40 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/TestStepHandler.java @@ -16,7 +16,7 @@ package org.springframework.batch.integration.job; import org.springframework.batch.core.StepContribution; -import org.springframework.batch.core.step.handler.StepHandler; +import org.springframework.batch.core.step.tasklet.StepHandler; import org.springframework.batch.repeat.ExitStatus; import org.springframework.core.AttributeAccessor; diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/job/MessageOrientedStepIntegrationTests-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/job/MessageOrientedStepIntegrationTests-context.xml index 7db883bac..3c4fb06a0 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/job/MessageOrientedStepIntegrationTests-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/job/MessageOrientedStepIntegrationTests-context.xml @@ -1,47 +1,47 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 3f62638e6..849fe2b78 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 @@ -26,8 +26,8 @@ - diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ItemTrackingItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ItemTrackingItemWriter.java index 95d6bfc7c..7d34c6daf 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ItemTrackingItemWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ItemTrackingItemWriter.java @@ -12,16 +12,22 @@ import org.springframework.batch.item.validator.ValidationException; public class ItemTrackingItemWriter implements ItemWriter { private List items = new ArrayList(); + + private T failed = null; private int failure = -1; private int counter = 0; - public void write(List item) throws Exception { - items.addAll(item); + public void write(List items) throws Exception { + if (failed!=null && items.contains(failed)) { + throw new ValidationException("validation failed"); + } + this.items.addAll(items); int current = counter; - counter += item.size(); + counter += items.size(); if (current < failure && counter >= failure) { + failed = items.get(failure-current-1); throw new ValidationException("validation failed"); } } 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/DummyMessageReceivingStepHandler.java index f7232d576..62842b756 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/DummyMessageReceivingStepHandler.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.handler.StepHandler; +import org.springframework.batch.core.step.tasklet.StepHandler; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; import org.springframework.core.AttributeAccessor; 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/DummyMessageSendingStepHandler.java index 063dca467..2166f99f3 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/DummyMessageSendingStepHandler.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.handler.StepHandler; +import org.springframework.batch.core.step.tasklet.StepHandler; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.repeat.ExitStatus; import org.springframework.core.AttributeAccessor; 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/FileDeletingStepHandler.java index ebab984d1..8c2b30470 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/FileDeletingStepHandler.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.handler.StepHandler; +import org.springframework.batch.core.step.tasklet.StepHandler; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.AttributeAccessor; diff --git a/spring-batch-samples/src/main/resources/jobs/jobExecutionContextSample.xml b/spring-batch-samples/src/main/resources/jobs/jobExecutionContextSample.xml index e583906e6..c91314214 100644 --- a/spring-batch-samples/src/main/resources/jobs/jobExecutionContextSample.xml +++ b/spring-batch-samples/src/main/resources/jobs/jobExecutionContextSample.xml @@ -11,11 +11,11 @@ - - + + - - + + diff --git a/spring-batch-samples/src/main/resources/jobs/handlerJob.xml b/spring-batch-samples/src/main/resources/jobs/taskletJob.xml similarity index 77% rename from spring-batch-samples/src/main/resources/jobs/handlerJob.xml rename to spring-batch-samples/src/main/resources/jobs/taskletJob.xml index a7fb8c326..6e9bfd67b 100644 --- a/spring-batch-samples/src/main/resources/jobs/handlerJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/taskletJob.xml @@ -13,19 +13,19 @@ The second step illustrates executing a system command. - + - - + + - + - - - + + + 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 46bb2c154..b67814229 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 @@ -2,17 +2,17 @@ - + 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"> + - + diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/HandlerJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/TaskletJobFunctionalTests.java similarity index 92% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/HandlerJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/TaskletJobFunctionalTests.java index b495041f1..174ca7d1a 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/HandlerJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/TaskletJobFunctionalTests.java @@ -17,7 +17,7 @@ import org.springframework.util.Assert; */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration() -public class HandlerJobFunctionalTests extends AbstractValidatingBatchLauncherTests { +public class TaskletJobFunctionalTests extends AbstractValidatingBatchLauncherTests { private Resource directory = new FileSystemResource("target/test-outputs/test-dir"); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/support/ItemTrackingItemWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/support/ItemTrackingItemWriterTests.java new file mode 100644 index 000000000..14968ff10 --- /dev/null +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/support/ItemTrackingItemWriterTests.java @@ -0,0 +1,67 @@ +/* + * Copyright 2006-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.batch.sample.support; + +import static org.junit.Assert.*; + +import java.util.Arrays; + +import org.junit.Test; +import org.springframework.batch.item.validator.ValidationException; + +/** + * @author Dave Syer + * + */ +public class ItemTrackingItemWriterTests { + + private ItemTrackingItemWriter writer = new ItemTrackingItemWriter(); + + /** + * Test method for {@link org.springframework.batch.sample.support.ItemTrackingItemWriter#write(java.util.List)}. + * @throws Exception + */ + @Test + public void testWrite() throws Exception { + assertEquals(0, writer.getItems().size()); + writer.write(Arrays.asList("a", "b", "c")); + assertEquals(3, writer.getItems().size()); + } + + @Test + public void testValidationFailure() throws Exception { + writer.setValidationFailure(2); + try { + writer.write(Arrays.asList("a", "b", "c")); + fail("Expected ValidationException"); + } + catch (ValidationException e) { + // expected + } + assertEquals(3, writer.getItems().size()); + writer.write(Arrays.asList("a", "e", "c")); + assertEquals(6, writer.getItems().size()); + try { + writer.write(Arrays.asList("f", "b", "g")); + fail("Expected ValidationException"); + } + catch (ValidationException e) { + // expected + } + assertEquals(6, writer.getItems().size()); + } + +} diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/HandlerJobFunctionalTests-context.xml b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/TaskletJobFunctionalTests-context.xml similarity index 85% rename from spring-batch-samples/src/test/resources/org/springframework/batch/sample/HandlerJobFunctionalTests-context.xml rename to spring-batch-samples/src/test/resources/org/springframework/batch/sample/TaskletJobFunctionalTests-context.xml index 132306802..71285d6a8 100644 --- a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/HandlerJobFunctionalTests-context.xml +++ b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/TaskletJobFunctionalTests-context.xml @@ -5,6 +5,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> - + \ No newline at end of file