org.exolab.jms.message
Class MessageImpl

java.lang.Object
  extended by org.exolab.jms.message.MessageImpl
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, javax.jms.Message
Direct Known Subclasses:
BytesMessageImpl, MapMessageImpl, ObjectMessageImpl, StreamMessageImpl, TextMessageImpl

public class MessageImpl
extends java.lang.Object
implements javax.jms.Message, java.io.Externalizable, java.lang.Cloneable

This class implements the javax.jms.Message interface.

Version:
$Revision: 1.2 $ $Date: 2005/03/18 03:50:12 $
Author:
Jim Mourikis
See Also:
Message, Serialized Form

Field Summary
protected  long _acceptedTime
          The time that the message was accepted by the server.
protected  boolean _bodyReadOnly
          If true, the message body is read-only.
protected  long _connectionId
          The identity of the connection that this was received on.
protected  boolean _processed
          This flag indicates that the message has been processed by the provider.
protected  boolean _propertiesReadOnly
          If true, message properties are read-only.
protected  long _sequenceNumber
          The sequence number assigned to the message by server when the message is accepted.
protected static byte[] EMPTY
          Empty byte array for initialisation purposes.
 
Fields inherited from interface javax.jms.Message
DEFAULT_DELIVERY_MODE, DEFAULT_PRIORITY, DEFAULT_TIME_TO_LIVE
 
Constructor Summary
MessageImpl()
          Default constructor, required to support externalization.
 
Method Summary
 void acknowledge()
          Acknowledge the message through the session that dispatched it.
 void checkPropertyWrite()
           
 void checkRead()
           
 void checkWrite()
           
 void clearBody()
           
 void clearProperties()
           
 java.lang.Object clone()
          Clone an instance of this object.
 long getAcceptedTime()
          Return the time that the messages was accepted by the server
 java.lang.String getAckMessageID()
          Returns the identifier of the message for acknowledgment.
 boolean getBooleanProperty(java.lang.String name)
           
 byte getByteProperty(java.lang.String name)
           
 long getConnectionId()
          Return the id of the connection that this messaged was received on
 long getConsumerId()
          Returns the value of the consumer identifier
 double getDoubleProperty(java.lang.String name)
           
 float getFloatProperty(java.lang.String name)
           
 java.lang.String getId()
           
 int getIntProperty(java.lang.String name)
           
 java.lang.String getJMSCorrelationID()
           
 byte[] getJMSCorrelationIDAsBytes()
           
 int getJMSDeliveryMode()
           
 javax.jms.Destination getJMSDestination()
           
 long getJMSExpiration()
           
 java.lang.String getJMSMessageID()
           
 int getJMSPriority()
           
 boolean getJMSRedelivered()
           
 javax.jms.Destination getJMSReplyTo()
           
 long getJMSTimestamp()
           
 java.lang.String getJMSType()
           
 long getLongProperty(java.lang.String name)
           
 MessageId getMessageId()
          Return the message id
 java.lang.Object getObjectProperty(java.lang.String name)
           
 boolean getProcessed()
          Check whether the message has been processed
 java.util.Enumeration getPropertyNames()
           
 boolean getReadOnly()
          Get the read-only state of the message.
 long getSequenceNumber()
          Return the sequence number associated with this message
 short getShortProperty(java.lang.String name)
           
 java.lang.String getStringProperty(java.lang.String name)
           
 java.lang.String getWildcard()
          Return the wildcard value if there is one.
 boolean propertyExists(java.lang.String name)
           
 void readExternal(java.io.ObjectInput in)
           
 void setAcceptedTime(long time)
          Set the time that the message was accepted by the server.
 void setBooleanProperty(java.lang.String name, boolean value)
           
 void setByteProperty(java.lang.String name, byte value)
           
 void setConnectionId(long id)
          Set the id of the connection that this message was received on
 void setConsumerId(long consumerId)
          Set the value of the consumer identifer
 void setDoubleProperty(java.lang.String name, double value)
           
 void setFloatProperty(java.lang.String name, float value)
           
 void setIntProperty(java.lang.String name, int value)
           
 void setJMSCorrelationID(java.lang.String correlationID)
           
 void setJMSCorrelationIDAsBytes(byte[] correlationID)
           
 void setJMSDeliveryMode(int deliveryMode)
           
 void setJMSDestination(javax.jms.Destination destination)
           
 void setJMSExpiration(long expiration)
           
 void setJMSMessageID(java.lang.String id)
           
 void setJMSPriority(int priority)
           
 void setJMSRedelivered(boolean redelivered)
           
 void setJMSReplyTo(javax.jms.Destination replyTo)
           
 void setJMSTimestamp(long timestamp)
           
 void setJMSType(java.lang.String type)
           
 void setJMSXRcvTimestamp(long timestamp)
          Set the JMSXRcvTimestamp property.
 void setLongProperty(java.lang.String name, long value)
           
 void setObjectProperty(java.lang.String name, java.lang.Object value)
           
 void setProcessed(boolean state)
          Set the processed state of the message
 void setReadOnly(boolean readOnly)
          Set the read-only state of the message
 void setSequenceNumber(long seq)
          Set the sequence number for this message.
 void setSession(MessageSessionIfc session)
           
 void setShortProperty(java.lang.String name, short value)
           
 void setStringProperty(java.lang.String name, java.lang.String value)
           
 void setWildcard(java.lang.String wildcard)
          Set the wildcard string.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_propertiesReadOnly

protected boolean _propertiesReadOnly
If true, message properties are read-only.


_bodyReadOnly

protected boolean _bodyReadOnly
If true, the message body is read-only.


_acceptedTime

protected long _acceptedTime
The time that the message was accepted by the server.


_sequenceNumber

protected long _sequenceNumber
The sequence number assigned to the message by server when the message is accepted.


_connectionId

protected transient long _connectionId
The identity of the connection that this was received on.


_processed

protected boolean _processed
This flag indicates that the message has been processed by the provider.


EMPTY

protected static final byte[] EMPTY
Empty byte array for initialisation purposes.

Constructor Detail

MessageImpl

public MessageImpl()
Default constructor, required to support externalization.

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone an instance of this object.

Overrides:
clone in class java.lang.Object
Returns:
a new copy of this object
Throws:
java.lang.CloneNotSupportedException - if object or attributesare not cloneable

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

setSession

public void setSession(MessageSessionIfc session)

getJMSMessageID

public java.lang.String getJMSMessageID()
                                 throws javax.jms.JMSException
Specified by:
getJMSMessageID in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSMessageID

public void setJMSMessageID(java.lang.String id)
                     throws javax.jms.JMSException
Specified by:
setJMSMessageID in interface javax.jms.Message
Throws:
javax.jms.JMSException

getAckMessageID

public java.lang.String getAckMessageID()
Returns the identifier of the message for acknowledgment. This will typically be the same as that returned by getJMSMessageID(), unless the message was republished after its receipt. If the message is republished, this method will return the original message identifier, whereas getJMSMessageID() will return that of the last publication.

Returns:
the identifier of the message for acknowledgment

getJMSTimestamp

public long getJMSTimestamp()
                     throws javax.jms.JMSException
Specified by:
getJMSTimestamp in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSTimestamp

public void setJMSTimestamp(long timestamp)
                     throws javax.jms.JMSException
Specified by:
setJMSTimestamp in interface javax.jms.Message
Throws:
javax.jms.JMSException

getWildcard

public java.lang.String getWildcard()
Return the wildcard value if there is one.

Returns:
the wildcard string

getMessageId

public MessageId getMessageId()
Return the message id

Returns:
MessageId

setWildcard

public void setWildcard(java.lang.String wildcard)
Set the wildcard string.

Parameters:
wildcard - The wildcard.

getConsumerId

public long getConsumerId()
Returns the value of the consumer identifier

Returns:
the value of the consumer identifier

setConsumerId

public void setConsumerId(long consumerId)
Set the value of the consumer identifer

Parameters:
consumerId - the consumer identifier

getJMSCorrelationIDAsBytes

public byte[] getJMSCorrelationIDAsBytes()
                                  throws javax.jms.JMSException
Specified by:
getJMSCorrelationIDAsBytes in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSCorrelationIDAsBytes

public void setJMSCorrelationIDAsBytes(byte[] correlationID)
                                throws javax.jms.JMSException
Specified by:
setJMSCorrelationIDAsBytes in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSCorrelationID

public void setJMSCorrelationID(java.lang.String correlationID)
                         throws javax.jms.JMSException
Specified by:
setJMSCorrelationID in interface javax.jms.Message
Throws:
javax.jms.JMSException

getJMSCorrelationID

public java.lang.String getJMSCorrelationID()
                                     throws javax.jms.JMSException
Specified by:
getJMSCorrelationID in interface javax.jms.Message
Throws:
javax.jms.JMSException

getJMSReplyTo

public javax.jms.Destination getJMSReplyTo()
                                    throws javax.jms.JMSException
Specified by:
getJMSReplyTo in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSReplyTo

public void setJMSReplyTo(javax.jms.Destination replyTo)
                   throws javax.jms.JMSException
Specified by:
setJMSReplyTo in interface javax.jms.Message
Throws:
javax.jms.JMSException

getJMSDestination

public javax.jms.Destination getJMSDestination()
                                        throws javax.jms.JMSException
Specified by:
getJMSDestination in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSDestination

public void setJMSDestination(javax.jms.Destination destination)
                       throws javax.jms.JMSException
Specified by:
setJMSDestination in interface javax.jms.Message
Throws:
javax.jms.JMSException

getJMSDeliveryMode

public int getJMSDeliveryMode()
                       throws javax.jms.JMSException
Specified by:
getJMSDeliveryMode in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSDeliveryMode

public void setJMSDeliveryMode(int deliveryMode)
                        throws javax.jms.JMSException
Specified by:
setJMSDeliveryMode in interface javax.jms.Message
Throws:
javax.jms.JMSException

getJMSRedelivered

public boolean getJMSRedelivered()
                          throws javax.jms.JMSException
Specified by:
getJMSRedelivered in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSRedelivered

public void setJMSRedelivered(boolean redelivered)
                       throws javax.jms.JMSException
Specified by:
setJMSRedelivered in interface javax.jms.Message
Throws:
javax.jms.JMSException

getJMSType

public java.lang.String getJMSType()
                            throws javax.jms.JMSException
Specified by:
getJMSType in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSType

public void setJMSType(java.lang.String type)
                throws javax.jms.JMSException
Specified by:
setJMSType in interface javax.jms.Message
Throws:
javax.jms.JMSException

getJMSExpiration

public long getJMSExpiration()
                      throws javax.jms.JMSException
Specified by:
getJMSExpiration in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSExpiration

public void setJMSExpiration(long expiration)
                      throws javax.jms.JMSException
Specified by:
setJMSExpiration in interface javax.jms.Message
Throws:
javax.jms.JMSException

getJMSPriority

public int getJMSPriority()
                   throws javax.jms.JMSException
Specified by:
getJMSPriority in interface javax.jms.Message
Throws:
javax.jms.JMSException

setJMSPriority

public void setJMSPriority(int priority)
                    throws javax.jms.JMSException
Specified by:
setJMSPriority in interface javax.jms.Message
Throws:
javax.jms.JMSException

clearProperties

public void clearProperties()
                     throws javax.jms.JMSException
Specified by:
clearProperties in interface javax.jms.Message
Throws:
javax.jms.JMSException

propertyExists

public boolean propertyExists(java.lang.String name)
                       throws javax.jms.JMSException
Specified by:
propertyExists in interface javax.jms.Message
Throws:
javax.jms.JMSException

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)
                           throws javax.jms.JMSException
Specified by:
getBooleanProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

getByteProperty

public byte getByteProperty(java.lang.String name)
                     throws javax.jms.JMSException
Specified by:
getByteProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

getShortProperty

public short getShortProperty(java.lang.String name)
                       throws javax.jms.JMSException
Specified by:
getShortProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

getIntProperty

public int getIntProperty(java.lang.String name)
                   throws javax.jms.JMSException
Specified by:
getIntProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

getLongProperty

public long getLongProperty(java.lang.String name)
                     throws javax.jms.JMSException
Specified by:
getLongProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

getFloatProperty

public float getFloatProperty(java.lang.String name)
                       throws javax.jms.JMSException
Specified by:
getFloatProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

getDoubleProperty

public double getDoubleProperty(java.lang.String name)
                         throws javax.jms.JMSException
Specified by:
getDoubleProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

getStringProperty

public java.lang.String getStringProperty(java.lang.String name)
                                   throws javax.jms.JMSException
Specified by:
getStringProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

getObjectProperty

public java.lang.Object getObjectProperty(java.lang.String name)
                                   throws javax.jms.JMSException
Specified by:
getObjectProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

getPropertyNames

public java.util.Enumeration getPropertyNames()
                                       throws javax.jms.JMSException
Specified by:
getPropertyNames in interface javax.jms.Message
Throws:
javax.jms.JMSException

setBooleanProperty

public void setBooleanProperty(java.lang.String name,
                               boolean value)
                        throws javax.jms.JMSException
Specified by:
setBooleanProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

setByteProperty

public void setByteProperty(java.lang.String name,
                            byte value)
                     throws javax.jms.JMSException
Specified by:
setByteProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

setShortProperty

public void setShortProperty(java.lang.String name,
                             short value)
                      throws javax.jms.JMSException
Specified by:
setShortProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

setIntProperty

public void setIntProperty(java.lang.String name,
                           int value)
                    throws javax.jms.JMSException
Specified by:
setIntProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

setLongProperty

public void setLongProperty(java.lang.String name,
                            long value)
                     throws javax.jms.JMSException
Specified by:
setLongProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

setFloatProperty

public void setFloatProperty(java.lang.String name,
                             float value)
                      throws javax.jms.JMSException
Specified by:
setFloatProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

setDoubleProperty

public void setDoubleProperty(java.lang.String name,
                              double value)
                       throws javax.jms.JMSException
Specified by:
setDoubleProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

setStringProperty

public void setStringProperty(java.lang.String name,
                              java.lang.String value)
                       throws javax.jms.JMSException
Specified by:
setStringProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

setObjectProperty

public void setObjectProperty(java.lang.String name,
                              java.lang.Object value)
                       throws javax.jms.JMSException
Specified by:
setObjectProperty in interface javax.jms.Message
Throws:
javax.jms.JMSException

acknowledge

public void acknowledge()
                 throws javax.jms.JMSException
Acknowledge the message through the session that dispatched it. Throw JMSException is there is no session attached to the message

Specified by:
acknowledge in interface javax.jms.Message
Throws:
javax.jms.JMSException - if acknowledgement fails

clearBody

public void clearBody()
               throws javax.jms.JMSException
Specified by:
clearBody in interface javax.jms.Message
Throws:
javax.jms.JMSException

checkPropertyWrite

public final void checkPropertyWrite()
                              throws javax.jms.MessageNotWriteableException
Throws:
javax.jms.MessageNotWriteableException

checkWrite

public final void checkWrite()
                      throws javax.jms.MessageNotWriteableException
Throws:
javax.jms.MessageNotWriteableException

checkRead

public final void checkRead()
                     throws javax.jms.MessageNotReadableException
Throws:
javax.jms.MessageNotReadableException

getId

public java.lang.String getId()

setAcceptedTime

public void setAcceptedTime(long time)
Set the time that the message was accepted by the server. This is different to the JMSTimestamp, which denotes the time that the message was handed off to the provider.

Parameters:
time - the time that the message was accepted by the server

getAcceptedTime

public long getAcceptedTime()
Return the time that the messages was accepted by the server

Returns:
time in milliseconds

setSequenceNumber

public void setSequenceNumber(long seq)
Set the sequence number for this message. Not mandatory.

Parameters:
seq - the sequence number, which is used for ordering

getSequenceNumber

public long getSequenceNumber()
Return the sequence number associated with this message

Returns:
the sequence number

setConnectionId

public void setConnectionId(long id)
Set the id of the connection that this message was received on

Parameters:
id - the connection id

getConnectionId

public long getConnectionId()
Return the id of the connection that this messaged was received on

Returns:
the connection id

setProcessed

public void setProcessed(boolean state)
Set the processed state of the message

Parameters:
state - true if message has been processed by provider

getProcessed

public boolean getProcessed()
Check whether the message has been processed

Returns:
true if the message has been processed

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws javax.jms.JMSException
Set the read-only state of the message

Parameters:
readOnly - if true, make the message body and properties read-only
Throws:
javax.jms.JMSException - if the read-only state cannot be changed

getReadOnly

public final boolean getReadOnly()
Get the read-only state of the message. Note that this only returns true if both properties and body are read-only

Returns:
true if the message is read-only

setJMSXRcvTimestamp

public void setJMSXRcvTimestamp(long timestamp)
Set the JMSXRcvTimestamp property. This bypasses the read-only check to avoid unwanted exceptions.



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