I
- The input type for the stepO
- The output type for the steppublic class JsrChunkProcessor<I,O> extends java.lang.Object implements ChunkProcessor<I>
ChunkProcessor
implementation that implements JSR-352's chunking pattern
(read and process in a loop until the chunk is complete then write). This
implementation is responsible for all three phases of chunk based processing
(reading, processing and writing).Constructor and Description |
---|
JsrChunkProcessor() |
JsrChunkProcessor(ItemReader<? extends I> reader,
ItemProcessor<? super I,? extends O> processor,
ItemWriter<? super O> writer,
RepeatOperations repeatTemplate) |
Modifier and Type | Method and Description |
---|---|
protected void |
doPersist(StepContribution contribution,
Chunk<O> chunk)
Implements writing and all related listener calls
|
protected I |
doProvide(StepContribution contribution,
Chunk<I> chunk)
Implements reading as well as any related listener calls required.
|
protected O |
doTransform(I item)
Implements processing and all related listener calls.
|
protected MulticasterBatchListener<I,O> |
getListener() |
protected void |
persist(StepContribution contribution,
Chunk<O> chunk)
Responsible for the writing portion of the chunking loop.
|
void |
process(StepContribution contribution,
Chunk<I> chunk)
Loops through reading (via
provide(StepContribution, Chunk) and
processing (via transform(StepContribution, Object) ) until the chunk
is complete. |
protected I |
provide(StepContribution contribution,
Chunk<I> chunk)
Responsible for the reading portion of the chunking loop.
|
void |
registerListener(StepListener listener)
Register a listener for callbacks at the appropriate stages in a process.
|
void |
setListeners(java.util.List<? extends StepListener> listeners)
Register some
StepListener s with the handler. |
protected O |
transform(StepContribution contribution,
I item)
Responsible for the processing portion of the chunking loop.
|
public JsrChunkProcessor()
public JsrChunkProcessor(ItemReader<? extends I> reader, ItemProcessor<? super I,? extends O> processor, ItemWriter<? super O> writer, RepeatOperations repeatTemplate)
protected MulticasterBatchListener<I,O> getListener()
public void process(StepContribution contribution, Chunk<I> chunk) throws java.lang.Exception
provide(StepContribution, Chunk)
and
processing (via transform(StepContribution, Object)
) until the chunk
is complete. Once the chunk is complete, the results are written (via
persist(StepContribution, Chunk)
.process
in interface ChunkProcessor<I>
contribution
- a StepContribution
chunk
- a Chunk
java.lang.Exception
ChunkProcessor.process(StepContribution, Chunk)
public void setListeners(java.util.List<? extends StepListener> listeners)
StepListener
s with the handler. Each will get the
callbacks in the order specified at the correct stage.listeners
- list of listeners to be used within this steppublic void registerListener(StepListener listener)
listener
- a StepListener
protected I provide(StepContribution contribution, Chunk<I> chunk) throws java.lang.Exception
doProvide(StepContribution, Chunk)
contribution
- a StepContribution
chunk
- a Chunk
java.lang.Exception
- thrown if error occurs during the reading portion of the chunking loop.protected final I doProvide(StepContribution contribution, Chunk<I> chunk) throws java.lang.Exception
contribution
- a StepContribution
chunk
- a Chunk
java.lang.Exception
- thrown if error occurs during reading or listener calls.protected O transform(StepContribution contribution, I item) throws java.lang.Exception
doTransform(Object)
if a processor is available (returns the item unmodified if it is not)contribution
- a StepContribution
item
- an itemjava.lang.Exception
- thrown if error occurs during the processing portion of the chunking loop.protected final O doTransform(I item) throws java.lang.Exception
item
- the item to be processedjava.lang.Exception
- thrown if error occurs during processing.protected void persist(StepContribution contribution, Chunk<O> chunk) throws java.lang.Exception
doPersist(StepContribution, Chunk)
.contribution
- a StepContribution
chunk
- a Chunk
java.lang.Exception
- thrown if error occurs during the writing portion of the chunking loop.protected final void doPersist(StepContribution contribution, Chunk<O> chunk) throws java.lang.Exception
contribution
- a StepContribution
chunk
- a Chunk
java.lang.Exception
- thrown if error occurs during the writing portion of the chunking loop.