Interface AvroSchemaServiceManager

All Known Implementing Classes:
AvroSchemaServiceManagerImpl

public interface AvroSchemaServiceManager
Manage a Schema together with its String representation. Helps to substitute the default implementation of Schema Generation using Custom Avro schema generator Provide a custom bean definition of AvroSchemaServiceManager to override the default implementation. Migrating this interface from the original Spring Cloud Schema Registry project.
Since:
3.2.0
Author:
Ish Mahajan, Soby Chacko
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.avro.io.DatumReader<Object>
    getDatumReader(Class<? extends Object> type, org.apache.avro.Schema schema, org.apache.avro.Schema writerSchema)
    get DatumReader.
    org.apache.avro.io.DatumWriter<Object>
    getDatumWriter(Class<? extends Object> type, org.apache.avro.Schema schema)
    get DatumWriter.
    org.apache.avro.Schema
    getSchema(Class<?> clazz)
    get Schema.
    readData(Class<? extends Object> targetClass, byte[] payload, org.apache.avro.Schema readerSchema, org.apache.avro.Schema writerSchema)
    read data from avro type payload DatumReader.
  • Method Details

    • getSchema

      org.apache.avro.Schema getSchema(Class<?> clazz)
      get Schema.
      Parameters:
      clazz - Class for which schema generation is required
      Returns:
      returns avro schema for given class
    • getDatumWriter

      org.apache.avro.io.DatumWriter<Object> getDatumWriter(Class<? extends Object> type, org.apache.avro.Schema schema)
      get DatumWriter.
      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

      org.apache.avro.io.DatumReader<Object> getDatumReader(Class<? extends Object> type, org.apache.avro.Schema schema, org.apache.avro.Schema writerSchema)
      get DatumReader.
      Parameters:
      type - Class of java object which needs to be serialized
      schema - 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

      Object readData(Class<? extends Object> targetClass, byte[] payload, org.apache.avro.Schema readerSchema, org.apache.avro.Schema writerSchema) throws IOException
      read data from avro type payload DatumReader.
      Parameters:
      targetClass - 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 - in case of error