Maps an object to a BytesMessage, or to a TextMessage if the
targetType is set to MessageType#TEXT.
Converts from a TextMessage or BytesMessage to an object.
It customizes Jackson's default properties with the following ones:
MapperFeature#DEFAULT_VIEW_INCLUSION is disabledDeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES is disabled| Modifier and Type | Field and Description |
|---|---|
| private ClassLoader | |
| private final Map | |
| public static final String | DEFAULT_ENCODING
The default encoding used for writing to text messages: UTF-8. |
| private String | |
| private String | |
| private Map | |
| private ObjectMapper | |
| private MessageType | |
| private String |
| Access | Constructor and Description |
|---|---|
| public | MappingJackson2MessageConverter()
Construct a |
| public | MappingJackson2MessageConverter(ObjectMapper
the objectMapper)ObjectMapper to useConstruct a |
| Modifier and Type | Method and Description |
|---|---|
| protected Object | Returns: the message converted to an objectthe input message message, JavaType the target type targetJavaType)Convert a BytesMessage to a Java Object with the specified type. |
| protected Object | Returns: the message converted to an objectthe input message message, JavaType the target type targetJavaType)Template method that allows for custom message mapping. |
| protected Object | Returns: the message converted to an objectthe input message message, JavaType the target type targetJavaType)Convert a TextMessage to a Java Object with the specified type. |
| private Object | convertToObject(Message message, JavaType targetJavaType)
Convenience method to dispatch to converters for individual message types. |
| private Class | |
| public Object | fromMessage(Message
the message to convert message)Implements org. Convert from a JMS Message to a Java object. |
| protected JavaType | getJavaTypeForMessage(Message
the JMS Message from which to get the type id property message)Determine a Jackson JavaType for the given JMS Message, typically parsing a type id message property. |
| protected Class | Returns: the serialization view class, ornull if nonethe conversion hint Object as passed into the
converter for the current conversion attempt conversionHint)Determine a Jackson serialization view based on the given conversion hint. |
| protected BytesMessage | Returns: the resulting messagethe object to be mapped object, Session current JMS session session, ObjectWriter the writer to use objectWriter)Map the given object to a |
| protected Message | Returns: the resulting messagethe object to marshal object, Session the JMS Session session, ObjectWriter the writer to use objectWriter, MessageType the target message type (other than TEXT or BYTES) targetType)Template method that allows for custom message mapping. |
| protected TextMessage | Returns: the resulting messagethe object to be mapped object, Session current JMS session session, ObjectWriter the writer to use objectWriter)Map the given object to a |
| public void | setBeanClassLoader(ClassLoader
the owning class loader classLoader)Implements org. Callback that supplies the bean |
| public void | setEncoding(String encoding)
Specify the encoding to use when converting to and from text-based message body content. |
| public void | setEncodingPropertyName(String encodingPropertyName)
Specify the name of the JMS message property that carries the encoding from bytes to String and back is BytesMessage is used during the conversion process. |
| public void | |
| public void | setTargetType(MessageType targetType)
Specify whether |
| public void | setTypeIdMappings(Map<String, Class<?>>
a Map with type id values as keys and Java classes as values typeIdMappings)Specify mappings from type ids to Java classes, if desired. |
| protected void | setTypeIdOnMessage(Object
the payload object to set a type id for object, Message the JMS Message on which to set the type id property message)Set a type id for the given payload object on the given JMS Message. |
| public void | setTypeIdPropertyName(String typeIdPropertyName)
Specify the name of the JMS message property that carries the type id for the contained object: either a mapped id value or a raw Java class name. |
| public Message | toMessage(Object
the object to convert object, Session the Session to use for creating a JMS Message session)Implements org. Convert a Java object to a JMS Message using the supplied session to create the message object. |
| public Message | toMessage(Object
the object to convert object, Session the Session to use for creating a JMS Message session, Object conversionHint)Implements org. A variant of |
| public Message | Returns: the JMS Messagethe object to convert object, Session the Session to use for creating a JMS Message session, Class<?> the view to use to filter the content jsonView)Convert a Java object to a JMS Message using the specified json view and the supplied session to create the message object. |
| protected Message |
| beanClassLoader | back to summary |
|---|---|
| private ClassLoader beanClassLoader
| |
| classIdMappings | back to summary |
|---|---|
| private final Map<Class<?>, String> classIdMappings | |
| DEFAULT_ENCODING | back to summary |
|---|---|
| public static final String DEFAULT_ENCODING The default encoding used for writing to text messages: UTF-8. | |
| encoding | back to summary |
|---|---|
| private String encoding
| |
| encodingPropertyName | back to summary |
|---|---|
| private String encodingPropertyName
| |
| idClassMappings | back to summary |
|---|---|
| private Map<String, Class<?>> idClassMappings | |
| objectMapper | back to summary |
|---|---|
| private ObjectMapper objectMapper | |
| targetType | back to summary |
|---|---|
| private MessageType targetType | |
| typeIdPropertyName | back to summary |
|---|---|
| private String typeIdPropertyName
| |
| MappingJackson2MessageConverter | back to summary |
|---|---|
| public MappingJackson2MessageConverter() Construct a
| |
| MappingJackson2MessageConverter | back to summary |
|---|---|
| public MappingJackson2MessageConverter(ObjectMapper objectMapper) Construct a
| |
| convertFromBytesMessage | back to summary |
|---|---|
| protected Object convertFromBytesMessage(BytesMessage message, JavaType targetJavaType) throws JMSException, IOException Convert a BytesMessage to a Java Object with the specified type.
| |
| convertFromMessage | back to summary |
|---|---|
| protected Object convertFromMessage(Message message, JavaType targetJavaType) throws JMSException, IOException Template method that allows for custom message mapping.
Invoked when The default implementation throws an
| |
| convertFromTextMessage | back to summary |
|---|---|
| protected Object convertFromTextMessage(TextMessage message, JavaType targetJavaType) throws JMSException, IOException Convert a TextMessage to a Java Object with the specified type.
| |
| convertToObject | back to summary |
|---|---|
| private Object convertToObject(Message message, JavaType targetJavaType) throws JMSException, IOException Convenience method to dispatch to converters for individual message types. | |
| extractViewClass | back to summary |
|---|---|
| private Class | |
| fromMessage | back to summary |
|---|---|
| public Object fromMessage(Message message) throws JMSException, MessageConversionException Implements org. Doc from org. Convert from a JMS Message to a Java object.
| |
| getJavaTypeForMessage | back to summary |
|---|---|
| protected JavaType getJavaTypeForMessage(Message message) throws JMSException Determine a Jackson JavaType for the given JMS Message, typically parsing a type id message property. The default implementation parses the configured type id property name and consults the configured type id mapping. This can be overridden with a different strategy, e.g. doing some heuristics based on message origin.
| |
| getSerializationView | back to summary |
|---|---|
| protected Class Determine a Jackson serialization view based on the given conversion hint. | |
| mapToBytesMessage | back to summary |
|---|---|
| protected BytesMessage mapToBytesMessage(Object object, Session session, ObjectWriter objectWriter) throws JMSException, IOException Map the given object to a
| |
| mapToMessage | back to summary |
|---|---|
| protected Message mapToMessage(Object object, Session session, ObjectWriter objectWriter, MessageType targetType) throws JMSException, IOException Template method that allows for custom message mapping.
Invoked when The default implementation throws an
| |
| mapToTextMessage | back to summary |
|---|---|
| protected TextMessage mapToTextMessage(Object object, Session session, ObjectWriter objectWriter) throws JMSException, IOException Map the given object to a
| |
| setBeanClassLoader | back to summary |
|---|---|
| public void setBeanClassLoader(ClassLoader classLoader) Implements org. Doc from org. Callback that supplies the bean Invoked after the population of normal bean properties but
before an initialization callback such as
| |
| setEncoding | back to summary |
|---|---|
| public void setEncoding(String encoding) Specify the encoding to use when converting to and from text-based message body content. The default encoding will be "UTF-8". When reading from a text-based message, an encoding may have been suggested through a special JMS property which will then be preferred over the encoding set on this MessageConverter instance.
| |
| setEncodingPropertyName | back to summary |
|---|---|
| public void setEncodingPropertyName(String encodingPropertyName) Specify the name of the JMS message property that carries the encoding from bytes to String and back is BytesMessage is used during the conversion process. Default is none. Setting this property is optional; if not set, UTF-8 will be used for decoding any incoming bytes message.
| |
| setObjectMapper | back to summary |
|---|---|
| public void setObjectMapper(ObjectMapper objectMapper) Set the If not set, a default | |
| setTargetType | back to summary |
|---|---|
| public void setTargetType(MessageType targetType) Specify whether The default is
| |
| setTypeIdMappings | back to summary |
|---|---|
| public void setTypeIdMappings(Map<String, Class<?>> typeIdMappings) Specify mappings from type ids to Java classes, if desired. This allows for synthetic ids in the type id message property, instead of transferring Java class names. Default is no custom mappings, i.e. transferring raw Java class names. | |
| setTypeIdOnMessage | back to summary |
|---|---|
| protected void setTypeIdOnMessage(Object object, Message message) throws JMSException Set a type id for the given payload object on the given JMS Message. The default implementation consults the configured type id mapping and sets the resulting value (either a mapped id or the raw Java class name) into the configured type id message property.
| |
| setTypeIdPropertyName | back to summary |
|---|---|
| public void setTypeIdPropertyName(String typeIdPropertyName) Specify the name of the JMS message property that carries the type id for the contained object: either a mapped id value or a raw Java class name. Default is none. Note This property needs to be set in order to allow for converting from an incoming message to a Java object.
| |
| toMessage | back to summary |
|---|---|
| public Message toMessage(Object object, Session session) throws JMSException, MessageConversionException Implements org. Doc from org. Convert a Java object to a JMS Message using the supplied session to create the message object.
| |
| toMessage | back to summary |
|---|---|
| public Message toMessage(Object object, Session session, Object conversionHint) throws JMSException, MessageConversionException Implements org. Doc from org. A variant of
| |
| toMessage | back to summary |
|---|---|
| public Message toMessage(Object object, Session session, Class<?> jsonView) throws JMSException, MessageConversionException Convert a Java object to a JMS Message using the specified json view and the supplied session to create the message object.
| |
| toMessage | back to summary |
|---|---|
| protected Message toMessage(Object object, Session session, ObjectWriter objectWriter) throws JMSException, MessageConversionException | |