Class AvroSchemaServiceManagerImpl
java.lang.Object
org.springframework.cloud.stream.schema.registry.avro.AvroSchemaServiceManagerImpl
- All Implemented Interfaces:
AvroSchemaServiceManager
@Component
public class AvroSchemaServiceManagerImpl
extends Object
implements AvroSchemaServiceManager
Default Concrete implementation of
AvroSchemaServiceManager.
Helps to substitute the default implementation of Schema Generation using Custom Avro
schema generator
Provide a custom bean definition of AvroSchemaServiceManager and mark it as @Primary to override this
default implementation- Author:
- Ish Mahajan
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.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.SchemagetSchema.readData(Class<? extends Object> clazz, byte[] payload, org.apache.avro.Schema readerSchema, org.apache.avro.Schema writerSchema) read data from avro type payloadDatumReader.
-
Field Details
-
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
AvroSchemaServiceManagerImpl
public AvroSchemaServiceManagerImpl()
-
-
Method Details
-
getSchema
getSchema.- Specified by:
getSchemain interfaceAvroSchemaServiceManager- Parameters:
clazz-Classfor 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:
getDatumWriterin interfaceAvroSchemaServiceManager- Parameters:
type-Classof java object which needs to be serializedschema-Schemaof 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:
getDatumReaderin interfaceAvroSchemaServiceManager- Parameters:
type-Classof java object which needs to be serializedreaderSchema-Schemadefault schema of object which needs to be de-serializedwriterSchema-SchemawriterSchema 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:
readDatain interfaceAvroSchemaServiceManager- Parameters:
clazz-Classof java object which needs to be serializedpayload-byteserialized payload of object which needs to be de-serializedreaderSchema-SchemareaderSchema of object which needs to be de-serializedwriterSchema-SchemawriterSchema used to while serializing payload- Returns:
- java object after reading Avro Payload
- Throws:
IOException- is thrown in case of error
-