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 Object implements ChunkProvider<I>
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 Details

    • logger

      protected final org.apache.commons.logging.Log logger
    • itemReader

      protected final ItemReader<? extends I> itemReader
  • Constructor Details

  • Method Details

    • setListeners

      public void setListeners(List<? extends StepListener> listeners)
      Register some StepListeners with the handler. Each will get the callbacks in the order specified at the correct stage.
      Parameters:
      listeners - list of StepListeners.
    • 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

      public void registerListener(StepListener listener)
      Register a listener for callbacks at the appropriate stages in a process.
      Parameters:
      listener - a StepListener
    • getListener

      protected MulticasterBatchListener<I,?> getListener()
      Returns:
      the listener
    • doRead

      @Nullable protected final I doRead() throws Exception
      Surrounds the read call with listener callbacks.
      Returns:
      the item or null if the data source is exhausted
      Throws:
      Exception - is thrown if error occurs during read.
    • provide

      public Chunk<I> provide(StepContribution contribution) throws Exception
      Specified by:
      provide in interface ChunkProvider<I>
      Throws:
      Exception
    • postProcess

      public void postProcess(StepContribution contribution, Chunk<I> chunk)
      Specified by:
      postProcess in interface ChunkProvider<I>
    • read

      @Nullable protected I read(StepContribution contribution, Chunk<I> chunk) throws SkipOverflowException, Exception
      Delegates to doRead(). Subclasses can add additional behaviour (e.g. exception handling).
      Parameters:
      contribution - the current step execution contribution
      chunk - 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.
      Exception - if there is a generic issue