Class DefaultJacksonJavaTypeMapper

java.lang.Object
org.springframework.amqp.support.converter.DefaultJacksonJavaTypeMapper
All Implemented Interfaces:
ClassMapper, JacksonJavaTypeMapper, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware

public class DefaultJacksonJavaTypeMapper extends Object implements JacksonJavaTypeMapper, org.springframework.beans.factory.BeanClassLoaderAware
Jackson 3 type mapper.
Since:
4.0
  • Field Details

  • Constructor Details

    • DefaultJacksonJavaTypeMapper

      public DefaultJacksonJavaTypeMapper()
  • Method Details

    • getClassIdFieldName

      public String getClassIdFieldName()
    • getContentClassIdFieldName

      public String getContentClassIdFieldName()
    • getKeyClassIdFieldName

      public String getKeyClassIdFieldName()
    • setIdClassMapping

      public void setIdClassMapping(Map<String,Class<?>> idClassMapping)
    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader classLoader)
      Specified by:
      setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware
    • getClassLoader

      protected @Nullable ClassLoader getClassLoader()
    • addHeader

      protected void addHeader(MessageProperties properties, String headerName, Class<?> clazz)
    • retrieveHeader

      protected String retrieveHeader(MessageProperties properties, String headerName)
    • retrieveHeaderAsString

      protected @Nullable String retrieveHeaderAsString(MessageProperties properties, String headerName)
    • getIdClassMapping

      public Map<String,Class<?>> getIdClassMapping()
    • hasInferredTypeHeader

      protected boolean hasInferredTypeHeader(MessageProperties properties)
    • fromInferredTypeHeader

      protected tools.jackson.databind.JavaType fromInferredTypeHeader(MessageProperties properties)
    • getTypePrecedence

      public JacksonJavaTypeMapper.TypePrecedence getTypePrecedence()
      Return the precedence.
      Specified by:
      getTypePrecedence in interface JacksonJavaTypeMapper
      Returns:
      the precedence.
      See Also:
    • setTypePrecedence

      public void setTypePrecedence(JacksonJavaTypeMapper.TypePrecedence typePrecedence)
      Set the precedence for evaluating type information in message properties. When using @RabbitListener at 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 the inferredArgumentType message 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 to JacksonJavaTypeMapper.TypePrecedence.TYPE_ID.

      Parameters:
      typePrecedence - the precedence.
    • setTrustedPackages

      public void setTrustedPackages(String @Nullable ... trustedPackages)
      Specify a set of packages to trust during deserialization. The asterisk (*) means trust all.
      Parameters:
      trustedPackages - the trusted Java packages for deserialization
    • addTrustedPackages

      public void addTrustedPackages(String @Nullable ... packages)
      Description copied from interface: JacksonJavaTypeMapper
      Add trusted packages.
      Specified by:
      addTrustedPackages in interface JacksonJavaTypeMapper
      Parameters:
      packages - the packages.
    • toJavaType

      public tools.jackson.databind.JavaType toJavaType(MessageProperties properties)
      Description copied from interface: JacksonJavaTypeMapper
      Determine the type from the message properties.
      Specified by:
      toJavaType in interface JacksonJavaTypeMapper
      Parameters:
      properties - the properties.
      Returns:
      the type.
    • getInferredType

      public @Nullable tools.jackson.databind.JavaType getInferredType(MessageProperties properties)
      Description copied from interface: JacksonJavaTypeMapper
      Return the inferred type, if the type precedence is inferred and the header is present.
      Specified by:
      getInferredType in interface JacksonJavaTypeMapper
      Parameters:
      properties - the message properties.
      Returns:
      the type.
    • fromJavaType

      public void fromJavaType(tools.jackson.databind.JavaType javaType, MessageProperties properties)
      Description copied from interface: JacksonJavaTypeMapper
      Set the message properties according to the type.
      Specified by:
      fromJavaType in interface JacksonJavaTypeMapper
      Parameters:
      javaType - the type.
      properties - the properties.
    • fromClass

      public void fromClass(Class<?> clazz, MessageProperties properties)
      Specified by:
      fromClass in interface ClassMapper
    • toClass

      public Class<?> toClass(MessageProperties properties)
      Specified by:
      toClass in interface ClassMapper