org.exolab.jms.message
Class ObjectMessageImpl

java.lang.Object
  |
  +--org.exolab.jms.message.MessageImpl
        |
        +--org.exolab.jms.message.ObjectMessageImpl
All Implemented Interfaces:
java.lang.Cloneable, java.io.Externalizable, Identifiable, javax.jms.Message, javax.jms.ObjectMessage, java.io.Serializable

public final class ObjectMessageImpl
extends MessageImpl
implements javax.jms.ObjectMessage

This class implements the javax.jms.ObjectMessage interface.

An ObjectMessage is used to send a message that contains a serializable Java object. It inherits from Message and adds a body containing a single Java reference. Only Serializable Java objects can be used.

If a collection of Java objects must be sent, one of the collection classes provided in JDK 1.2 can be used.

When a client receives an ObjectMessage, it is in read-only mode. If a client attempts to write to the message at this point, a MessageNotWriteableException is thrown. If clearBody is called, the message can now be both read from and written to.

Version:
$Revision: 1.10 $ $Date: 2003/08/17 01:32:24 $
Author:
Jim Mourikis, Tim Anderson
See Also:
Serialized Form

Fields inherited from class org.exolab.jms.message.MessageImpl
_acceptedTime, _bodyReadOnly, _connectionId, _processed, _propertiesReadOnly, _sequenceNumber, EMPTY
 
Fields inherited from interface javax.jms.Message
DEFAULT_DELIVERY_MODE, DEFAULT_PRIORITY, DEFAULT_TIME_TO_LIVE
 
Constructor Summary
ObjectMessageImpl()
          Construct a new ObjectMessage
 
Method Summary
 void clearBody()
          Clear out the message body.
 java.lang.Object clone()
          Clone an instance of this object
 java.io.Serializable getObject()
          Get the serializable object containing this message's data.
 void readExternal(java.io.ObjectInput in)
          Serialize in this message's data
 void setObject(java.io.Serializable object)
          Set the serializable object containing this message's data.
 void writeExternal(java.io.ObjectOutput out)
          Serialize out this message's data
 
Methods inherited from class org.exolab.jms.message.MessageImpl
acknowledge, checkPropertyWrite, checkRead, checkWrite, clearProperties, getAcceptedTime, getAckMessageID, getBooleanProperty, getByteProperty, getClientId, getConnectionId, getConsumerId, getDoubleProperty, getFloatProperty, getId, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getMessageId, getObjectProperty, getProcessed, getPropertyNames, getReadOnly, getSequenceNumber, getShortProperty, getStringProperty, getWildcard, isPersistent, isPriorityExpedited, propertyExists, setAcceptedTime, setBooleanProperty, setByteProperty, setClientId, setConnectionId, setConsumerId, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setJMSXRcvTimestamp, setLongProperty, setObjectProperty, setProcessed, setReadOnly, setSequenceNumber, setSession, setShortProperty, setStringProperty, setWildcard
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jms.Message
acknowledge, clearProperties, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, propertyExists, setBooleanProperty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setShortProperty, setStringProperty
 

Constructor Detail

ObjectMessageImpl

public ObjectMessageImpl()
                  throws javax.jms.JMSException
Construct a new ObjectMessage
Throws:
javax.jms.JMSException - if the message type can't be set
Method Detail

clone

public final java.lang.Object clone()
                             throws java.lang.CloneNotSupportedException
Clone an instance of this object
Overrides:
clone in class MessageImpl
Returns:
a copy of this object
Throws:
java.lang.CloneNotSupportedException - if object or attributes aren't cloneable

writeExternal

public final void writeExternal(java.io.ObjectOutput out)
                         throws java.io.IOException
Serialize out this message's data
Overrides:
writeExternal in class MessageImpl
Parameters:
out - the stream to serialize out to
Throws:
java.io.IOException - if any I/O exceptions occurr

readExternal

public final void readExternal(java.io.ObjectInput in)
                        throws java.lang.ClassNotFoundException,
                               java.io.IOException
Serialize in this message's data
Overrides:
readExternal in class MessageImpl
Parameters:
in - the stream to serialize in from
Throws:
java.lang.ClassNotFoundException - if the class for an object being restored cannot be found.
java.io.IOException - if any I/O exceptions occur

setObject

public final void setObject(java.io.Serializable object)
                     throws javax.jms.MessageFormatException,
                            javax.jms.MessageNotWriteableException
Set the serializable object containing this message's data. It is important to note that an ObjectMessage contains a snapshot of the object at the time setObject() is called - subsequent modifications of the object will have no affect on the ObjectMessage body.
Specified by:
setObject in interface javax.jms.ObjectMessage
Parameters:
object - the message's data
Throws:
javax.jms.MessageFormatException - if object serialization fails
javax.jms.MessageNotWriteableException - if the message is read-only

getObject

public final java.io.Serializable getObject()
                                     throws javax.jms.MessageFormatException
Get the serializable object containing this message's data. The default value is null.
Specified by:
getObject in interface javax.jms.ObjectMessage
Returns:
the serializable object containing this message's data
Throws:
javax.jms.MessageFormatException - if object deserialization fails

clearBody

public final void clearBody()
                     throws javax.jms.JMSException
Clear out the message body. Clearing a message's body does not clear its header values or property entries. If this message body was read-only, calling this method leaves the message body is in the same state as an empty body in a newly created message
Specified by:
clearBody in interface javax.jms.Message
Overrides:
clearBody in class MessageImpl


Copyright © 1999-2004 The OpenJMS Group. All Rights Reserved.