Class SimpleChunkProvider<I>
java.lang.Object
org.springframework.batch.core.step.item.SimpleChunkProvider<I>
- All Implemented Interfaces:
ChunkProvider<I>
- Direct Known Subclasses:
FaultTolerantChunkProvider
Simple implementation of the ChunkProvider interface that does basic chunk providing
from an
ItemReader.- Author:
- Dave Syer, Michael Minella, Mahmoud Ben Hassine
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ItemReader<? extends I>protected final org.apache.commons.logging.Log -
Constructor Summary
ConstructorsConstructorDescriptionSimpleChunkProvider(ItemReader<? extends I> itemReader, RepeatOperations repeatOperations) -
Method Summary
Modifier and TypeMethodDescriptionprotected final IdoRead()Surrounds the read call with listener callbacks.protected MulticasterBatchListener<I,?> voidpostProcess(StepContribution contribution, Chunk<I> chunk) provide(StepContribution contribution) protected Iread(StepContribution contribution, Chunk<I> chunk) Delegates todoRead().voidregisterListener(StepListener listener) Register a listener for callbacks at the appropriate stages in a process.voidsetListeners(List<? extends StepListener> listeners) Register someStepListeners with the handler.voidsetMeterRegistry(io.micrometer.core.instrument.MeterRegistry meterRegistry) Set the meter registry to use for metrics.
-
Field Details
-
logger
protected final org.apache.commons.logging.Log logger -
itemReader
-
-
Constructor Details
-
SimpleChunkProvider
-
-
Method Details
-
setListeners
Register someStepListeners with the handler. Each will get the callbacks in the order specified at the correct stage.- Parameters:
listeners- list ofStepListeners.
-
setMeterRegistry
public void setMeterRegistry(io.micrometer.core.instrument.MeterRegistry meterRegistry) Set the meter registry to use for metrics.- Parameters:
meterRegistry- the meter registry- Since:
- 5.0
-
registerListener
Register a listener for callbacks at the appropriate stages in a process.- Parameters:
listener- aStepListener
-
getListener
- Returns:
- the listener
-
doRead
Surrounds the read call with listener callbacks.- Returns:
- the item or
nullif the data source is exhausted - Throws:
Exception- is thrown if error occurs during read.
-
provide
- Specified by:
providein interfaceChunkProvider<I>- Throws:
Exception
-
postProcess
- Specified by:
postProcessin interfaceChunkProvider<I>
-
read
@Nullable protected I read(StepContribution contribution, Chunk<I> chunk) throws SkipOverflowException, 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
nullif 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.Exception- if there is a generic issue
-