Class SimpleChunkProvider<I>
- java.lang.Object
- org.springframework.batch.core.step.item.SimpleChunkProvider<I>
- All Implemented Interfaces:
ChunkProvider<I>
- Direct Known Subclasses:
FaultTolerantChunkProvider
public class SimpleChunkProvider<I> extends java.lang.Object implements ChunkProvider<I>
Simple implementation of the ChunkProvider interface that does basic chunk providing from anItemReader
.- Author:
- Dave Syer, Michael Minella, Mahmoud Ben Hassine
- See Also:
ChunkOrientedTasklet
Field Summary
Fields Modifier and Type Field Description protected ItemReader<? extends I>
itemReader
protected org.apache.commons.logging.Log
logger
Constructor Summary
Constructors Constructor Description SimpleChunkProvider(ItemReader<? extends I> itemReader, RepeatOperations repeatOperations)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected I
doRead()
Surrounds the read call with listener callbacks.protected MulticasterBatchListener<I,?>
getListener()
void
postProcess(StepContribution contribution, Chunk<I> chunk)
Chunk<I>
provide(StepContribution contribution)
protected I
read(StepContribution contribution, Chunk<I> chunk)
Delegates todoRead()
.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 someStepListener
s with the handler.
Field Detail
logger
protected final org.apache.commons.logging.Log logger
itemReader
protected final ItemReader<? extends I> itemReader
Constructor Detail
SimpleChunkProvider
public SimpleChunkProvider(ItemReader<? extends I> itemReader, RepeatOperations repeatOperations)
Method Detail
setListeners
public void setListeners(java.util.List<? extends StepListener> listeners)
Register someStepListener
s with the handler. Each will get the callbacks in the order specified at the correct stage.- Parameters:
listeners
- list ofStepListener
s.
registerListener
public void registerListener(StepListener listener)
Register a listener for callbacks at the appropriate stages in a process.- Parameters:
listener
- aStepListener
getListener
protected MulticasterBatchListener<I,?> getListener()
- Returns:
- the listener
doRead
@Nullable protected final I doRead() throws java.lang.Exception
Surrounds the read call with listener callbacks.- Returns:
- the item or
null
if the data source is exhausted - Throws:
java.lang.Exception
- is thrown if error occurs during read.
provide
public Chunk<I> provide(StepContribution contribution) throws java.lang.Exception
- Specified by:
provide
in interfaceChunkProvider<I>
- Throws:
java.lang.Exception
postProcess
public void postProcess(StepContribution contribution, Chunk<I> chunk)
- Specified by:
postProcess
in interfaceChunkProvider<I>
read
@Nullable protected I read(StepContribution contribution, Chunk<I> chunk) throws SkipOverflowException, java.lang.Exception
Delegates todoRead()
. Subclasses can add additional behaviour (e.g. exception handling).- Parameters:
contribution
- the current step execution contributionchunk
- the current chunk- Returns:
- a new item for processing or
null
if the data source is exhausted - Throws:
SkipOverflowException
- if specifically the chunk is accumulating too much data (e.g. skips) and it wants to force a commit.java.lang.Exception
- if there is a generic issue