java.lang.Object |
↳ |
org.springframework.jms.support.converter.SimpleMessageConverter |
Known Direct Subclasses
|
Class Overview
A simple message converter which is able to handle TextMessages, BytesMessages,
MapMessages, and ObjectMessages. Used as default conversion strategy
by JmsTemplate
, for
convertAndSend
and receiveAndConvert
operations.
Converts a String to a javax.jms.TextMessage, a byte array to a
javax.jms.BytesMessage, a Map to a javax.jms.MapMessage, and
a Serializable object to a javax.jms.ObjectMessage (or vice versa).
Summary
Public Methods |
Object
|
fromMessage(Message message)
This implementation converts a TextMessage back to a String, a
ByteMessage back to a byte array, a MapMessage back to a Map,
and an ObjectMessage back to a Serializable object.
|
Message
|
toMessage(Object object, Session session)
This implementation creates a TextMessage for a String, a
BytesMessage for a byte array, a MapMessage for a Map,
and an ObjectMessage for a Serializable object.
|
Public Constructors
public
SimpleMessageConverter
()
Public Methods
public
Object
fromMessage
(Message message)
This implementation converts a TextMessage back to a String, a
ByteMessage back to a byte array, a MapMessage back to a Map,
and an ObjectMessage back to a Serializable object. Returns
the plain Message object in case of an unknown message type.
Parameters
message
| the message to convert |
Returns
- the converted Java object
public
Message
toMessage
(Object object, Session session)
This implementation creates a TextMessage for a String, a
BytesMessage for a byte array, a MapMessage for a Map,
and an ObjectMessage for a Serializable object.
Parameters
object
| the object to convert |
session
| the Session to use for creating a JMS Message |
Protected Methods
protected
BytesMessage
createMessageForByteArray
(byte[] bytes, Session session)
Create a JMS BytesMessage for the given byte array.
Parameters
bytes
| the byyte array to convert |
session
| current JMS session |
Throws
| if thrown by JMS methods |
JMSException
| |
See Also
- javax.jms.Session#createBytesMessage
protected
MapMessage
createMessageForMap
(Map<?, ?> map, Session session)
Create a JMS MapMessage for the given Map.
Parameters
map
| the Map to convert |
session
| current JMS session |
Throws
| if thrown by JMS methods |
JMSException
| |
See Also
- javax.jms.Session#createMapMessage
protected
ObjectMessage
createMessageForSerializable
(Serializable object, Session session)
Create a JMS ObjectMessage for the given Serializable object.
Parameters
object
| the Serializable object to convert |
session
| current JMS session |
Throws
| if thrown by JMS methods |
JMSException
| |
See Also
- javax.jms.Session#createObjectMessage
protected
TextMessage
createMessageForString
(String text, Session session)
Create a JMS TextMessage for the given String.
Parameters
text
| the String to convert |
session
| current JMS session |
Throws
| if thrown by JMS methods |
JMSException
| |
See Also
- javax.jms.Session#createTextMessage
protected
byte[]
extractByteArrayFromMessage
(BytesMessage message)
Extract a byte array from the given BytesMessage.
Parameters
message
| the message to convert |
Throws
| if thrown by JMS methods
|
JMSException
| |
protected
Map
extractMapFromMessage
(MapMessage message)
Extract a Map from the given MapMessage.
Parameters
message
| the message to convert |
Throws
| if thrown by JMS methods
|
JMSException
| |
protected
Serializable
extractSerializableFromMessage
(ObjectMessage message)
Extract a Serializable object from the given ObjectMessage.
Parameters
message
| the message to convert |
Returns
- the resulting Serializable object
Throws
| if thrown by JMS methods
|
JMSException
| |
protected
String
extractStringFromMessage
(TextMessage message)
Extract a String from the given TextMessage.
Parameters
message
| the message to convert |
Throws
| if thrown by JMS methods
|
JMSException
| |