From acbc1d89edb3f0440e8de6c27c40a840cd7357eb Mon Sep 17 00:00:00 2001 From: dsyer Date: Thu, 17 Jul 2008 11:33:55 +0000 Subject: [PATCH] CLOSED - issue BATCH-563: ItemOrientedStep can be TaskletStep + ItemOrientedTasklet --- .../batch/core/step/AbstractStep.java | 30 +++++++++++++++++-- .../batch/core/step/tasklet/TaskletStep.java | 10 ------- .../integration/job/MessageOrientedStep.java | 18 ----------- 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java index aa8d57172..3d267aa30 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java @@ -140,11 +140,37 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw this.name = name; } + /** + * Extension point for subclasses to execute business logic. + * + * @param stepExecution + * @return {@link ExitStatus} to show whether the step is finished + * processing. + * @throws Exception + */ protected abstract ExitStatus doExecute(StepExecution stepExecution) throws Exception; - protected abstract void open(ExecutionContext ctx) throws Exception; + /** + * Extension point for subclasses to provide callbacks to their + * collaborators at the beginning of a step, to open or acquire resources. + * Does nothing by default. + * + * @param ctx the {@link ExecutionContext} to use + * @throws Exception + */ + protected void open(ExecutionContext ctx) throws Exception { + } - protected abstract void close(ExecutionContext ctx) throws Exception; + /** + * Extension point for subclasses to provide callbacks to their + * collaborators at the end of a step (right at the end of the finally + * block), to close or release resources. Does nothing by default. + * + * @param ctx the {@link ExecutionContext} to use + * @throws Exception + */ + protected void close(ExecutionContext ctx) throws Exception { + } /** * Template method for step execution logic - calls abstract methods for diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java index be247839d..5f76fe12d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java @@ -98,14 +98,4 @@ public class TaskletStep extends AbstractStep { return tasklet.execute(); } - protected void close(ExecutionContext ctx) throws Exception { - } - - protected void open(ExecutionContext ctx) throws Exception { - } - - - - - } diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/job/MessageOrientedStep.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/job/MessageOrientedStep.java index 0aa41a53d..40e65e733 100644 --- a/spring-batch-integration/src/main/java/org/springframework/batch/integration/job/MessageOrientedStep.java +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/job/MessageOrientedStep.java @@ -120,24 +120,6 @@ public class MessageOrientedStep extends AbstractStep { } - /** - * Do nothing. - * - * @see org.springframework.batch.core.step.AbstractStep#open(org.springframework.batch.item.ExecutionContext) - */ - @Override - protected void open(ExecutionContext ctx) throws Exception { - } - - /** - * Do nothing. - * - * @see org.springframework.batch.core.step.AbstractStep#close(org.springframework.batch.item.ExecutionContext) - */ - @Override - protected void close(ExecutionContext ctx) throws Exception { - } - /** * @param expectedJobId */