|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.batch.core.step.item.SimpleChunkProcessor<I,O>
public class SimpleChunkProcessor<I,O>
Simple implementation of the ChunkProcessor interface that handles
basic item writing and processing. Any exceptions encountered will be
rethrown.
ChunkOrientedTasklet| Constructor Summary | |
|---|---|
SimpleChunkProcessor(org.springframework.batch.item.ItemProcessor<? super I,? extends O> itemProcessor,
org.springframework.batch.item.ItemWriter<? super O> itemWriter)
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Check mandatory properties. |
protected void |
doAfterWrite(java.util.List<O> items)
Call the listener's after write method. |
protected O |
doProcess(I item)
|
protected void |
doWrite(java.util.List<O> items)
Surrounds the actual write call with listener callbacks. |
protected Chunk<O> |
getAdjustedOutputs(Chunk<I> inputs,
Chunk<O> outputs)
Extension point for subclasses that want to adjust the outputs based on additional saved data in the inputs. |
protected int |
getFilterCount(Chunk<I> inputs,
Chunk<O> outputs)
Extension point for subclasses to calculate the filter count. |
protected MulticasterBatchListener<I,O> |
getListener()
|
protected void |
initializeUserData(Chunk<I> inputs)
Extension point for subclasses to allow them to memorise the contents of the inputs, in case they are needed for accounting purposes later. |
protected boolean |
isComplete(Chunk<I> inputs)
Extension point for subclasses that want to store additional data in the inputs. |
void |
process(StepContribution contribution,
Chunk<I> inputs)
|
void |
registerListener(StepListener listener)
Register a listener for callbacks at the appropriate stages in a process. |
void |
setItemProcessor(org.springframework.batch.item.ItemProcessor<? super I,? extends O> itemProcessor)
|
void |
setItemWriter(org.springframework.batch.item.ItemWriter<? super O> itemWriter)
|
void |
setListeners(java.util.List<? extends StepListener> listeners)
Register some StepListeners with the handler. |
protected Chunk<O> |
transform(StepContribution contribution,
Chunk<I> inputs)
|
protected void |
write(StepContribution contribution,
Chunk<I> inputs,
Chunk<O> outputs)
Simple implementation delegates to the doWrite(List) method and
increments the write count in the contribution. |
protected void |
writeItems(java.util.List<O> items)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleChunkProcessor(org.springframework.batch.item.ItemProcessor<? super I,? extends O> itemProcessor,
org.springframework.batch.item.ItemWriter<? super O> itemWriter)
| Method Detail |
|---|
public void setItemProcessor(org.springframework.batch.item.ItemProcessor<? super I,? extends O> itemProcessor)
itemProcessor - the ItemProcessor to setpublic void setItemWriter(org.springframework.batch.item.ItemWriter<? super O> itemWriter)
itemWriter - the ItemWriter to set
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.ExceptionInitializingBean.afterPropertiesSet()public void setListeners(java.util.List<? extends StepListener> listeners)
StepListeners with the handler. Each will get the
callbacks in the order specified at the correct stage.
listeners - public void registerListener(StepListener listener)
listener - a StepListenerprotected MulticasterBatchListener<I,O> getListener()
protected final O doProcess(I item)
throws java.lang.Exception
item - the input item
java.lang.Exception
protected final void doWrite(java.util.List<O> items)
throws java.lang.Exception
items -
java.lang.Exceptionprotected final void doAfterWrite(java.util.List<O> items)
items -
protected void writeItems(java.util.List<O> items)
throws java.lang.Exception
java.lang.Exception
public final void process(StepContribution contribution,
Chunk<I> inputs)
throws java.lang.Exception
process in interface ChunkProcessor<I>java.lang.Exceptionprotected void initializeUserData(Chunk<I> inputs)
isComplete(Chunk), getFilterCount(Chunk, Chunk) and
getAdjustedOutputs(Chunk, Chunk) might also need to be, to
ensure that the user data is handled consistently.
inputs - the inputs for the process
protected int getFilterCount(Chunk<I> inputs,
Chunk<O> outputs)
inputs - the inputs after transformationoutputs - the outputs after transformation
initializeUserData(Chunk)protected boolean isComplete(Chunk<I> inputs)
inputs - the input chunk
initializeUserData(Chunk)
protected Chunk<O> getAdjustedOutputs(Chunk<I> inputs,
Chunk<O> outputs)
inputs - the inputs for the transformationoutputs - the result of the transformation
initializeUserData(Chunk)
protected void write(StepContribution contribution,
Chunk<I> inputs,
Chunk<O> outputs)
throws java.lang.Exception
doWrite(List) method and
increments the write count in the contribution. Subclasses can handle
more complicated scenarios, e.g.with fault tolerance. If output items are
skipped they should be removed from the inputs as well.
contribution - the current step contributioninputs - the inputs that gave rise to the ouputsoutputs - the outputs to write
java.lang.Exception - if there is a problem
protected Chunk<O> transform(StepContribution contribution,
Chunk<I> inputs)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||