From 09d681c8dc3a2b159396a89ddc8a07b8a9a067f8 Mon Sep 17 00:00:00 2001 From: robokaso Date: Fri, 13 Jun 2008 09:04:33 +0000 Subject: [PATCH] IN PROGRESS - BATCH-666: consolidate duplications in SimpleStepFactoryBean and RepeatOperationsStepFactoryBean pulled up streams config --- .../core/step/item/AbstractStepFactoryBean.java | 16 ++++++++++++++++ .../item/RepeatOperationsStepFactoryBean.java | 14 -------------- .../core/step/item/SimpleStepFactoryBean.java | 15 --------------- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/AbstractStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/AbstractStepFactoryBean.java index 24a70f0a3..b4b21d4c3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/AbstractStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/AbstractStepFactoryBean.java @@ -18,6 +18,7 @@ package org.springframework.batch.core.step.item; import org.springframework.batch.core.Step; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.item.ItemReader; +import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.validator.Validator; import org.springframework.beans.factory.BeanNameAware; @@ -52,6 +53,8 @@ public abstract class AbstractStepFactoryBean implements FactoryBean, BeanNameAw private boolean singleton = true; private Validator jobRepositoryValidator = new TransactionInterceptorValidator(1); + + private ItemStream[] streams = new ItemStream[0]; /** * @@ -109,6 +112,17 @@ public abstract class AbstractStepFactoryBean implements FactoryBean, BeanNameAw public void setItemWriter(ItemWriter itemWriter) { this.itemWriter = itemWriter; } + + /** + * The streams to inject into the {@link Step}. Any instance of + * {@link ItemStream} can be used, and will then receive callbacks at the + * appropriate stage in the step. + * + * @param streams an array of listeners + */ + public void setStreams(ItemStream[] streams) { + this.streams = streams; + } /** * Protected getter for the {@link ItemReader} for subclasses to use. @@ -171,6 +185,8 @@ public abstract class AbstractStepFactoryBean implements FactoryBean, BeanNameAw step.setJobRepository(jobRepository); step.setStartLimit(startLimit); step.setAllowStartIfComplete(allowStartIfComplete); + + step.setStreams(streams); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBean.java index 13b04607e..399ed3e80 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBean.java @@ -34,24 +34,12 @@ import org.springframework.batch.repeat.support.RepeatTemplate; */ public class RepeatOperationsStepFactoryBean extends AbstractStepFactoryBean { - private ItemStream[] streams = new ItemStream[0]; - private StepListener[] listeners = new StepListener[0]; private RepeatOperations chunkOperations = new RepeatTemplate(); private RepeatOperations stepOperations = new RepeatTemplate(); - /** - * The streams to inject into the {@link Step}. Any instance of - * {@link ItemStream} can be used, and will then receive callbacks at the - * appropriate stage in the step. - * - * @param streams an array of listeners - */ - public void setStreams(ItemStream[] streams) { - this.streams = streams; - } /** * The listeners to inject into the {@link Step}. Any instance of @@ -94,8 +82,6 @@ public class RepeatOperationsStepFactoryBean extends AbstractStepFactoryBean { super.applyConfiguration(step); - step.setStreams(streams); - ItemReader itemReader = getItemReader(); ItemWriter itemWriter = getItemWriter(); 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 d4413796e..77adf372e 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 @@ -52,8 +52,6 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean { private int commitInterval = 0; - private ItemStream[] streams = new ItemStream[0]; - private StepListener[] listeners = new StepListener[0]; private TaskExecutor taskExecutor; @@ -90,17 +88,6 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean { this.chunkCompletionPolicy = chunkCompletionPolicy; } - /** - * The streams to inject into the {@link Step}. Any instance of - * {@link ItemStream} can be used, and will then receive callbacks at the - * appropriate stage in the step. - * - * @param streams an array of listeners - */ - public void setStreams(ItemStream[] streams) { - this.streams = streams; - } - /** * The listeners to inject into the {@link Step}. Any instance of * {@link StepListener} can be used, and will then receive callbacks at the @@ -188,8 +175,6 @@ public class SimpleStepFactoryBean extends AbstractStepFactoryBean { super.applyConfiguration(step); - step.setStreams(streams); - ItemReader itemReader = getItemReader(); ItemWriter itemWriter = getItemWriter();