org.springframework.jms.support.converter
Class SimpleMessageConverter

java.lang.Object
  extended byorg.springframework.jms.support.converter.SimpleMessageConverter
All Implemented Interfaces:
MessageConverter

public class SimpleMessageConverter
extends java.lang.Object
implements MessageConverter

A simple message converter that can handle TextMessages, BytesMessages, MapMessages, and ObjectMessages.

Converts a String to a JMS TextMessage, a byte array to a JMS BytesMessage, and a Map to a JMS MapMessage (and vice versa).

Since:
1.1
Author:
Juergen Hoeller
See Also:
TextMessage, BytesMessage, MapMessage, ObjectMessage

Constructor Summary
SimpleMessageConverter()
           
 
Method Summary
 java.lang.Object fromMessage(javax.jms.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.
 javax.jms.Message toMessage(java.lang.Object object, javax.jms.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleMessageConverter

public SimpleMessageConverter()
Method Detail

toMessage

public javax.jms.Message toMessage(java.lang.Object object,
                                   javax.jms.Session session)
                            throws javax.jms.JMSException,
                                   MessageConversionException
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.

Specified by:
toMessage in interface MessageConverter
Parameters:
object - the object to convert
session - the Session to use for creating a JMS Message
Returns:
the JMS Message
Throws:
javax.jms.JMSException - if thrown by JMS API methods
MessageConversionException - in case of conversion failure
See Also:
Session.createBytesMessage(), Session.createTextMessage(), Session.createObjectMessage()

fromMessage

public java.lang.Object fromMessage(javax.jms.Message message)
                             throws javax.jms.JMSException,
                                    MessageConversionException
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.

Specified by:
fromMessage in interface MessageConverter
Parameters:
message - the message to convert
Returns:
the converted Java object
Throws:
MessageConversionException - in case of conversion failure
javax.jms.JMSException


Copyright (C) 2003-2004 The Spring Framework Project.