Class DefaultSchemaHandler

java.lang.Object
io.micronaut.pulsar.processor.DefaultSchemaHandler

@Singleton public class DefaultSchemaHandler extends Object
Message type resolver for Pulsar schema. Simplifies resolving Java types to Pulsar schemas by using requested transmission type via annotations and injecting proper resolvers in place.
Since:
1.1.0
Author:
Haris Secic
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultSchemaHandler(io.micronaut.context.BeanContext context)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Class<?>
    bodyType(io.micronaut.core.type.Argument<?> body)
     
    org.apache.pulsar.client.api.Schema<?>
    decideSchema(io.micronaut.core.type.Argument<?> body, @Nullable io.micronaut.core.type.Argument<?> key, io.micronaut.core.annotation.AnnotationValue<?> topicAnnotation, String target)
    Resolve which schema to use for ser/der.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultSchemaHandler

      public DefaultSchemaHandler(io.micronaut.context.BeanContext context)
      Parameters:
      context - BeanContext for fetching extra resolvers
      Since:
      1.1.0
  • Method Details

    • decideSchema

      public org.apache.pulsar.client.api.Schema<?> decideSchema(io.micronaut.core.type.Argument<?> body, @Nullable @Nullable io.micronaut.core.type.Argument<?> key, io.micronaut.core.annotation.AnnotationValue<?> topicAnnotation, String target)
      Resolve which schema to use for ser/der.
      Parameters:
      body - argument that represents message body
      key - if message is of type key-value a key should be passed; otherwise use null
      topicAnnotation - annotation corresponding to one of the Pulsar annotations: consumer, reader, producer.
      target - name of the method, field, or other that represent where the error might be in case of it.
      Returns:
      new Schema
    • bodyType

      public static Class<?> bodyType(io.micronaut.core.type.Argument<?> body)