Interface Jackson2JavaTypeMapper
-
- All Superinterfaces:
ClassMapper
- All Known Implementing Classes:
DefaultJackson2JavaTypeMapper
public interface Jackson2JavaTypeMapper extends ClassMapper
Strategy for setting metadata on messages such that one can create the class that needs to be instantiated when receiving a message.- Since:
- 2.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classJackson2JavaTypeMapper.TypePrecedenceThe precedence for type conversion - inferred from the method parameter or message headers.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddTrustedPackages(java.lang.String... packages)voidfromJavaType(com.fasterxml.jackson.databind.JavaType javaType, org.apache.kafka.common.header.Headers headers)Jackson2JavaTypeMapper.TypePrecedencegetTypePrecedence()default voidremoveHeaders(org.apache.kafka.common.header.Headers headers)Remove the type information headers.default voidsetTypePrecedence(Jackson2JavaTypeMapper.TypePrecedence typePrecedence)Set the precedence for evaluating type information in message properties.com.fasterxml.jackson.databind.JavaTypetoJavaType(org.apache.kafka.common.header.Headers headers)-
Methods inherited from interface org.springframework.kafka.support.converter.ClassMapper
fromClass, toClass
-
-
-
-
Method Detail
-
fromJavaType
void fromJavaType(com.fasterxml.jackson.databind.JavaType javaType, org.apache.kafka.common.header.Headers headers)
-
toJavaType
com.fasterxml.jackson.databind.JavaType toJavaType(org.apache.kafka.common.header.Headers headers)
-
getTypePrecedence
Jackson2JavaTypeMapper.TypePrecedence getTypePrecedence()
-
setTypePrecedence
default void setTypePrecedence(Jackson2JavaTypeMapper.TypePrecedence typePrecedence)
Set the precedence for evaluating type information in message properties. When using@KafkaListenerat the method level, the framework attempts to determine the target type for payload conversion from the method signature. If so, this type is provided by theMessagingMessageListenerAdapter.By default, if the type is concrete (not abstract, not an interface), this will be used ahead of type information provided in the
__TypeId__and associated headers provided by the sender.If you wish to force the use of the
__TypeId__and associated headers (such as when the actual type is a subclass of the method argument type), set the precedence toJackson2JavaTypeMapper.TypePrecedence.TYPE_ID.- Parameters:
typePrecedence- the precedence.- Since:
- 2.2
-
addTrustedPackages
void addTrustedPackages(java.lang.String... packages)
-
removeHeaders
default void removeHeaders(org.apache.kafka.common.header.Headers headers)
Remove the type information headers.- Parameters:
headers- the headers.- Since:
- 2.2
-
-