com.caucho.jms.message
Class MessageImpl

java.lang.Object
  extended by com.caucho.jms.message.MessageImpl
All Implemented Interfaces:
java.io.Serializable, Message
Direct Known Subclasses:
BytesMessageImpl, MapMessageImpl, ObjectMessageImpl, StreamMessageImpl, TextMessageImpl

public class MessageImpl
extends java.lang.Object
implements Message, java.io.Serializable

A basic message.

See Also:
Serialized Form

Field Summary
protected static L10N L
           
protected static java.util.logging.Logger log
           
 
Fields inherited from interface javax.jms.Message
DEFAULT_DELIVERY_MODE, DEFAULT_PRIORITY, DEFAULT_TIME_TO_LIVE
 
Constructor Summary
MessageImpl()
           
MessageImpl(Message msg)
          Create a message, copying the properties
MessageImpl(MessageImpl msg)
           
 
Method Summary
 void acknowledge()
          Acknowledge receipt of this message.
 java.io.InputStream bodyToInputStream()
          Serialize the body to an input stream.
protected  void checkBodyReadable()
           
protected  void checkBodyWriteable()
           
protected  void checkHeaderWriteable()
           
protected  void checkPropertyWriteable()
           
 void clearBody()
          Clears the body, setting write mode.
 void clearProperties()
          Clears the message properties, making them writeable.
 MessageImpl copy()
           
protected  void copy(MessageImpl newMsg)
           
 boolean getBooleanProperty(java.lang.String name)
          Returns a boolean property with the given name.
 byte getByteProperty(java.lang.String name)
          Returns a property as a byte
 double getDoubleProperty(java.lang.String name)
          Returns a property as a double
 float getFloatProperty(java.lang.String name)
          Returns a property as a float
 int getIntProperty(java.lang.String name)
          Returns a property as an integer
 java.lang.String getJMSCorrelationID()
          Returns the correlation id.
 byte[] getJMSCorrelationIDAsBytes()
          Returns the correlation id.
 int getJMSDeliveryMode()
          Gets the delivery model
 Destination getJMSDestination()
          Gets the destination
 long getJMSExpiration()
          Returns the message expiration time.
 java.lang.String getJMSMessageID()
          Returns the message id.
 int getJMSPriority()
          Returns the message priority.
 boolean getJMSRedelivered()
          Returns if the message is being redelivered.
 Destination getJMSReplyTo()
          Gets the reply-to destination
 long getJMSTimestamp()
          Returns the time the message was sent.
 java.lang.String getJMSType()
          Returns the message type
 long getLongProperty(java.lang.String name)
          Returns a property as a long
 java.lang.Object getObjectProperty(java.lang.String name)
          Returns a string property.
 java.util.HashMap<java.lang.String,java.lang.Object> getProperties()
          Returns the properties.
 java.util.Enumeration getPropertyNames()
          Returns an enumeration of the message's properties.
 long getSequence()
           
 short getShortProperty(java.lang.String name)
          Returns a property as a short
 java.lang.String getStringProperty(java.lang.String name)
          Returns a string property.
 MessageType getType()
          Returns the type enumeration.
static boolean isReserved(java.lang.String name)
           
 java.io.InputStream propertiesToInputStream()
          Serialize the properties to an input stream.
 boolean propertyExists(java.lang.String name)
          Returns true if the property exists.
 void readBody(java.io.InputStream is)
          Read the body from an input stream.
 void readProperties(java.io.InputStream is)
          Read the properties from an input stream.
protected  void setBodyReadOnly()
          Sets the body for reading.
 void setBooleanProperty(java.lang.String name, boolean value)
          Sets a boolean property.
 void setByteProperty(java.lang.String name, byte value)
          Sets a byte property.
 void setDoubleProperty(java.lang.String name, double value)
          Sets a double property.
 void setFloatProperty(java.lang.String name, float value)
          Sets a float property.
 void setIntProperty(java.lang.String name, int value)
          Sets an integer property.
 void setJMSCorrelationID(java.lang.String id)
          Sets the correlation id.
 void setJMSCorrelationIDAsBytes(byte[] id)
          Sets the correlation id.
 void setJMSDeliveryMode(int deliveryMode)
          Sets the delivery mode
 void setJMSDestination(Destination destination)
          Sets the reply-to destination
 void setJMSExpiration(long time)
          Sets the message expiration type.
 void setJMSMessageID(java.lang.String id)
          Sets the message id.
 void setJMSPriority(int priority)
          Sets the message priority.
 void setJMSRedelivered(boolean isRedelivered)
          Sets if the message is being redelivered.
 void setJMSReplyTo(Destination replyTo)
          Sets the reply-to destination
 void setJMSTimestamp(long time)
          Sets the time the message was sent.
 void setJMSType(java.lang.String type)
          Sets the message type.
 void setLongProperty(java.lang.String name, long value)
          Sets a long property.
 void setObjectProperty(java.lang.String name, java.lang.Object value)
          Sets an object property.
 void setReceive()
          Sets the body for reading.
 void setSequence(long seq)
           
 void setSession(JmsSession session)
          Sets the session.
 void setShortProperty(java.lang.String name, short value)
          Sets a short property.
 void setStringProperty(java.lang.String name, java.lang.String value)
          Sets a string property.
 java.lang.String toString()
           
 void writeBody(java.io.OutputStream os)
          Serialize the body to an output stream.
 void writeProperties(java.io.OutputStream os)
          Serialize the properties to an input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final java.util.logging.Logger log

L

protected static final L10N L
Constructor Detail

MessageImpl

public MessageImpl()

MessageImpl

public MessageImpl(Message msg)
            throws JMSException
Create a message, copying the properties

Throws:
JMSException

MessageImpl

public MessageImpl(MessageImpl msg)
Method Detail

setSession

public void setSession(JmsSession session)
Sets the session.


getType

public MessageType getType()
Returns the type enumeration.


getJMSMessageID

public java.lang.String getJMSMessageID()
Returns the message id.

Specified by:
getJMSMessageID in interface Message

setJMSMessageID

public void setJMSMessageID(java.lang.String id)
Sets the message id.

Specified by:
setJMSMessageID in interface Message
Parameters:
id - the new message id

getJMSTimestamp

public long getJMSTimestamp()
                     throws JMSException
Returns the time the message was sent.

Specified by:
getJMSTimestamp in interface Message
Throws:
JMSException

setJMSTimestamp

public void setJMSTimestamp(long time)
                     throws JMSException
Sets the time the message was sent.

Specified by:
setJMSTimestamp in interface Message
Parameters:
time - the message timestamp
Throws:
JMSException

getJMSCorrelationIDAsBytes

public byte[] getJMSCorrelationIDAsBytes()
                                  throws JMSException
Returns the correlation id.

Specified by:
getJMSCorrelationIDAsBytes in interface Message
Throws:
JMSException

setJMSCorrelationIDAsBytes

public void setJMSCorrelationIDAsBytes(byte[] id)
                                throws JMSException
Sets the correlation id.

Specified by:
setJMSCorrelationIDAsBytes in interface Message
Parameters:
id - the correlation id
Throws:
JMSException

getJMSCorrelationID

public java.lang.String getJMSCorrelationID()
                                     throws JMSException
Returns the correlation id.

Specified by:
getJMSCorrelationID in interface Message
Throws:
JMSException

setJMSCorrelationID

public void setJMSCorrelationID(java.lang.String id)
                         throws JMSException
Sets the correlation id.

Specified by:
setJMSCorrelationID in interface Message
Parameters:
id - the correlation id
Throws:
JMSException

getJMSReplyTo

public Destination getJMSReplyTo()
                          throws JMSException
Gets the reply-to destination

Specified by:
getJMSReplyTo in interface Message
Throws:
JMSException

setJMSReplyTo

public void setJMSReplyTo(Destination replyTo)
                   throws JMSException
Sets the reply-to destination

Specified by:
setJMSReplyTo in interface Message
Parameters:
replyTo - the destination
Throws:
JMSException

getJMSDestination

public Destination getJMSDestination()
                              throws JMSException
Gets the destination

Specified by:
getJMSDestination in interface Message
Throws:
JMSException

setJMSDestination

public void setJMSDestination(Destination destination)
                       throws JMSException
Sets the reply-to destination

Specified by:
setJMSDestination in interface Message
Parameters:
destination - the destination
Throws:
JMSException

getJMSDeliveryMode

public int getJMSDeliveryMode()
                       throws JMSException
Gets the delivery model

Specified by:
getJMSDeliveryMode in interface Message
Throws:
JMSException

setJMSDeliveryMode

public void setJMSDeliveryMode(int deliveryMode)
                        throws JMSException
Sets the delivery mode

Specified by:
setJMSDeliveryMode in interface Message
Parameters:
deliveryMode - the delivery mode
Throws:
JMSException

getJMSRedelivered

public boolean getJMSRedelivered()
Returns if the message is being redelivered.

Specified by:
getJMSRedelivered in interface Message

setJMSRedelivered

public void setJMSRedelivered(boolean isRedelivered)
Sets if the message is being redelivered.

Specified by:
setJMSRedelivered in interface Message
Parameters:
deliveryMode - the delivery mode

getJMSType

public java.lang.String getJMSType()
                            throws JMSException
Returns the message type

Specified by:
getJMSType in interface Message
Throws:
JMSException

setJMSType

public void setJMSType(java.lang.String type)
                throws JMSException
Sets the message type.

Specified by:
setJMSType in interface Message
Parameters:
type - the delivery mode
Throws:
JMSException

getJMSExpiration

public long getJMSExpiration()
                      throws JMSException
Returns the message expiration time.

Specified by:
getJMSExpiration in interface Message
Throws:
JMSException

setJMSExpiration

public void setJMSExpiration(long time)
                      throws JMSException
Sets the message expiration type.

Specified by:
setJMSExpiration in interface Message
Parameters:
time - the expiration time
Throws:
JMSException

getJMSPriority

public int getJMSPriority()
Returns the message priority.

Specified by:
getJMSPriority in interface Message

setJMSPriority

public void setJMSPriority(int priority)
Sets the message priority.

Specified by:
setJMSPriority in interface Message
Parameters:
priority - the priority

clearProperties

public void clearProperties()
                     throws JMSException
Clears the message properties, making them writeable.

Specified by:
clearProperties in interface Message
Throws:
JMSException

propertyExists

public boolean propertyExists(java.lang.String name)
                       throws JMSException
Returns true if the property exists.

Specified by:
propertyExists in interface Message
Throws:
JMSException

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)
                           throws JMSException
Returns a boolean property with the given name.

Specified by:
getBooleanProperty in interface Message
Throws:
JMSException

getByteProperty

public byte getByteProperty(java.lang.String name)
                     throws JMSException
Returns a property as a byte

Specified by:
getByteProperty in interface Message
Throws:
JMSException

getShortProperty

public short getShortProperty(java.lang.String name)
                       throws JMSException
Returns a property as a short

Specified by:
getShortProperty in interface Message
Throws:
JMSException

getIntProperty

public int getIntProperty(java.lang.String name)
                   throws JMSException
Returns a property as an integer

Specified by:
getIntProperty in interface Message
Throws:
JMSException

getLongProperty

public long getLongProperty(java.lang.String name)
                     throws JMSException
Returns a property as a long

Specified by:
getLongProperty in interface Message
Throws:
JMSException

getFloatProperty

public float getFloatProperty(java.lang.String name)
                       throws JMSException
Returns a property as a float

Specified by:
getFloatProperty in interface Message
Throws:
JMSException

getDoubleProperty

public double getDoubleProperty(java.lang.String name)
                         throws JMSException
Returns a property as a double

Specified by:
getDoubleProperty in interface Message
Throws:
JMSException

getStringProperty

public java.lang.String getStringProperty(java.lang.String name)
                                   throws JMSException
Returns a string property.

Specified by:
getStringProperty in interface Message
Throws:
JMSException

getObjectProperty

public java.lang.Object getObjectProperty(java.lang.String name)
                                   throws JMSException
Returns a string property.

Specified by:
getObjectProperty in interface Message
Throws:
JMSException

getPropertyNames

public java.util.Enumeration getPropertyNames()
                                       throws JMSException
Returns an enumeration of the message's properties.

Specified by:
getPropertyNames in interface Message
Throws:
JMSException

setBooleanProperty

public void setBooleanProperty(java.lang.String name,
                               boolean value)
                        throws JMSException
Sets a boolean property.

Specified by:
setBooleanProperty in interface Message
Parameters:
name - the property name
value - the property's value
Throws:
JMSException

setByteProperty

public void setByteProperty(java.lang.String name,
                            byte value)
                     throws JMSException
Sets a byte property.

Specified by:
setByteProperty in interface Message
Parameters:
name - the property name
value - the property's value
Throws:
JMSException

setShortProperty

public void setShortProperty(java.lang.String name,
                             short value)
                      throws JMSException
Sets a short property.

Specified by:
setShortProperty in interface Message
Parameters:
name - the property name
value - the property's value
Throws:
JMSException

setIntProperty

public void setIntProperty(java.lang.String name,
                           int value)
                    throws JMSException
Sets an integer property.

Specified by:
setIntProperty in interface Message
Parameters:
name - the property name
value - the property's value
Throws:
JMSException

setLongProperty

public void setLongProperty(java.lang.String name,
                            long value)
                     throws JMSException
Sets a long property.

Specified by:
setLongProperty in interface Message
Parameters:
name - the property name
value - the property's value
Throws:
JMSException

setFloatProperty

public void setFloatProperty(java.lang.String name,
                             float value)
                      throws JMSException
Sets a float property.

Specified by:
setFloatProperty in interface Message
Parameters:
name - the property name
value - the property's value
Throws:
JMSException

setDoubleProperty

public void setDoubleProperty(java.lang.String name,
                              double value)
                       throws JMSException
Sets a double property.

Specified by:
setDoubleProperty in interface Message
Parameters:
name - the property name
value - the property's value
Throws:
JMSException

setStringProperty

public void setStringProperty(java.lang.String name,
                              java.lang.String value)
                       throws JMSException
Sets a string property.

Specified by:
setStringProperty in interface Message
Parameters:
name - the property name
value - the property's value
Throws:
JMSException

setObjectProperty

public void setObjectProperty(java.lang.String name,
                              java.lang.Object value)
                       throws JMSException
Sets an object property.

Specified by:
setObjectProperty in interface Message
Parameters:
name - the property name
value - the property's value
Throws:
JMSException

acknowledge

public void acknowledge()
                 throws JMSException
Acknowledge receipt of this message.

Specified by:
acknowledge in interface Message
Throws:
JMSException

clearBody

public void clearBody()
               throws JMSException
Clears the body, setting write mode.

Specified by:
clearBody in interface Message
Throws:
JMSException

setReceive

public void setReceive()
                throws JMSException
Sets the body for reading.

Throws:
JMSException

setBodyReadOnly

protected void setBodyReadOnly()
Sets the body for reading.


getProperties

public java.util.HashMap<java.lang.String,java.lang.Object> getProperties()
Returns the properties.


getSequence

public long getSequence()

setSequence

public void setSequence(long seq)

copy

public MessageImpl copy()

propertiesToInputStream

public java.io.InputStream propertiesToInputStream()
                                            throws java.io.IOException
Serialize the properties to an input stream.

Throws:
java.io.IOException

writeProperties

public void writeProperties(java.io.OutputStream os)
                     throws java.io.IOException
Serialize the properties to an input stream.

Throws:
java.io.IOException

readProperties

public void readProperties(java.io.InputStream is)
                    throws java.io.IOException,
                           JMSException
Read the properties from an input stream.

Throws:
java.io.IOException
JMSException

bodyToInputStream

public java.io.InputStream bodyToInputStream()
                                      throws java.io.IOException
Serialize the body to an input stream.

Throws:
java.io.IOException

writeBody

public void writeBody(java.io.OutputStream os)
               throws java.io.IOException
Serialize the body to an output stream.

Throws:
java.io.IOException

readBody

public void readBody(java.io.InputStream is)
              throws java.io.IOException,
                     JMSException
Read the body from an input stream.

Throws:
java.io.IOException
JMSException

checkHeaderWriteable

protected void checkHeaderWriteable()
                             throws JMSException
Throws:
JMSException

checkPropertyWriteable

protected void checkPropertyWriteable()
                               throws JMSException
Throws:
JMSException

checkBodyWriteable

protected void checkBodyWriteable()
                           throws JMSException
Throws:
JMSException

checkBodyReadable

protected void checkBodyReadable()
                          throws JMSException
Throws:
JMSException

copy

protected void copy(MessageImpl newMsg)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isReserved

public static boolean isReserved(java.lang.String name)