org.springframework.batch.item.support

## Class CompositeItemWriter<T>

- java.lang.Object
- - org.springframework.batch.item.support.CompositeItemWriter<T>

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

      public class CompositeItemWriter<T>
      extends java.lang.Object
      implements ItemStreamWriter<T>, org.springframework.beans.factory.InitializingBean

  Calls a collection of `ItemWriter`s in fixed-order sequence.
  The implementation is thread-safe if all delegates are thread-safe.
  Author:
    Robert Kasanicky, Dave Syer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CompositeItemWriter()`

  - ### 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` | `setDelegates(java.util.List<ItemWriter<? super T>> delegates)`
    `void` | `setIgnoreItemStream(boolean ignoreItemStream)`
    `void` | `update(ExecutionContext executionContext)` Indicates that the execution context provided during open is about to be saved.
    `void` | `write(java.util.List<? extends T> item)` Process the supplied data element.

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

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

- - ### Constructor Detail

    - #### CompositeItemWriter

          public CompositeItemWriter()

  - ### Method Detail

    - #### setIgnoreItemStream

          public void setIgnoreItemStream(boolean ignoreItemStream)

    - #### write

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

      Description copied from interface: `ItemWriter`
      Process the supplied data element. Will not be called with any null items in normal operation.
      Specified by:
        `write` in interface `ItemWriter<T>`
      Parameters:
        `item` - items to be written
      Throws:
        `java.lang.Exception` - if there are errors. The framework will catch the exception and convert or rethrow it as appropriate.

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws java.lang.Exception

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

    - #### setDelegates

          public void setDelegates(java.util.List<ItemWriter<? super T>> delegates)

    - #### 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`

    - #### 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`