Class DelegatingDeserializer
- java.lang.Object
-
- org.springframework.kafka.support.serializer.DelegatingDeserializer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,org.apache.kafka.common.serialization.Deserializer<java.lang.Object>
public class DelegatingDeserializer extends java.lang.Object implements org.apache.kafka.common.serialization.Deserializer<java.lang.Object>
ADeserializer
that delegates to other deserializers based on a serialization selector header. It is not necessary to configure standard deserializers supported bySerdes
.- Since:
- 2.3
- Author:
- Gary Russell
-
-
Constructor Summary
Constructors Constructor Description DelegatingDeserializer()
Construct an instance that will be configured inconfigure(Map, boolean)
with consumer propertiesDelegatingSerializer.KEY_SERIALIZATION_SELECTOR_CONFIG
andDelegatingSerializer.VALUE_SERIALIZATION_SELECTOR_CONFIG
.DelegatingDeserializer(java.util.Map<java.lang.String,org.apache.kafka.common.serialization.Deserializer<?>> delegates)
Construct an instance with the supplied mapping of selectors to delegate deserializers.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDelegate(java.lang.String selector, org.apache.kafka.common.serialization.Deserializer<?> deserializer)
void
close()
void
configure(java.util.Map<java.lang.String,?> configs, boolean isKey)
protected static java.util.Map<java.lang.String,org.apache.kafka.common.serialization.Deserializer<?>>
createDelegates(java.lang.String mappings, java.util.Map<java.lang.String,?> configs, boolean isKey)
protected static void
createInstanceAndConfigure(java.util.Map<java.lang.String,?> configs, boolean isKey, java.util.Map<java.lang.String,org.apache.kafka.common.serialization.Deserializer<?>> delegateMap, java.lang.String selector, java.lang.String className)
java.lang.Object
deserialize(java.lang.String topic, byte[] data)
java.lang.Object
deserialize(java.lang.String topic, org.apache.kafka.common.header.Headers headers, byte[] data)
protected static void
instantiateAndConfigure(java.util.Map<java.lang.String,?> configs, boolean isKey, java.util.Map<java.lang.String,org.apache.kafka.common.serialization.Deserializer<?>> delegateMap, java.lang.String selector, java.lang.Class<?> clazz)
org.apache.kafka.common.serialization.Deserializer<?>
removeDelegate(java.lang.String selector)
-
-
-
Constructor Detail
-
DelegatingDeserializer
public DelegatingDeserializer()
Construct an instance that will be configured inconfigure(Map, boolean)
with consumer propertiesDelegatingSerializer.KEY_SERIALIZATION_SELECTOR_CONFIG
andDelegatingSerializer.VALUE_SERIALIZATION_SELECTOR_CONFIG
.
-
DelegatingDeserializer
public DelegatingDeserializer(java.util.Map<java.lang.String,org.apache.kafka.common.serialization.Deserializer<?>> delegates)
Construct an instance with the supplied mapping of selectors to delegate deserializers. The selector must be supplied in theDelegatingSerializer.KEY_SERIALIZATION_SELECTOR_CONFIG
andDelegatingSerializer.VALUE_SERIALIZATION_SELECTOR_CONFIG
headers. It is not necessary to configure standard deserializers supported bySerdes
.- Parameters:
delegates
- the map of delegates.
-
-
Method Detail
-
configure
public void configure(java.util.Map<java.lang.String,?> configs, boolean isKey)
- Specified by:
configure
in interfaceorg.apache.kafka.common.serialization.Deserializer<java.lang.Object>
-
createDelegates
protected static java.util.Map<java.lang.String,org.apache.kafka.common.serialization.Deserializer<?>> createDelegates(java.lang.String mappings, java.util.Map<java.lang.String,?> configs, boolean isKey)
-
createInstanceAndConfigure
protected static void createInstanceAndConfigure(java.util.Map<java.lang.String,?> configs, boolean isKey, java.util.Map<java.lang.String,org.apache.kafka.common.serialization.Deserializer<?>> delegateMap, java.lang.String selector, java.lang.String className)
-
instantiateAndConfigure
protected static void instantiateAndConfigure(java.util.Map<java.lang.String,?> configs, boolean isKey, java.util.Map<java.lang.String,org.apache.kafka.common.serialization.Deserializer<?>> delegateMap, java.lang.String selector, java.lang.Class<?> clazz)
-
addDelegate
public void addDelegate(java.lang.String selector, org.apache.kafka.common.serialization.Deserializer<?> deserializer)
-
removeDelegate
@Nullable public org.apache.kafka.common.serialization.Deserializer<?> removeDelegate(java.lang.String selector)
-
deserialize
public java.lang.Object deserialize(java.lang.String topic, byte[] data)
- Specified by:
deserialize
in interfaceorg.apache.kafka.common.serialization.Deserializer<java.lang.Object>
-
deserialize
public java.lang.Object deserialize(java.lang.String topic, org.apache.kafka.common.header.Headers headers, byte[] data)
- Specified by:
deserialize
in interfaceorg.apache.kafka.common.serialization.Deserializer<java.lang.Object>
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceorg.apache.kafka.common.serialization.Deserializer<java.lang.Object>
-
-