Class AvroSchemaServiceManagerImpl
- java.lang.Object
-
- org.springframework.cloud.function.context.converter.avro.AvroSchemaServiceManagerImpl
-
- All Implemented Interfaces:
AvroSchemaServiceManager
public class AvroSchemaServiceManagerImpl extends Object implements AvroSchemaServiceManager
Default Concrete implementation ofAvroSchemaServiceManager
. Helps to substitute the default implementation ofSchema
Generation using Custom Avro schema generator Migrating this class from the original Spring Cloud Schema Registry project.- Since:
- 3.2.0
- Author:
- Ish Mahajan, Soby Chacko
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.Log
logger
-
Constructor Summary
Constructors Constructor Description AvroSchemaServiceManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.avro.io.DatumReader<Object>
getDatumReader(Class<?> type, org.apache.avro.Schema readerSchema, org.apache.avro.Schema writerSchema)
getDatumReader
.org.apache.avro.io.DatumWriter<Object>
getDatumWriter(Class<?> type, org.apache.avro.Schema schema)
getDatumWriter
.org.apache.avro.Schema
getSchema(Class<?> clazz)
getSchema
.Object
readData(Class<? extends Object> clazz, byte[] payload, org.apache.avro.Schema readerSchema, org.apache.avro.Schema writerSchema)
read data from avro type payloadDatumReader
.
-
-
-
Method Detail
-
getSchema
public org.apache.avro.Schema getSchema(Class<?> clazz)
getSchema
.- Specified by:
getSchema
in interfaceAvroSchemaServiceManager
- Parameters:
clazz
-Class
for which schema generation is required- Returns:
- returns avro schema for given class
-
getDatumWriter
public org.apache.avro.io.DatumWriter<Object> getDatumWriter(Class<?> type, org.apache.avro.Schema schema)
getDatumWriter
.- Specified by:
getDatumWriter
in interfaceAvroSchemaServiceManager
- Parameters:
type
-Class
of java object which needs to be serializedschema
-Schema
of object which needs to be serialized- Returns:
- datum writer which can be used to write Avro payload
-
getDatumReader
public org.apache.avro.io.DatumReader<Object> getDatumReader(Class<?> type, org.apache.avro.Schema readerSchema, org.apache.avro.Schema writerSchema)
getDatumReader
.- Specified by:
getDatumReader
in interfaceAvroSchemaServiceManager
- Parameters:
type
-Class
of java object which needs to be serializedreaderSchema
-Schema
default schema of object which needs to be de-serializedwriterSchema
-Schema
writerSchema provided at run time- Returns:
- datum reader which can be used to read Avro payload
-
readData
public Object readData(Class<? extends Object> clazz, byte[] payload, org.apache.avro.Schema readerSchema, org.apache.avro.Schema writerSchema) throws IOException
read data from avro type payloadDatumReader
.- Specified by:
readData
in interfaceAvroSchemaServiceManager
- Parameters:
clazz
-Class
of java object which needs to be serializedpayload
-byte
serialized payload of object which needs to be de-serializedreaderSchema
-Schema
readerSchema of object which needs to be de-serializedwriterSchema
-Schema
writerSchema used to while serializing payload- Returns:
- java object after reading Avro Payload
- Throws:
IOException
- is thrown in case of error
-
-