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
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 TdoRead()Read next item from input.voidsetEmbeddedSchema(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, updateMethods inherited from class org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, getName, setExecutionContextName, setName
-
Constructor Details
-
AvroItemReader
- Parameters:
resource- theResourcecontaining 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- 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 to false to if 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
-