jrun.jms.core.message
Class MessageImpl

jrun.jms.core.message.MessageImpl
All Implemented Interfaces:
java.lang.Cloneable, Disposable, java.io.Externalizable, Identifiable, java.io.Serializable

public class MessageImpl
implements java.io.Externalizable, java.lang.Cloneable, Identifiable, Disposable

This class implements the javax.jms.Message interface

Version:
$Revision: 1.13 $ $Date: 2001/08/06 02:59:19 $
Author:
Jim Mourikis
See Also:
Message, Serialized Form

Field Summary
protected  long _acceptedTime
          This is the time that the message was accepted by the server
protected  boolean _bodyReadOnly
          If true, the message body is read-only
protected  int _connectionId
          This message was received on this connection
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
          This is the sequence number assigned to it by the message manager when the message is accepted.
protected  int _size
          Holds the size (in bytes).
 
Constructor Summary
MessageImpl()
          Default constructor, required to support externalization
 
Method Summary
 void acknowledge()
          Acknowledge the message through the session that dispatched it.
 boolean canDispose()
          Check whether we can dispose of this object.
 void checkPropertyWrite()
           
 void checkRead()
           
 void checkWrite()
           
 void clearBody()
           
 void clearProperties()
           
 java.lang.Object clone()
          Clone an instance of this object
 void dispose()
          Unconditionally dispose of this object or do whatever you can to make it available for garbage collection
 long getAcceptedTime()
          Return the time that the messages was accepted by the server
 boolean getBooleanProperty(java.lang.String name)
           
 byte getByteProperty(java.lang.String name)
           
 long getClientId()
          Get the value of the client session consumer identifier
 int getConnectionId()
          Return the id of the connection that this messaged was received on
 java.lang.String getConsumerId()
          Get the value of consumerId
 double getDoubleProperty(java.lang.String name)
           
static int getExternalizableObjectSize(java.io.Externalizable obj)
          Calculate the size of the supplied message object.
 float getFloatProperty(java.lang.String name)
           
 long getId()
          Return the identity of the object as a long
 java.lang.String getIdAsString()
          Return the identity of the object as a string
 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)
           
 long getPersistentId()
          Return the message's persistent identity or null if it is not set
 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)
           
 int getSize()
          Return the previously saved size value (if any.)
 java.lang.String getStringProperty(java.lang.String name)
           
 java.lang.String getWildcard()
          Return the wildcard value if there is one.
 boolean isPersistent()
           
 boolean isPriorityExpedited()
           
 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 setClientId(long clientId)
          Set the value of the client session consumer identifer
 void setConnectionId(int id)
          Set the id of the connection that this message was received on
 void setConsumerId(java.lang.String consumerId)
          Set the value of consumerId
 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 setSize(int size)
          Store the size in bytes of this message.
 void setStringProperty(java.lang.String name, java.lang.String value)
           
 void setWildcard(java.lang.String wildcard)
          Set the wildcard string.
 boolean tryDisposing()
          Check to see if this object can be disposed.
 void writeExternal(java.io.ObjectOutput out)
           
 

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
This is the time that the message was accepted by the server

_sequenceNumber

protected long _sequenceNumber
This is the sequence number assigned to it by the message manager when the message is accepted.

_connectionId

protected transient int _connectionId
This message was received on this connection

_processed

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

_size

protected int _size
Holds the size (in bytes). (Not automatically set. Set explicitly in client.JmsSession.sendMessage().)
Constructor Detail

MessageImpl

public MessageImpl()
            throws javax.jms.JMSException
Default constructor, required to support externalization
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone an instance of this 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

readExternal

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

setSession

public void setSession(MessageSessionIfc session)

getJMSMessageID

public java.lang.String getJMSMessageID()
                                 throws javax.jms.JMSException

setJMSMessageID

public void setJMSMessageID(java.lang.String id)
                     throws javax.jms.JMSException

getJMSTimestamp

public long getJMSTimestamp()
                     throws javax.jms.JMSException

setJMSTimestamp

public void setJMSTimestamp(long timestamp)
                     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 java.lang.String getConsumerId()
Get the value of consumerId
Returns:
the consumerId

setConsumerId

public void setConsumerId(java.lang.String consumerId)
Set the value of consumerId
Parameters:
consumerId - the consumerId

getClientId

public long getClientId()
Get the value of the client session consumer identifier
Returns:
the value of the client session consumer identifier

setClientId

public void setClientId(long clientId)
Set the value of the client session consumer identifer
Parameters:
clientId - the client session consumer identifier

getJMSCorrelationIDAsBytes

public byte[] getJMSCorrelationIDAsBytes()
                                  throws javax.jms.JMSException

setJMSCorrelationIDAsBytes

public void setJMSCorrelationIDAsBytes(byte[] correlationID)
                                throws javax.jms.JMSException

setJMSCorrelationID

public void setJMSCorrelationID(java.lang.String correlationID)
                         throws javax.jms.JMSException

getJMSCorrelationID

public java.lang.String getJMSCorrelationID()
                                     throws javax.jms.JMSException

getJMSReplyTo

public javax.jms.Destination getJMSReplyTo()
                                    throws javax.jms.JMSException

setJMSReplyTo

public void setJMSReplyTo(javax.jms.Destination replyTo)
                   throws javax.jms.JMSException

getJMSDestination

public javax.jms.Destination getJMSDestination()
                                        throws javax.jms.JMSException

setJMSDestination

public void setJMSDestination(javax.jms.Destination destination)
                       throws javax.jms.JMSException

getJMSDeliveryMode

public int getJMSDeliveryMode()
                       throws javax.jms.JMSException

setJMSDeliveryMode

public void setJMSDeliveryMode(int deliveryMode)
                        throws javax.jms.JMSException

getJMSRedelivered

public boolean getJMSRedelivered()
                          throws javax.jms.JMSException

setJMSRedelivered

public void setJMSRedelivered(boolean redelivered)
                       throws javax.jms.JMSException

getJMSType

public java.lang.String getJMSType()
                            throws javax.jms.JMSException

setJMSType

public void setJMSType(java.lang.String type)
                throws javax.jms.JMSException

getJMSExpiration

public long getJMSExpiration()
                      throws javax.jms.JMSException

setJMSExpiration

public void setJMSExpiration(long expiration)
                      throws javax.jms.JMSException

getJMSPriority

public int getJMSPriority()
                   throws javax.jms.JMSException

setJMSPriority

public void setJMSPriority(int priority)
                    throws javax.jms.JMSException

isPersistent

public boolean isPersistent()
                     throws javax.jms.JMSException

isPriorityExpedited

public boolean isPriorityExpedited()
                            throws javax.jms.JMSException

clearProperties

public void clearProperties()
                     throws javax.jms.JMSException

propertyExists

public boolean propertyExists(java.lang.String name)
                       throws javax.jms.JMSException

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)
                           throws javax.jms.JMSException

getByteProperty

public byte getByteProperty(java.lang.String name)
                     throws javax.jms.JMSException

getShortProperty

public short getShortProperty(java.lang.String name)
                       throws javax.jms.JMSException

getIntProperty

public int getIntProperty(java.lang.String name)
                   throws javax.jms.JMSException

getLongProperty

public long getLongProperty(java.lang.String name)
                     throws javax.jms.JMSException

getFloatProperty

public float getFloatProperty(java.lang.String name)
                       throws javax.jms.JMSException

getDoubleProperty

public double getDoubleProperty(java.lang.String name)
                         throws javax.jms.JMSException

getStringProperty

public java.lang.String getStringProperty(java.lang.String name)
                                   throws javax.jms.JMSException

getObjectProperty

public java.lang.Object getObjectProperty(java.lang.String name)
                                   throws javax.jms.JMSException

getPropertyNames

public java.util.Enumeration getPropertyNames()
                                       throws javax.jms.JMSException

setBooleanProperty

public void setBooleanProperty(java.lang.String name,
                               boolean value)
                        throws javax.jms.JMSException

setByteProperty

public void setByteProperty(java.lang.String name,
                            byte value)
                     throws javax.jms.JMSException

setShortProperty

public void setShortProperty(java.lang.String name,
                             short value)
                      throws javax.jms.JMSException

setIntProperty

public void setIntProperty(java.lang.String name,
                           int value)
                    throws javax.jms.JMSException

setLongProperty

public void setLongProperty(java.lang.String name,
                            long value)
                     throws javax.jms.JMSException

setFloatProperty

public void setFloatProperty(java.lang.String name,
                             float value)
                      throws javax.jms.JMSException

setDoubleProperty

public void setDoubleProperty(java.lang.String name,
                              double value)
                       throws javax.jms.JMSException

setStringProperty

public void setStringProperty(java.lang.String name,
                              java.lang.String value)
                       throws javax.jms.JMSException

setObjectProperty

public void setObjectProperty(java.lang.String name,
                              java.lang.Object value)
                       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
Throws:
JMSException -  

clearBody

public void clearBody()
               throws javax.jms.JMSException

checkPropertyWrite

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

checkWrite

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

checkRead

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

getId

public long getId()
Description copied from interface: Identifiable
Return the identity of the object as a long
Specified by:
getId in interface Identifiable
Following copied from interface: jrun.jms.core.Identifiable
Returns:
long - the object identity

getIdAsString

public java.lang.String getIdAsString()
Description copied from interface: Identifiable
Return the identity of the object as a string
Specified by:
getIdAsString in interface Identifiable
Following copied from interface: jrun.jms.core.Identifiable
Returns:
String - the identity

tryDisposing

public boolean tryDisposing()
Description copied from interface: Disposable
Check to see if this object can be disposed. If so do whatever you can to make it available for garbage collection.
Specified by:
tryDisposing in interface Disposable
Following copied from interface: jrun.jms.core.Disposable
Returns:
boolean - true if object was disposed

canDispose

public final boolean canDispose()
Description copied from interface: Disposable
Check whether we can dispose of this object. This does not actually have any side effects. Note that the Disposable.dispose() method does a check before disposing of the object
Specified by:
canDispose in interface Disposable
Following copied from interface: jrun.jms.core.Disposable
Returns:
boolean - true if we can dispose of it

dispose

public void dispose()
Description copied from interface: Disposable
Unconditionally dispose of this object or do whatever you can to make it available for garbage collection
Specified by:
dispose in interface Disposable

getPersistentId

public long getPersistentId()
                     throws javax.jms.JMSException
Return the message's persistent identity or null if it is not set
Returns:
the message's persistent identity.
Throws:
JMSException - if cannot get persistent identity

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(int id)
Set the id of the connection that this message was received on
Parameters:
id - the connection id

getConnectionId

public int 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:
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.

getExternalizableObjectSize

public static int getExternalizableObjectSize(java.io.Externalizable obj)
Calculate the size of the supplied message object.

setSize

public void setSize(int size)
Store the size in bytes of this message.

getSize

public int getSize()
Return the previously saved size value (if any.)


Copyright � 2002 Macromedia Corporation. All Rights Reserved.