org.springframework.batch.integration.async

## Class AsyncItemWriter<T>

- java.lang.Object
- - org.springframework.batch.integration.async.AsyncItemWriter<T>

- All Implemented Interfaces:
    ItemStream, ItemStreamWriter<java.util.concurrent.Future<T>>, ItemWriter<java.util.concurrent.Future<T>>, org.springframework.beans.factory.InitializingBean

      public class AsyncItemWriter<T>
      extends java.lang.Object
      implements ItemStreamWriter<java.util.concurrent.Future<T>>, org.springframework.beans.factory.InitializingBean

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AsyncItemWriter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()`
    `void` | `close()` If any resources are needed for the stream to operate they need to be destroyed here.
    `void` | `open(ExecutionContext executionContext)` Open the stream for the provided `ExecutionContext`.
    `void` | `setDelegate(ItemWriter<T> delegate)`
    `void` | `update(ExecutionContext executionContext)` Indicates that the execution context provided during open is about to be saved.
    `void` | `write(java.util.List<? extends java.util.concurrent.Future<T>> items)` In the processing of the `Future`s passed, nulls are not passed to the delegate since they are considered filtered out by the `AsyncItemProcessor`'s delegated `ItemProcessor`.

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

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

- - ### Constructor Detail

    - #### AsyncItemWriter

          public AsyncItemWriter()

  - ### Method Detail

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws java.lang.Exception

      Specified by:
        `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
      Throws:
        `java.lang.Exception`

    - #### setDelegate

          public void setDelegate(ItemWriter<T> delegate)

      Parameters:
        `delegate` - ItemWriter that does the actual writing of the Future results

    - #### write

          public void write(java.util.List<? extends java.util.concurrent.Future<T>> items)
                     throws java.lang.Exception

      In the processing of the `Future`s passed, nulls are not passed to the delegate since they are considered filtered out by the `AsyncItemProcessor`'s delegated `ItemProcessor`. If the unwrapping of the `Future` results in an `ExecutionException`, that will be unwrapped and the cause will be thrown.
      Specified by:
        `write` in interface `ItemWriter<java.util.concurrent.Future<T>>`
      Parameters:
        `items` - `Future`s to be unwrapped and passed to the delegate
      Throws:
        `java.lang.Exception` - The exception returned by the Future if one was thrown

    - #### open

          public void open(ExecutionContext executionContext)
                    throws ItemStreamException

      Description copied from interface: `ItemStream`
      Open the stream for the provided `ExecutionContext`.
      Specified by:
        `open` in interface `ItemStream`
      Parameters:
        `executionContext` - current step's `ExecutionContext`. Will be the executionContext from the last run of the step on a restart.
      Throws:
        `ItemStreamException`

    - #### update

          public void update(ExecutionContext executionContext)
                      throws ItemStreamException

      Description copied from interface: `ItemStream`
      Indicates that the execution context provided during open is about to be saved. If any state is remaining, but has not been put in the context, it should be added here.
      Specified by:
        `update` in interface `ItemStream`
      Parameters:
        `executionContext` - to be updated
      Throws:
        `ItemStreamException`

    - #### close

          public void close()
                     throws ItemStreamException

      Description copied from interface: `ItemStream`
      If any resources are needed for the stream to operate they need to be destroyed here. Once this method has been called all other methods (except open) may throw an exception.
      Specified by:
        `close` in interface `ItemStream`
      Throws:
        `ItemStreamException`