org.springframework.batch.core.jsr

## Class ItemWriteListenerAdapter<S>

- java.lang.Object
- - org.springframework.batch.core.jsr.ItemWriteListenerAdapter<S>

- Type Parameters:
    `S` - type to be written by the associated `ItemWriter`
  All Implemented Interfaces:
    ItemWriteListener<S>, StepListener

      public class ItemWriteListenerAdapter<S>
      extends java.lang.Object
      implements ItemWriteListener<S>

  Wrapper class to adapt the `ItemWriteListener` to a `ItemWriteListener`.
  Since:
    3.0
  Author:
    Michael Minella

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ItemWriteListenerAdapter(javax.batch.api.chunk.listener.ItemWriteListener delegate)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterWrite(java.util.List<? extends S> items)` Called after `ItemWriter.write(java.util.List)` This will be called before any transaction is committed, and before `ChunkListener.afterChunk(ChunkContext)`
    `void` | `beforeWrite(java.util.List<? extends S> items)` Called before `ItemWriter.write(java.util.List)`
    `void` | `onWriteError(java.lang.Exception exception, java.util.List<? extends S> items)` 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

    - #### ItemWriteListenerAdapter

          public ItemWriteListenerAdapter(javax.batch.api.chunk.listener.ItemWriteListener delegate)

  - ### Method Detail

    - #### beforeWrite

          public void beforeWrite(java.util.List<? extends S> items)

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

    - #### afterWrite

          public void afterWrite(java.util.List<? extends S> items)

      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<S>`
      Parameters:
        `items` - written items

    - #### onWriteError

          public void onWriteError(java.lang.Exception exception,
                                   java.util.List<? extends S> items)

      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<S>`
      Parameters:
        `exception` - thrown from `ItemWriter`
        `items` - attempted to be written.