| java.lang.Object org.springframework.jms.support.converter.SimpleMessageConverter
All known Subclasses: org.springframework.jms.support.converter.SimpleMessageConverter102,
SimpleMessageConverter | public class SimpleMessageConverter implements MessageConverter(Code) | | A simple message converter which is able to handle TextMessages, BytesMessages,
MapMessages, and ObjectMessages. Used as default conversion strategy
by
org.springframework.jms.core.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).
This converter implementation works for both JMS 1.1 and JMS 1.0.2,
except when extracting a byte array from a BytesMessage. So for converting
BytesMessages with a JMS 1.0.2 provider, use
SimpleMessageConverter102 .
(As you would expect,
org.springframework.jms.core.JmsTemplate102 uses SimpleMessageConverter102 as default.)
author: Juergen Hoeller since: 1.1 See Also: org.springframework.jms.core.JmsTemplate.convertAndSend See Also: org.springframework.jms.core.JmsTemplate.receiveAndConvert |
Method Summary | |
protected BytesMessage | createMessageForByteArray(byte[] bytes, Session session) Create a JMS BytesMessage for the given byte array. | protected MapMessage | createMessageForMap(Map map, Session session) Create a JMS MapMessage for the given Map. | protected ObjectMessage | createMessageForSerializable(Serializable object, Session session) Create a JMS ObjectMessage for the given Serializable object. | protected TextMessage | createMessageForString(String text, Session session) Create a JMS TextMessage for the given String. | protected byte[] | extractByteArrayFromMessage(BytesMessage message) Extract a byte array from the given
BytesMessage . | protected Map | extractMapFromMessage(MapMessage message) Extract a Map from the given
MapMessage . | protected Serializable | extractSerializableFromMessage(ObjectMessage message) Extract a Serializable object from the given
ObjectMessage . | protected String | extractStringFromMessage(TextMessage message) Extract a String from the given TextMessage. | 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. | 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. |
createMessageForByteArray | protected BytesMessage createMessageForByteArray(byte[] bytes, Session session) throws JMSException(Code) | | Create a JMS BytesMessage for the given byte array.
Parameters: bytes - the byyte array to convert Parameters: session - current JMS session the resulting message throws: JMSException - if thrown by JMS methods See Also: javax.jms.Session.createBytesMessage |
createMessageForMap | protected MapMessage createMessageForMap(Map map, Session session) throws JMSException(Code) | | Create a JMS MapMessage for the given Map.
Parameters: map - the Map to convert Parameters: session - current JMS session the resulting message throws: JMSException - if thrown by JMS methods See Also: javax.jms.Session.createMapMessage |
createMessageForSerializable | protected ObjectMessage createMessageForSerializable(Serializable object, Session session) throws JMSException(Code) | | Create a JMS ObjectMessage for the given Serializable object.
Parameters: object - the Serializable object to convert Parameters: session - current JMS session the resulting message throws: JMSException - if thrown by JMS methods See Also: javax.jms.Session.createObjectMessage |
createMessageForString | protected TextMessage createMessageForString(String text, Session session) throws JMSException(Code) | | Create a JMS TextMessage for the given String.
Parameters: text - the String to convert Parameters: session - current JMS session the resulting message throws: JMSException - if thrown by JMS methods See Also: javax.jms.Session.createTextMessage |
extractByteArrayFromMessage | protected byte[] extractByteArrayFromMessage(BytesMessage message) throws JMSException(Code) | | Extract a byte array from the given
BytesMessage .
Parameters: message - the message to convert the resulting byte array throws: JMSException - if thrown by JMS methods |
extractMapFromMessage | protected Map extractMapFromMessage(MapMessage message) throws JMSException(Code) | | Extract a Map from the given
MapMessage .
Parameters: message - the message to convert the resulting Map throws: JMSException - if thrown by JMS methods |
extractSerializableFromMessage | protected Serializable extractSerializableFromMessage(ObjectMessage message) throws JMSException(Code) | | Extract a Serializable object from the given
ObjectMessage .
Parameters: message - the message to convert the resulting Serializable object throws: JMSException - if thrown by JMS methods |
extractStringFromMessage | protected String extractStringFromMessage(TextMessage message) throws JMSException(Code) | | Extract a String from the given TextMessage.
Parameters: message - the message to convert the resulting String throws: JMSException - if thrown by JMS methods |
|
|