org.springframework.batch.item.avro

## Class AvroItemWriter<T>

- java.lang.Object
- - org.springframework.batch.item.ItemStreamSupport
  - - org.springframework.batch.item.support.AbstractItemStreamItemWriter<T>
    - - org.springframework.batch.item.avro.AvroItemWriter<T>

- All Implemented Interfaces:
    ItemStream, ItemStreamWriter<T>, ItemWriter<T>

      public class AvroItemWriter<T>
      extends AbstractItemStreamItemWriter<T>

  An `ItemWriter` that serializes data to an `WritableResource` using Avro. This does not support restart on failure.
  Since:
    4.2
  Author:
    David Turanski, Mahmoud Ben Hassine

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AvroItemWriter(org.springframework.core.io.WritableResource resource, java.lang.Class<T> clazz)` This constructor will create an ItemWriter that does not embedded Avro schema.
    `AvroItemWriter(org.springframework.core.io.WritableResource resource, org.springframework.core.io.Resource schema, java.lang.Class<T> clazz)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` No-op.
    `void` | `open(ExecutionContext executionContext)` No-op.
    `void` | `write(java.util.List<? extends T> items)` Process the supplied data element.

    - ### Methods inherited from class org.springframework.batch.item.ItemStreamSupport

      `getExecutionContextKey, setExecutionContextName, setName, update`

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

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

    - ### Methods inherited from interface org.springframework.batch.item.ItemStream

      `update`

- - ### Constructor Detail

    - #### AvroItemWriter

          public AvroItemWriter(org.springframework.core.io.WritableResource resource,
                                org.springframework.core.io.Resource schema,
                                java.lang.Class<T> clazz)

      Parameters:
        `resource` - a `WritableResource` to which the objects will be serialized.
        `schema` - a `Resource` containing the Avro schema.
        `clazz` - the data type to be serialized.

    - #### AvroItemWriter

          public AvroItemWriter(org.springframework.core.io.WritableResource resource,
                                java.lang.Class<T> clazz)

      This constructor will create an ItemWriter that does not embedded Avro schema.
      Parameters:
        `resource` - a `WritableResource` to which the objects will be serialized.
        `clazz` - the data type to be serialized.

  - ### Method Detail

    - #### write

          public void write(java.util.List<? extends T> items)
                     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.
      Parameters:
        `items` - 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.

    - #### open

          public void open(ExecutionContext executionContext)

      Description copied from class: `ItemStreamSupport`
      No-op.
      Specified by:
        `open` in interface `ItemStream`
      Overrides:
        `open` in class `ItemStreamSupport`
      Parameters:
        `executionContext` - current step's `ExecutionContext`. Will be the executionContext from the last run of the step on a restart.
      See Also:
        `ItemStream.open(ExecutionContext)`

    - #### close

          public void close()

      Description copied from class: `ItemStreamSupport`
      No-op.
      Specified by:
        `close` in interface `ItemStream`
      Overrides:
        `close` in class `ItemStreamSupport`
      See Also:
        `ItemStream.close()`