Class AvroItemReader<T>
java.lang.Object
org.springframework.batch.infrastructure.item.ItemStreamSupport
org.springframework.batch.infrastructure.item.support.AbstractItemStreamItemReader<T>
org.springframework.batch.infrastructure.item.support.AbstractItemCountingItemStreamItemReader<T>
org.springframework.batch.infrastructure.item.avro.AvroItemReader<T>
- All Implemented Interfaces:
ItemReader<T>, ItemStream, ItemStreamReader<T>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware
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, Jimmy Praet
-
Constructor Summary
ConstructorsConstructorDescriptionAvroItemReader(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 voiddoClose()Close the resources opened inAbstractItemCountingItemStreamItemReader.doOpen().protected voiddoOpen()Open resources necessary to start reading input.protected @Nullable TdoRead()Read next item from input.voidsetEmbeddedSchema(boolean embeddedSchema) Disable or enable reading an embedded Avro schema.Methods inherited from class AbstractItemCountingItemStreamItemReader
close, getCurrentItemCount, isSaveState, jumpToItem, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, updateMethods inherited from class ItemStreamSupport
getExecutionContextKey, getName, setBeanName, setExecutionContextName, setName
-
Constructor Details
-
AvroItemReader
-
AvroItemReader
public AvroItemReader(org.springframework.core.io.Resource data, org.springframework.core.io.Resource schema) - Parameters:
data- theResourcecontaining the data to be read.schema- theResourcecontaining 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 tofalseif the input does not embed an Avro schema.
-
doRead
Description copied from class:AbstractItemCountingItemStreamItemReaderRead next item from input.- Specified by:
doReadin classAbstractItemCountingItemStreamItemReader<T>- Returns:
- an item or
nullif the data source is exhausted - Throws:
Exception- Allows subclasses to throw checked exceptions for interpretation by the framework
-
doOpen
Description copied from class:AbstractItemCountingItemStreamItemReaderOpen resources necessary to start reading input.- Specified by:
doOpenin classAbstractItemCountingItemStreamItemReader<T>- Throws:
Exception- Allows subclasses to throw checked exceptions for interpretation by the framework
-
doClose
Description copied from class:AbstractItemCountingItemStreamItemReaderClose the resources opened inAbstractItemCountingItemStreamItemReader.doOpen().- Specified by:
doClosein classAbstractItemCountingItemStreamItemReader<T>- Throws:
Exception- Allows subclasses to throw checked exceptions for interpretation by the framework
-