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>
An
ItemWriter
that serializes data to an WritableResource
using Avro.
This does not support restart on failure.
This writer is not thread-safe.
- Since:
- 4.2
- Author:
- David Turanski, Mahmoud Ben Hassine
-
Constructor Summary
ConstructorDescriptionAvroItemWriter
(org.springframework.core.io.WritableResource resource, 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, Class<T> clazz) -
Method Summary
Methods inherited from class org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, getName, 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 Details
-
AvroItemWriter
public AvroItemWriter(org.springframework.core.io.WritableResource resource, org.springframework.core.io.Resource schema, Class<T> clazz) - Parameters:
resource
- aWritableResource
to which the objects will be serialized.schema
- aResource
containing the Avro schema.clazz
- the data type to be serialized.
-
AvroItemWriter
This constructor will create an ItemWriter that does not embedded Avro schema.- Parameters:
resource
- aWritableResource
to which the objects will be serialized.clazz
- the data type to be serialized.
-
-
Method Details
-
write
Description copied from interface:ItemWriter
Process the supplied data element. Will not be called with any null items in normal operation.- Parameters:
items
- of items to be written. Must not benull
.- Throws:
Exception
- if there are errors. The framework will catch the exception and convert or rethrow it as appropriate.
-
open
Description copied from class:ItemStreamSupport
No-op.- Specified by:
open
in interfaceItemStream
- Overrides:
open
in classItemStreamSupport
- Parameters:
executionContext
- current step'sExecutionContext
. Will be the executionContext from the last run of the step on a restart.- See Also:
-
close
public void close()Description copied from class:ItemStreamSupport
No-op.- Specified by:
close
in interfaceItemStream
- Overrides:
close
in classItemStreamSupport
- See Also:
-