Class DelegatingByTopicSerialization<T extends Closeable>

java.lang.Object
org.springframework.kafka.support.serializer.DelegatingByTopicSerialization<T>
Type Parameters:
T - the type.
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
DelegatingByTopicDeserializer, DelegatingByTopicSerializer

public abstract class DelegatingByTopicSerialization<T extends Closeable> extends Object implements Closeable
Base class with common code for delegating by topic serialization.
Since:
2.8
Author:
Gary Russell, Wang Zhiyang
  • Field Details

    • VALUE_SERIALIZATION_TOPIC_CONFIG

      public static final String VALUE_SERIALIZATION_TOPIC_CONFIG
      Name of the configuration property containing the serialization selector map for values with format selector:class,....
      See Also:
    • KEY_SERIALIZATION_TOPIC_CONFIG

      public static final String KEY_SERIALIZATION_TOPIC_CONFIG
      Name of the configuration property containing the serialization topic pattern map for keys with format pattern:class,....
      See Also:
    • VALUE_SERIALIZATION_TOPIC_DEFAULT

      public static final String VALUE_SERIALIZATION_TOPIC_DEFAULT
      Name of the default delegate for keys when no topic name match is fount.
      See Also:
    • KEY_SERIALIZATION_TOPIC_DEFAULT

      public static final String KEY_SERIALIZATION_TOPIC_DEFAULT
      Name of the default delegate for keys when no topic name match is fount.
      See Also:
    • CASE_SENSITIVE

      public static final String CASE_SENSITIVE
      Set to false to make topic pattern matching case-insensitive.
      See Also:
  • Constructor Details

    • DelegatingByTopicSerialization

      public DelegatingByTopicSerialization()
    • DelegatingByTopicSerialization

      public DelegatingByTopicSerialization(Map<Pattern,T> delegates, T defaultDelegate)
  • Method Details

    • setCaseSensitive

      public void setCaseSensitive(boolean caseSensitive)
      Set to false to make topic name matching case insensitive.
      Parameters:
      caseSensitive - false for case insensitive.
    • configure

      protected void configure(Map<String,?> configs, boolean isKey)
    • build

      protected void build(Map<String,?> configs, boolean isKey, String configKey, Object delegate, Pattern pattern)
    • buildDefault

      protected void buildDefault(Map<String,?> configs, String configKey, boolean isKey, Object delegate)
    • configureDelegate

      protected abstract T configureDelegate(Map<String,?> configs, boolean isKey, T delegate)
      Configure the delegate.
      Parameters:
      configs - the configs.
      isKey - true if this is for keys.
      delegate - the delegate.
      Returns:
      the delegate.
    • isInstance

      protected abstract boolean isInstance(Object delegate)
      Return true if this object is an instance of T.
      Parameters:
      delegate - the delegate.
      Returns:
      true if a T.
    • instantiateAndConfigure

      protected T instantiateAndConfigure(Map<String,?> configs, boolean isKey, Map<Pattern,T> delegates2, @Nullable Pattern pattern, Class<?> clazz)
    • addDelegate

      public void addDelegate(Pattern pattern, T serializer)
    • removeDelegate

      @Nullable public T removeDelegate(Pattern pattern)
    • findDelegate

      protected T findDelegate(String topic)
      Determine the delegate for the topic.
      Parameters:
      topic - the topic.
      Returns:
      the delegate.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable