java.lang.Object | |
↳ | org.springframework.jms.support.converter.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 TEXT
.
Unmarshals from a TextMessage or BytesMessage to an object.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct a new
MarshallingMessageConverter with the given Marshaller set. | |||||||||||
Construct a new
MarshallingMessageConverter with the
given Marshaller and Unmarshaller. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
| |||||||||||
This implementation unmarshals the given Message into an object.
| |||||||||||
Set the
Marshaller to be used by this message converter. | |||||||||||
Specify whether
toMessage(Object, Session) should marshal to
a BytesMessage or a TextMessage. | |||||||||||
Set the
Unmarshaller to be used by this message converter. | |||||||||||
This implementation marshals the given object to a javax.jms.TextMessage or
javax.jms.BytesMessage.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Marshal the given object to a BytesMessage.
| |||||||||||
Template method that allows for custom message marshalling.
| |||||||||||
Marshal the given object to a TextMessage.
| |||||||||||
Unmarshal the given BytesMessage into an object.
| |||||||||||
Template method that allows for custom message unmarshalling.
| |||||||||||
Unmarshal the given TextMessage into an object.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
| |||||||||||
From interface
org.springframework.jms.support.converter.MessageConverter
|
Construct a new MarshallingMessageConverter
with no Marshaller
or Unmarshaller
set.
The marshaller must be set after construction by invoking setMarshaller(Marshaller)
and
setUnmarshaller(Unmarshaller)
.
Construct a new 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 also implement the
Unmarshaller
interface, so that you can safely use this constructor.
marshaller | object used as marshaller and unmarshaller |
---|
IllegalArgumentException | when marshaller does not implement the
Unmarshaller interface as well
|
---|
Construct a new MarshallingMessageConverter
with the
given Marshaller and Unmarshaller.
marshaller | the Marshaller to use |
---|---|
unmarshaller | the Unmarshaller to use |
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
This implementation unmarshals the given Message into an object.
message | the message to convert |
---|
JMSException | |
---|---|
MessageConversionException |
Set the Marshaller
to be used by this message converter.
Set the Unmarshaller
to be used by this message converter.
This implementation marshals the given object to a javax.jms.TextMessage or
javax.jms.BytesMessage. The desired message type can be defined by setting
the "marshalTo"
property.
object | the object to convert |
---|---|
session | the Session to use for creating a JMS Message |
JMSException | |
---|---|
MessageConversionException |
Marshal the given object to a BytesMessage.
object | the object to be marshalled |
---|---|
session | current JMS session |
marshaller | the marshaller to use |
if thrown by JMS methods | |
IOException | in case of I/O errors |
XmlMappingException | in case of OXM mapping errors |
JMSException |
marshal(Object, Result)
Template method that allows for custom message marshalling.
Invoked when setTargetType(MessageType)
is not TEXT
or
BYTES
.
The default implementation throws an IllegalArgumentException
.
object | the object to marshal |
---|---|
session | the JMS session |
marshaller | the marshaller to use |
targetType | the target message type (other than TEXT or BYTES) |
if thrown by JMS methods | |
IOException | in case of I/O errors |
XmlMappingException | in case of OXM mapping errors |
JMSException |
Marshal the given object to a TextMessage.
object | the object to be marshalled |
---|---|
session | current JMS session |
marshaller | the marshaller to use |
if thrown by JMS methods | |
IOException | in case of I/O errors |
XmlMappingException | in case of OXM mapping errors |
JMSException |
marshal(Object, Result)
Unmarshal the given BytesMessage into an object.
message | the message |
---|---|
unmarshaller | the unmarshaller to use |
if thrown by JMS methods | |
IOException | in case of I/O errors |
XmlMappingException | in case of OXM mapping errors |
JMSException |
Template method that allows for custom message unmarshalling.
Invoked when fromMessage(Message)
is invoked with a message
that is not a TextMessage or BytesMessage.
The default implemenetation throws an IllegalArgumentException
.
message | the message |
---|---|
unmarshaller | the unmarshaller to use |
if thrown by JMS methods | |
IOException | in case of I/O errors |
XmlMappingException | in case of OXM mapping errors |
JMSException |
Unmarshal the given TextMessage into an object.
message | the message |
---|---|
unmarshaller | the unmarshaller to use |
if thrown by JMS methods | |
IOException | in case of I/O errors |
XmlMappingException | in case of OXM mapping errors |
JMSException |