Class AvroItemReader<T>
java.lang.Object
org.springframework.batch.item.ItemStreamSupport
org.springframework.batch.item.support.AbstractItemStreamItemReader<T>
org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>
org.springframework.batch.item.avro.AvroItemReader<T>
- All Implemented Interfaces:
ItemReader<T>
,ItemStream
,ItemStreamReader<T>
An
ItemReader
that deserializes data from a Resource
containing
serialized Avro objects.
This reader is not thread-safe.
- Since:
- 4.2
- Author:
- David Turanski, Mahmoud Ben Hassine, Song JaeGeun
-
Constructor Summary
ConstructorDescriptionAvroItemReader
(org.springframework.core.io.Resource resource, Class<T> clazz) AvroItemReader
(org.springframework.core.io.Resource data, org.springframework.core.io.Resource schema) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doClose()
Close the resources opened inAbstractItemCountingItemStreamItemReader.doOpen()
.protected void
doOpen()
Open resources necessary to start reading input.protected T
doRead()
Read next item from input.void
setEmbeddedSchema
(boolean embeddedSchema) Disable or enable reading an embedded Avro schema.Methods inherited from class org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader
close, getCurrentItemCount, isSaveState, jumpToItem, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, update
Methods inherited from class org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, getName, setExecutionContextName, setName
-
Constructor Details
-
AvroItemReader
- Parameters:
resource
- theResource
containing objects serialized with Avro.clazz
- the data type to be deserialized.
-
AvroItemReader
public AvroItemReader(org.springframework.core.io.Resource data, org.springframework.core.io.Resource schema) - Parameters:
data
- theResource
containing the data to be read.schema
- theResource
containing the Avro schema.
-
-
Method Details
-
setEmbeddedSchema
public void setEmbeddedSchema(boolean embeddedSchema) Disable or enable reading an embedded Avro schema. True by default.- Parameters:
embeddedSchema
- set to false to if the input does not embed an Avro schema.
-
doRead
Description copied from class:AbstractItemCountingItemStreamItemReader
Read next item from input.- Specified by:
doRead
in classAbstractItemCountingItemStreamItemReader<T>
- Returns:
- an item or
null
if the data source is exhausted - Throws:
Exception
- Allows subclasses to throw checked exceptions for interpretation by the framework
-
doOpen
Description copied from class:AbstractItemCountingItemStreamItemReader
Open resources necessary to start reading input.- Specified by:
doOpen
in classAbstractItemCountingItemStreamItemReader<T>
- Throws:
Exception
- Allows subclasses to throw checked exceptions for interpretation by the framework
-
doClose
Description copied from class:AbstractItemCountingItemStreamItemReader
Close the resources opened inAbstractItemCountingItemStreamItemReader.doOpen()
.- Specified by:
doClose
in classAbstractItemCountingItemStreamItemReader<T>
- Throws:
Exception
- Allows subclasses to throw checked exceptions for interpretation by the framework
-