Class DefaultJackson2JavaTypeMapper
java.lang.Object
org.springframework.amqp.support.converter.AbstractJavaTypeMapper
org.springframework.amqp.support.converter.DefaultJackson2JavaTypeMapper
- All Implemented Interfaces:
ClassMapper,Jackson2JavaTypeMapper,Aware,BeanClassLoaderAware
public class DefaultJackson2JavaTypeMapper
extends AbstractJavaTypeMapper
implements Jackson2JavaTypeMapper
Jackson 2 type mapper.
- Author:
- Mark Pollack, Sam Nelson, Andreas Asplund, Artem Bilan, Gary Russell
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.amqp.support.converter.Jackson2JavaTypeMapper
Jackson2JavaTypeMapper.TypePrecedence -
Field Summary
Fields inherited from class org.springframework.amqp.support.converter.AbstractJavaTypeMapper
DEFAULT_CLASSID_FIELD_NAME, DEFAULT_CONTENT_CLASSID_FIELD_NAME, DEFAULT_KEY_CLASSID_FIELD_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTrustedPackages(String... packages) Add trusted packages.voidfromClass(Class<?> clazz, MessageProperties properties) voidfromJavaType(com.fasterxml.jackson.databind.JavaType javaType, MessageProperties properties) Set the message properties according to the type.com.fasterxml.jackson.databind.JavaTypegetInferredType(MessageProperties properties) Return the inferred type, if the type precedence is inferred and the header is present.Return the precedence.voidsetTrustedPackages(String... trustedPackages) Specify a set of packages to trust during deserialization.voidsetTypePrecedence(Jackson2JavaTypeMapper.TypePrecedence typePrecedence) Set the precedence for evaluating type information in message properties.Class<?>toClass(MessageProperties properties) com.fasterxml.jackson.databind.JavaTypetoJavaType(MessageProperties properties) Determine the type from the message properties.Methods inherited from class org.springframework.amqp.support.converter.AbstractJavaTypeMapper
addHeader, fromInferredTypeHeader, getClassIdFieldName, getClassLoader, getContentClassIdFieldName, getIdClassMapping, getKeyClassIdFieldName, hasInferredTypeHeader, retrieveHeader, retrieveHeaderAsString, setBeanClassLoader, setIdClassMapping
-
Constructor Details
-
DefaultJackson2JavaTypeMapper
public DefaultJackson2JavaTypeMapper()
-
-
Method Details
-
getTypePrecedence
Return the precedence.- Specified by:
getTypePrecedencein interfaceJackson2JavaTypeMapper- Returns:
- the precedence.
- Since:
- 1.6.
- See Also:
-
setTypePrecedence
Set the precedence for evaluating type information in message properties. When using@RabbitListenerat the method level, the framework attempts to determine the target type for payload conversion from the method signature. If so, this type is provided in theinferredArgumentTypemessage property.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:
- 1.6
-
setTrustedPackages
Specify a set of packages to trust during deserialization. The asterisk (*) means trust all.- Parameters:
trustedPackages- the trusted Java packages for deserialization- Since:
- 1.6.11
-
addTrustedPackages
Description copied from interface:Jackson2JavaTypeMapperAdd trusted packages.- Specified by:
addTrustedPackagesin interfaceJackson2JavaTypeMapper- Parameters:
packages- the packages.
-
toJavaType
Description copied from interface:Jackson2JavaTypeMapperDetermine the type from the message properties.- Specified by:
toJavaTypein interfaceJackson2JavaTypeMapper- Parameters:
properties- the properties.- Returns:
- the type.
-
getInferredType
@Nullable public com.fasterxml.jackson.databind.JavaType getInferredType(MessageProperties properties) Description copied from interface:Jackson2JavaTypeMapperReturn the inferred type, if the type precedence is inferred and the header is present.- Specified by:
getInferredTypein interfaceJackson2JavaTypeMapper- Parameters:
properties- the message properties.- Returns:
- the type.
-
fromJavaType
public void fromJavaType(com.fasterxml.jackson.databind.JavaType javaType, MessageProperties properties) Description copied from interface:Jackson2JavaTypeMapperSet the message properties according to the type.- Specified by:
fromJavaTypein interfaceJackson2JavaTypeMapper- Parameters:
javaType- the type.properties- the properties.
-
fromClass
- Specified by:
fromClassin interfaceClassMapper
-
toClass
- Specified by:
toClassin interfaceClassMapper
-