org.springframework.batch.core.jsr.step.item

## Class JsrChunkProcessor<I,O>

- java.lang.Object
- - org.springframework.batch.core.jsr.step.item.JsrChunkProcessor<I,O>

- Type Parameters:
    `I` - The input type for the step
    `O` - The output type for the step
  All Implemented Interfaces:
    ChunkProcessor<I>
  Direct Known Subclasses:
    JsrFaultTolerantChunkProcessor

      public 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).
  Author:
    Michael Minella

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JsrChunkProcessor()`
    `JsrChunkProcessor(ItemReader<? extends I> reader, ItemProcessor<? super I,? extends O> processor, ItemWriter<? super O> writer, RepeatOperations repeatTemplate)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JsrChunkProcessor

          public JsrChunkProcessor()

    - #### JsrChunkProcessor

          public JsrChunkProcessor(ItemReader<? extends I> reader,
                                   ItemProcessor<? super I,? extends O> processor,
                                   ItemWriter<? super O> writer,
                                   RepeatOperations repeatTemplate)

  - ### Method Detail

    - #### getListener

          protected MulticasterBatchListener<I,O> getListener()

    - #### process

          public void process(StepContribution contribution,
                              Chunk<I> chunk)
                       throws java.lang.Exception

      Loops through reading (via `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)`.
      Specified by:
        `process` in interface `ChunkProcessor<I>`
      Parameters:
        `contribution` - a `StepContribution`
        `chunk` - a `Chunk`
      Throws:
        `java.lang.Exception`
      See Also:
        `ChunkProcessor.process(StepContribution, Chunk)`

    - #### setListeners

          public void setListeners(java.util.List<? extends StepListener> listeners)

      Register some `StepListener`s with the handler. Each will get the callbacks in the order specified at the correct stage.
      Parameters:
        `listeners` - list of listeners to be used within this step

    - #### registerListener

          public void registerListener(StepListener listener)

      Register a listener for callbacks at the appropriate stages in a process.
      Parameters:
        `listener` - a `StepListener`

    - #### provide

          protected I provide(StepContribution contribution,
                              Chunk<I> chunk)
                       throws java.lang.Exception

      Responsible for the reading portion of the chunking loop. In this implementation, delegates to `doProvide(StepContribution, Chunk)`
      Parameters:
        `contribution` - a `StepContribution`
        `chunk` - a `Chunk`
      Returns:
        an item
      Throws:
        `java.lang.Exception`

    - #### doProvide

          protected final I doProvide(StepContribution contribution,
                                      Chunk<I> chunk)
                               throws java.lang.Exception

      Implements reading as well as any related listener calls required.
      Parameters:
        `contribution` - a `StepContribution`
        `chunk` - a `Chunk`
      Returns:
        an item
      Throws:
        `java.lang.Exception`

    - #### transform

          protected O transform(StepContribution contribution,
                                I item)
                         throws java.lang.Exception

      Responsible for the processing portion of the chunking loop. In this implementation, delegates to the `doTransform(Object)` if a processor is available (returns the item unmodified if it is not)
      Parameters:
        `contribution` - a `StepContribution`
        `item` - an item
      Returns:
        a processed item if a processor is present (the unmodified item if it is not)
      Throws:
        `java.lang.Exception`

    - #### doTransform

          protected final O doTransform(I item)
                                 throws java.lang.Exception

      Implements processing and all related listener calls.
      Parameters:
        `item` - the item to be processed
      Returns:
        the processed item
      Throws:
        `java.lang.Exception`

    - #### persist

          protected void persist(StepContribution contribution,
                                 Chunk<O> chunk)
                          throws java.lang.Exception

      Responsible for the writing portion of the chunking loop. In this implementation, delegates to the {`doPersist(StepContribution, Chunk)`.
      Parameters:
        `contribution` - a `StepContribution`
        `chunk` - a `Chunk`
      Throws:
        `java.lang.Exception`

    - #### doPersist

          protected final void doPersist(StepContribution contribution,
                                         Chunk<O> chunk)
                                  throws java.lang.Exception

      Implements writing and all related listener calls
      Parameters:
        `contribution` - a `StepContribution`
        `chunk` - a `Chunk`
      Throws:
        `java.lang.Exception`