public class WrappingObjectMessage extends DelegateMessage implements ObjectMessage
DEFAULT_DELIVERY_DELAY, DEFAULT_DELIVERY_MODE, DEFAULT_PRIORITY, DEFAULT_TIME_TO_LIVE
Constructor and Description |
---|
WrappingObjectMessage(ObjectMessage message) |
Modifier and Type | Method and Description |
---|---|
<T> T |
getBody(java.lang.Class<T> c)
Returns the message body as an object of the specified type.
|
java.io.Serializable |
getObject()
Gets the serializable object containing this message's data.
|
boolean |
isBodyAssignableTo(java.lang.Class c)
Returns whether the message body is capable of being assigned to the specified type.
|
void |
setObject(java.io.Serializable object)
Sets the serializable object containing this message's data.
|
acknowledge, clearBody, clearProperties, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDeliveryTime, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, propertyExists, setBooleanProperty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDeliveryTime, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setShortProperty, setStringProperty, unwrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
acknowledge, clearBody, clearProperties, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDeliveryTime, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, propertyExists, setBooleanProperty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDeliveryTime, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setShortProperty, setStringProperty
public WrappingObjectMessage(ObjectMessage message)
public boolean isBodyAssignableTo(java.lang.Class c) throws JMSException
Message
getBody
on the same message with the same type argument would not throw a
MessageFormatException.
If the message is a StreamMessage
then false is always returned. If the message is a ObjectMessage
and object deserialization fails then false is returned. If the message has no body then any type may be specified
and true is returned.
isBodyAssignableTo
in interface Message
isBodyAssignableTo
in class DelegateMessage
c
- The specified type TextMessage
then this method will only return true if this parameter is set to
String.class
or another type to which a String
is assignable. ObjectMessage
then this method will only return true if this parameter is set to
java.io.Serializable.class
or another class to which the body is assignable. MapMessage
then this method will only return true if this parameter is set to
java.util.Map.class
(or java.lang.Object.class
). BytesMessage
then this this method will only return true if this parameter is set to
byte[].class
(or java.lang.Object.class
). TextMessage
, ObjectMessage
, MapMessage
or BytesMessage
and the
message has no body, then the above does not apply and this method will return true irrespective of the value of this
parameter.Message
(but not one of its subtypes) then this method will return true irrespective of
the value of this parameter.JMSException
- if the JMS provider fails to return a value due to some internal error.public <T> T getBody(java.lang.Class<T> c) throws JMSException
Message
getBody
in interface Message
getBody
in class DelegateMessage
T
- The type of the message bodyc
- The type to which the message body will be assigned. TextMessage
then this parameter must be set to String.class
or another type to
which a String
is assignable. ObjectMessage
then parameter must must be set to java.io.Serializable.class
or
another type to which the body is assignable. MapMessage
then this parameter must be set to java.util.Map.class
(or
java.lang.Object.class
). BytesMessage
then this parameter must be set to byte[].class
(or
java.lang.Object.class
). This method will reset the BytesMessage
before and after use.TextMessage
, ObjectMessage
, MapMessage
or BytesMessage
and the
message has no body, then the above does not apply and this parameter may be set to any type; the returned value will
always be null.Message
(but not one of its subtypes) then this parameter may be set to any type; the
returned value will always be null.MessageFormatException
- StreamMessage
ObjectMessage
and object deserialization fails.
JMSException
- if the JMS provider fails to get the message body due to some internal error.public void setObject(java.io.Serializable object) throws JMSException
ObjectMessage
ObjectMessage
contains a snapshot of the object at the time setObject()
is called; subsequent modifications of the object
will have no effect on the ObjectMessage
body.setObject
in interface ObjectMessage
object
- the message's dataJMSException
- if the JMS provider fails to set the object due to some internal error.MessageFormatException
- if object serialization fails.MessageNotWriteableException
- if the message is in read-only mode.public java.io.Serializable getObject() throws JMSException
ObjectMessage
getObject
in interface ObjectMessage
JMSException
- if the JMS provider fails to get the object due to some internal error.MessageFormatException
- if object deserialization fails.