Class DelegatingByTopicSerialization<T extends java.io.Closeable>
- java.lang.Object
-
- org.springframework.kafka.support.serializer.DelegatingByTopicSerialization<T>
-
- Type Parameters:
T- the type.
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
DelegatingByTopicDeserializer,DelegatingByTopicSerializer
public abstract class DelegatingByTopicSerialization<T extends java.io.Closeable> extends java.lang.Object implements java.io.CloseableBase class with common code for delegating by topic serialization.- Since:
- 2.8
- Author:
- Gary Russell
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCASE_SENSITIVESet to false to make topic pattern matching case-insensitive.static java.lang.StringKEY_SERIALIZATION_TOPIC_CONFIGName of the configuration property containing the serialization topic pattern map for keys with formatpattern:class,....static java.lang.StringKEY_SERIALIZATION_TOPIC_DEFAULTName of the default delegate for keys when no topic name match is fount.static java.lang.StringVALUE_SERIALIZATION_TOPIC_CONFIGName of the configuration property containing the serialization selector map for values with formatselector:class,....static java.lang.StringVALUE_SERIALIZATION_TOPIC_DEFAULTName of the default delegate for keys when no topic name match is fount.
-
Constructor Summary
Constructors Constructor Description DelegatingByTopicSerialization()DelegatingByTopicSerialization(java.util.Map<java.util.regex.Pattern,T> delegates, T defaultDelegate)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDelegate(java.util.regex.Pattern pattern, T serializer)protected voidbuild(java.util.Map<java.lang.String,?> configs, boolean isKey, java.lang.String configKey, java.lang.Object delegate, java.util.regex.Pattern pattern)protected voidbuildDefault(java.util.Map<java.lang.String,?> configs, java.lang.String configKey, boolean isKey, java.lang.Object delegate)voidclose()protected voidconfigure(java.util.Map<java.lang.String,?> configs, boolean isKey)protected abstract TconfigureDelegate(java.util.Map<java.lang.String,?> configs, boolean isKey, T delegate)Configure the delegate.protected TfindDelegate(java.lang.String topic)Determine the delegate for the topic.protected TinstantiateAndConfigure(java.util.Map<java.lang.String,?> configs, boolean isKey, java.util.Map<java.util.regex.Pattern,T> delegates2, java.util.regex.Pattern pattern, java.lang.Class<?> clazz)protected abstract booleanisInstance(java.lang.Object delegate)Return true if this object is an instance of T.TremoveDelegate(java.util.regex.Pattern pattern)voidsetCaseSensitive(boolean caseSensitive)Set to false to make topic name matching case insensitive.
-
-
-
Field Detail
-
VALUE_SERIALIZATION_TOPIC_CONFIG
public static final java.lang.String VALUE_SERIALIZATION_TOPIC_CONFIG
Name of the configuration property containing the serialization selector map for values with formatselector:class,....- See Also:
- Constant Field Values
-
KEY_SERIALIZATION_TOPIC_CONFIG
public static final java.lang.String KEY_SERIALIZATION_TOPIC_CONFIG
Name of the configuration property containing the serialization topic pattern map for keys with formatpattern:class,....- See Also:
- Constant Field Values
-
VALUE_SERIALIZATION_TOPIC_DEFAULT
public static final java.lang.String VALUE_SERIALIZATION_TOPIC_DEFAULT
Name of the default delegate for keys when no topic name match is fount.- See Also:
- Constant Field Values
-
KEY_SERIALIZATION_TOPIC_DEFAULT
public static final java.lang.String KEY_SERIALIZATION_TOPIC_DEFAULT
Name of the default delegate for keys when no topic name match is fount.- See Also:
- Constant Field Values
-
CASE_SENSITIVE
public static final java.lang.String CASE_SENSITIVE
Set to false to make topic pattern matching case-insensitive.- See Also:
- Constant Field Values
-
-
Method Detail
-
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(java.util.Map<java.lang.String,?> configs, boolean isKey)
-
build
protected void build(java.util.Map<java.lang.String,?> configs, boolean isKey, java.lang.String configKey, java.lang.Object delegate, java.util.regex.Pattern pattern)
-
buildDefault
protected void buildDefault(java.util.Map<java.lang.String,?> configs, java.lang.String configKey, boolean isKey, java.lang.Object delegate)
-
configureDelegate
protected abstract T configureDelegate(java.util.Map<java.lang.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(java.lang.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(java.util.Map<java.lang.String,?> configs, boolean isKey, java.util.Map<java.util.regex.Pattern,T> delegates2, @Nullable java.util.regex.Pattern pattern, java.lang.Class<?> clazz)
-
addDelegate
public void addDelegate(java.util.regex.Pattern pattern, T serializer)
-
removeDelegate
@Nullable public T removeDelegate(java.util.regex.Pattern pattern)
-
findDelegate
protected T findDelegate(java.lang.String topic)
Determine the delegate for the topic.- Parameters:
topic- the topic.- Returns:
- the delegate.
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
-