IN PROGRESS - BATCH-666: consolidate duplications in SimpleStepFactoryBean and RepeatOperationsStepFactoryBean

pulled up streams config
This commit is contained in:
robokaso
2008-06-13 09:04:33 +00:00
parent 49640faef5
commit 09d681c8dc
3 changed files with 16 additions and 29 deletions

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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();