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 Details

    • logger

      protected final org.apache.commons.logging.Log logger
  • Constructor Details

    • AvroSchemaServiceManagerImpl

      public AvroSchemaServiceManagerImpl()
  • Method Details

    • getSchema

      public org.apache.avro.Schema getSchema(Class<?> clazz)
      get Schema.
      Specified by:
      getSchema in interface AvroSchemaServiceManager
      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)
      get DatumWriter.
      Specified by:
      getDatumWriter in interface AvroSchemaServiceManager
      Parameters:
      type - Class of java object which needs to be serialized
      schema - 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)
      get DatumReader.
      Specified by:
      getDatumReader in interface AvroSchemaServiceManager
      Parameters:
      type - Class of java object which needs to be serialized
      readerSchema - Schema default schema of object which needs to be de-serialized
      writerSchema - 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 payload DatumReader.
      Specified by:
      readData in interface AvroSchemaServiceManager
      Parameters:
      clazz - Class of java object which needs to be serialized
      payload - byte serialized payload of object which needs to be de-serialized
      readerSchema - Schema readerSchema of object which needs to be de-serialized
      writerSchema - Schema writerSchema used to while serializing payload
      Returns:
      java object after reading Avro Payload
      Throws:
      IOException - is thrown in case of error