org.springframework.batch.core.listener

## Class ItemListenerSupport<I,O>

- java.lang.Object
- - org.springframework.batch.core.listener.ItemListenerSupport<I,O>

- All Implemented Interfaces:
    ItemProcessListener<I,O>, ItemReadListener<I>, ItemWriteListener<O>, StepListener
  Direct Known Subclasses:
    DefaultItemFailureHandler

      public class ItemListenerSupport<I,O>
      extends java.lang.Object
      implements ItemReadListener<I>, ItemProcessListener<I,O>, ItemWriteListener<O>

  Basic no-op implementation of the `ItemReadListener`, `ItemProcessListener`, and `ItemWriteListener` interfaces. All are implemented, since it is very common that all may need to be implemented at once.
  Author:
    Lucas Ward, Mahmoud Ben Hassine

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ItemListenerSupport()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterProcess(I item, O result)` Called after `ItemProcessor.process(Object)` returns.
    `void` | `afterRead(I item)` Called after `ItemReader.read()`.
    `void` | `afterWrite(java.util.List<? extends O> item)` Called after `ItemWriter.write(java.util.List)` This will be called before any transaction is committed, and before `ChunkListener.afterChunk(ChunkContext)`
    `void` | `beforeProcess(I item)` Called before `ItemProcessor.process(Object)`.
    `void` | `beforeRead()` Called before `ItemReader.read()`
    `void` | `beforeWrite(java.util.List<? extends O> item)` Called before `ItemWriter.write(java.util.List)`
    `void` | `onProcessError(I item, java.lang.Exception e)` Called if an exception was thrown from `ItemProcessor.process(Object)`.
    `void` | `onReadError(java.lang.Exception ex)` Called if an error occurs while trying to read.
    `void` | `onWriteError(java.lang.Exception ex, java.util.List<? extends O> item)` Called if an error occurs while trying to write.

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

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

- - ### Constructor Detail

    - #### ItemListenerSupport

          public ItemListenerSupport()

  - ### Method Detail

    - #### afterRead

          public void afterRead(I item)

      Description copied from interface: `ItemReadListener`
      Called after `ItemReader.read()`. This method is called only for actual items (ie it is not called when the reader returns null).
      Specified by:
        `afterRead` in interface `ItemReadListener<I>`
      Parameters:
        `item` - returned from read()

    - #### beforeRead

          public void beforeRead()

      Description copied from interface: `ItemReadListener`
      Called before `ItemReader.read()`
      Specified by:
        `beforeRead` in interface `ItemReadListener<I>`

    - #### onReadError

          public void onReadError(java.lang.Exception ex)

      Description copied from interface: `ItemReadListener`
      Called if an error occurs while trying to read.
      Specified by:
        `onReadError` in interface `ItemReadListener<I>`
      Parameters:
        `ex` - thrown from `ItemWriter`

    - #### afterProcess

          public void afterProcess(I item,
                                   @Nullable
                                   O result)

      Description copied from interface: `ItemProcessListener`
      Called after `ItemProcessor.process(Object)` returns. If the processor returns `null`, this method will still be called, with a {code null} result, allowing for notification of 'filtered' items.
      Specified by:
        `afterProcess` in interface `ItemProcessListener<I,O>`
      Parameters:
        `item` - to be processed
        `result` - of processing

    - #### beforeProcess

          public void beforeProcess(I item)

      Description copied from interface: `ItemProcessListener`
      Called before `ItemProcessor.process(Object)`.
      Specified by:
        `beforeProcess` in interface `ItemProcessListener<I,O>`
      Parameters:
        `item` - to be processed.

    - #### onProcessError

          public void onProcessError(I item,
                                     java.lang.Exception e)

      Description copied from interface: `ItemProcessListener`
      Called if an exception was thrown from `ItemProcessor.process(Object)`.
      Specified by:
        `onProcessError` in interface `ItemProcessListener<I,O>`
      Parameters:
        `item` - attempted to be processed
        `e` - - exception thrown during processing.

    - #### afterWrite

          public void afterWrite(java.util.List<? extends O> item)

      Description copied from interface: `ItemWriteListener`
      Called after `ItemWriter.write(java.util.List)` This will be called before any transaction is committed, and before `ChunkListener.afterChunk(ChunkContext)`
      Specified by:
        `afterWrite` in interface `ItemWriteListener<O>`
      Parameters:
        `item` - written items

    - #### beforeWrite

          public void beforeWrite(java.util.List<? extends O> item)

      Description copied from interface: `ItemWriteListener`
      Called before `ItemWriter.write(java.util.List)`
      Specified by:
        `beforeWrite` in interface `ItemWriteListener<O>`
      Parameters:
        `item` - to be written

    - #### onWriteError

          public void onWriteError(java.lang.Exception ex,
                                   java.util.List<? extends O> item)

      Description copied from interface: `ItemWriteListener`
      Called if an error occurs while trying to write. Will be called inside a transaction, but the transaction will normally be rolled back. There is no way to identify from this callback which of the items (if any) caused the error.
      Specified by:
        `onWriteError` in interface `ItemWriteListener<O>`
      Parameters:
        `ex` - thrown from `ItemWriter`
        `item` - attempted to be written.