|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.oxm.support.MarshallingMessageConverter
public class MarshallingMessageConverter
Spring JMS MessageConverter that uses a Marshaller and Unmarshaller. Marshals an object to a
BytesMessage, or to a TextMessage if the marshalTo is set to MARSHAL_TO_TEXT_MESSAGE. Unmarshals from a TextMessage or BytesMessage to an object.
org.springframework.jms.core.JmsTemplate#convertAndSend,
org.springframework.jms.core.JmsTemplate#receiveAndConvert| Field Summary | |
|---|---|
static int |
MARSHAL_TO_BYTES_MESSAGE
Constant that indicates that toMessage(Object, Session) should marshal to a BytesMessage. |
static int |
MARSHAL_TO_TEXT_MESSAGE
Constant that indicates that toMessage(Object, Session) should marshal to a TextMessage. |
| Constructor Summary | |
|---|---|
MarshallingMessageConverter()
Constructs a new MarshallingMessageConverter with no Marshaller set. |
|
MarshallingMessageConverter(Marshaller marshaller)
Constructs a new MarshallingMessageConverter with the given Marshaller set. |
|
MarshallingMessageConverter(Marshaller marshaller,
Unmarshaller unmarshaller)
Creates a new MarshallingMessageConverter with the given marshaller and unmarshaller. |
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
|
java.lang.Object |
fromMessage(javax.jms.Message message)
Unmarshals the given Message into an object. |
protected javax.jms.BytesMessage |
marshalToBytesMessage(java.lang.Object object,
javax.jms.Session session,
Marshaller marshaller)
Marshals the given object to a BytesMessage. |
protected javax.jms.Message |
marshalToMessage(java.lang.Object object,
javax.jms.Session session,
Marshaller marshaller)
Template method that allows for custom message marshalling. |
protected javax.jms.TextMessage |
marshalToTextMessage(java.lang.Object object,
javax.jms.Session session,
Marshaller marshaller)
Marshals the given object to a TextMessage. |
void |
setMarshaller(Marshaller marshaller)
Sets the Marshaller to be used by this message converter. |
void |
setMarshalTo(int marshalTo)
Indicates whether toMessage(Object,Session) should marshal to a BytesMessage or a TextMessage. |
void |
setUnmarshaller(Unmarshaller unmarshaller)
Sets the Unmarshaller to be used by this message converter. |
javax.jms.Message |
toMessage(java.lang.Object object,
javax.jms.Session session)
Marshals the given object to a TextMessage or BytesMessage. |
protected java.lang.Object |
unmarshalFromBytesMessage(javax.jms.BytesMessage message,
Unmarshaller unmarshaller)
Unmarshals the given BytesMessage into an object. |
protected java.lang.Object |
unmarshalFromMessage(javax.jms.Message message,
Unmarshaller unmarshaller)
Template method that allows for custom message unmarshalling. |
protected java.lang.Object |
unmarshalFromTextMessage(javax.jms.TextMessage message,
Unmarshaller unmarshaller)
Unmarshals the given TextMessage into an object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MARSHAL_TO_BYTES_MESSAGE
toMessage(Object, Session) should marshal to a BytesMessage.
public static final int MARSHAL_TO_TEXT_MESSAGE
toMessage(Object, Session) should marshal to a TextMessage.
| Constructor Detail |
|---|
public MarshallingMessageConverter()
MarshallingMessageConverter with no Marshaller set. The marshaller must be
set after construction by invoking setMarshaller(Marshaller).
public MarshallingMessageConverter(Marshaller marshaller)
MarshallingMessageConverter with the given Marshaller set. If the given
Marshaller also implements the Unmarshaller interface, it is used for both marshalling and
unmarshalling. Otherwise, an exception is thrown.
Note that all Marshaller implementations in Spring-WS also implement the Unmarshaller interface,
so that you can safely use this constructor.
marshaller - object used as marshaller and unmarshaller
java.lang.IllegalArgumentException - when marshaller does not implement the Unmarshaller
interface
public MarshallingMessageConverter(Marshaller marshaller,
Unmarshaller unmarshaller)
MarshallingMessageConverter with the given marshaller and unmarshaller.
marshaller - the marshaller to useunmarshaller - the unmarshaller to use| Method Detail |
|---|
public void setMarshalTo(int marshalTo)
toMessage(Object,Session) should marshal to a BytesMessage or a TextMessage. The default is MARSHAL_TO_BYTES_MESSAGE, i.e. this converter marshals to a BytesMessage.
MARSHAL_TO_BYTES_MESSAGE,
MARSHAL_TO_TEXT_MESSAGEpublic void setMarshaller(Marshaller marshaller)
Marshaller to be used by this message converter.
public void setUnmarshaller(Unmarshaller unmarshaller)
Unmarshaller to be used by this message converter.
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exception
public javax.jms.Message toMessage(java.lang.Object object,
javax.jms.Session session)
throws javax.jms.JMSException,
org.springframework.jms.support.converter.MessageConversionException
TextMessage or BytesMessage. The desired message type
can be defined by setting the marshalTo property.
toMessage in interface org.springframework.jms.support.converter.MessageConverterjavax.jms.JMSException
org.springframework.jms.support.converter.MessageConversionExceptionmarshalToTextMessage(java.lang.Object, javax.jms.Session, org.springframework.oxm.Marshaller),
marshalToBytesMessage(java.lang.Object, javax.jms.Session, org.springframework.oxm.Marshaller)
public java.lang.Object fromMessage(javax.jms.Message message)
throws javax.jms.JMSException,
org.springframework.jms.support.converter.MessageConversionException
Message into an object.
fromMessage in interface org.springframework.jms.support.converter.MessageConverterjavax.jms.JMSException
org.springframework.jms.support.converter.MessageConversionExceptionunmarshalFromTextMessage(javax.jms.TextMessage, org.springframework.oxm.Unmarshaller),
unmarshalFromBytesMessage(javax.jms.BytesMessage, org.springframework.oxm.Unmarshaller)
protected javax.jms.TextMessage marshalToTextMessage(java.lang.Object object,
javax.jms.Session session,
Marshaller marshaller)
throws javax.jms.JMSException,
java.io.IOException
TextMessage.
object - the object to be marshalledsession - current JMS sessionmarshaller - the marshaller to use
javax.jms.JMSException - if thrown by JMS methods
java.io.IOException - in case of I/O errorsSession.createTextMessage(),
Marshaller.marshal(Object, Result)
protected javax.jms.BytesMessage marshalToBytesMessage(java.lang.Object object,
javax.jms.Session session,
Marshaller marshaller)
throws javax.jms.JMSException,
java.io.IOException
BytesMessage.
object - the object to be marshalledsession - current JMS sessionmarshaller - the marshaller to use
javax.jms.JMSException - if thrown by JMS methods
java.io.IOException - in case of I/O errorsSession.createBytesMessage(),
Marshaller.marshal(Object, Result)
protected javax.jms.Message marshalToMessage(java.lang.Object object,
javax.jms.Session session,
Marshaller marshaller)
throws javax.jms.JMSException,
java.io.IOException
setMarshalTo(int) is not MARSHAL_TO_TEXT_MESSAGE or MARSHAL_TO_BYTES_MESSAGE.
Default implemenetation throws a MessageConversionException.
object - the object to marshalsession - the JMS sessionmarshaller - the marshaller to use
javax.jms.JMSException - if thrown by JMS methods
java.io.IOException - in case of I/O errors
protected java.lang.Object unmarshalFromTextMessage(javax.jms.TextMessage message,
Unmarshaller unmarshaller)
throws javax.jms.JMSException,
java.io.IOException
TextMessage into an object.
message - the messageunmarshaller - the unmarshaller to use
javax.jms.JMSException - if thrown by JMS methods
java.io.IOException - in case of I/O errorsUnmarshaller.unmarshal(Source)
protected java.lang.Object unmarshalFromBytesMessage(javax.jms.BytesMessage message,
Unmarshaller unmarshaller)
throws javax.jms.JMSException,
java.io.IOException
BytesMessage into an object.
message - the messageunmarshaller - the unmarshaller to use
javax.jms.JMSException - if thrown by JMS methods
java.io.IOException - in case of I/O errorsUnmarshaller.unmarshal(Source)
protected java.lang.Object unmarshalFromMessage(javax.jms.Message message,
Unmarshaller unmarshaller)
throws javax.jms.JMSException,
java.io.IOException
fromMessage(Message) is
invoked with a message that is not a TextMessage or BytesMessage.
Default implemenetation throws a MessageConversionException.
message - the messageunmarshaller - the unmarshaller to use
javax.jms.JMSException - if thrown by JMS methods
java.io.IOException - in case of I/O errors
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||