|
||||||||||
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(ItemProcessor<? super I,? extends O> itemProcessor,
ItemWriter<? super O> itemWriter)
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Check mandatory properties. |
protected void |
doAfterWrite(List<O> items)
Call the listener's after write method. |
protected O |
doProcess(I item)
|
protected void |
doWrite(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(ItemProcessor<? super I,? extends O> itemProcessor)
|
void |
setItemWriter(ItemWriter<? super O> itemWriter)
|
void |
setListeners(List<? extends StepListener> listeners)
Register some StepListener s 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(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(ItemProcessor<? super I,? extends O> itemProcessor, ItemWriter<? super O> itemWriter)
Method Detail |
---|
public void setItemProcessor(ItemProcessor<? super I,? extends O> itemProcessor)
itemProcessor
- the ItemProcessor
to setpublic void setItemWriter(ItemWriter<? super O> itemWriter)
itemWriter
- the ItemWriter
to setpublic void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
InitializingBean.afterPropertiesSet()
public void setListeners(List<? extends StepListener> listeners)
StepListener
s with the handler. Each will get the
callbacks in the order specified at the correct stage.
listeners
- public void registerListener(StepListener listener)
listener
- a StepListener
protected MulticasterBatchListener<I,O> getListener()
protected final O doProcess(I item) throws Exception
item
- the input item
Exception
protected final void doWrite(List<O> items) throws Exception
items
-
Exception
protected final void doAfterWrite(List<O> items)
items
- protected void writeItems(List<O> items) throws Exception
Exception
public final void process(StepContribution contribution, Chunk<I> inputs) throws Exception
process
in interface ChunkProcessor<I>
Exception
protected 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 processprotected 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 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
Exception
- if there is a problemprotected Chunk<O> transform(StepContribution contribution, Chunk<I> inputs) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |