org.jboss.jms.message
Class MessageProxy

java.lang.Object
  extended byorg.jboss.jms.message.MessageProxy
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BytesMessageProxy, MapMessageProxy, ObjectMessageProxy, StreamMessageProxy, TextMessageProxy

public class MessageProxy
extends java.lang.Object
implements java.io.Serializable

MessageProxy is a thin proxy for JBossMessage. JMS Users actually handle MessageProxy instances rather than JBossMessage instances. The purpose of this class and subclasses is to prevent unnecessary copying of a message. After a message is sent, the message can be changed, but this should not affect the sent message. This class accomplishes this by intercepting any methods which change the state of the message and copying either the headers, jms properties or body as appropriate. This enables up to make the minimum amount of copies while still preserving JMS semantics. Similarly on receive. See JMS1.1 Spec 3.9, 3.10 for more details. If nothing is changed, nothing is copied.

Author:
Tim Fox MessageProxy.java,v 1.1 2006/03/08 08:00:34 timfox Exp
See Also:
Serialized Form

Field Summary
protected  boolean bodyCopied
           
protected  boolean bodyReadOnly
           
protected  boolean cc
           
protected  SessionDelegate delegate
           
protected  int deliveryCount
           
protected  JBossMessage message
           
protected  boolean messageCopied
           
protected  boolean propertiesCopied
           
protected  boolean propertiesReadOnly
           
protected  int state
           
protected static int STATE_NEW
           
protected static int STATE_RECEIVED
           
protected static int STATE_SENT
           
 
Constructor Summary
MessageProxy()
           
MessageProxy(JBossMessage message, int deliveryCount)
           
 
Method Summary
 void acknowledge()
           
protected  void bodyChange()
           
protected  void bodyClear()
           
 void clearBody()
           
 void clearProperties()
           
protected  void copyMessage()
           
 boolean getBooleanProperty(java.lang.String name)
           
 byte getByteProperty(java.lang.String name)
           
 int getDeliveryCount()
           
 double getDoubleProperty(java.lang.String name)
           
 float getFloatProperty(java.lang.String name)
           
 int getIntProperty(java.lang.String name)
           
 java.lang.String getJMSCorrelationID()
           
 byte[] getJMSCorrelationIDAsBytes()
           
 int getJMSDeliveryMode()
           
 Destination getJMSDestination()
           
 long getJMSExpiration()
           
 java.lang.String getJMSMessageID()
           
 int getJMSPriority()
           
 boolean getJMSRedelivered()
           
 Destination getJMSReplyTo()
           
 long getJMSTimestamp()
           
 java.lang.String getJMSType()
           
 long getLongProperty(java.lang.String name)
           
 JBossMessage getMessage()
           
 java.lang.Object getObjectProperty(java.lang.String name)
           
 java.util.Enumeration getPropertyNames()
           
 SessionDelegate getSessionDelegate()
           
 short getShortProperty(java.lang.String name)
           
 java.lang.String getStringProperty(java.lang.String name)
           
protected  void headerChange()
           
 void incDeliveryCount()
           
 boolean isReceived()
           
 boolean isSent()
           
protected  void propertiesClear()
           
protected  void propertyChange()
           
 boolean propertyExists(java.lang.String name)
           
 void setBooleanProperty(java.lang.String name, boolean value)
           
 void setByteProperty(java.lang.String name, byte value)
           
 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(Destination destination)
           
 void setJMSExpiration(long expiration)
           
 void setJMSMessageID(java.lang.String id)
           
 void setJMSPriority(int priority)
           
 void setJMSRedelivered(boolean redelivered)
           
 void setJMSReplyTo(Destination replyTo)
           
 void setJMSTimestamp(long timestamp)
           
 void setJMSType(java.lang.String type)
           
 void setLongProperty(java.lang.String name, long value)
           
 void setObjectProperty(java.lang.String name, java.lang.Object value)
           
 void setReceived()
           
 void setSent()
           
 void setSessionDelegate(SessionDelegate sd, boolean isConnectionConsumer)
           
 void setShortProperty(java.lang.String name, short value)
           
 void setStringProperty(java.lang.String name, java.lang.String value)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATE_NEW

protected static final int STATE_NEW
See Also:
Constant Field Values

STATE_SENT

protected static final int STATE_SENT
See Also:
Constant Field Values

STATE_RECEIVED

protected static final int STATE_RECEIVED
See Also:
Constant Field Values

message

protected JBossMessage message

delegate

protected transient SessionDelegate delegate

cc

protected transient boolean cc

messageCopied

protected transient boolean messageCopied

propertiesCopied

protected transient boolean propertiesCopied

bodyCopied

protected transient boolean bodyCopied

state

protected transient int state

propertiesReadOnly

protected transient boolean propertiesReadOnly

bodyReadOnly

protected transient boolean bodyReadOnly

deliveryCount

protected int deliveryCount
Constructor Detail

MessageProxy

public MessageProxy()

MessageProxy

public MessageProxy(JBossMessage message,
                    int deliveryCount)
Method Detail

getJMSMessageID

public java.lang.String getJMSMessageID()
                                 throws JMSException
Throws:
JMSException

setJMSMessageID

public void setJMSMessageID(java.lang.String id)
                     throws JMSException
Throws:
JMSException

getJMSTimestamp

public long getJMSTimestamp()
                     throws JMSException
Throws:
JMSException

setJMSTimestamp

public void setJMSTimestamp(long timestamp)
                     throws JMSException
Throws:
JMSException

getJMSCorrelationIDAsBytes

public byte[] getJMSCorrelationIDAsBytes()
                                  throws JMSException
Throws:
JMSException

setJMSCorrelationIDAsBytes

public void setJMSCorrelationIDAsBytes(byte[] correlationID)
                                throws JMSException
Throws:
JMSException

setJMSCorrelationID

public void setJMSCorrelationID(java.lang.String correlationID)
                         throws JMSException
Throws:
JMSException

getJMSCorrelationID

public java.lang.String getJMSCorrelationID()
                                     throws JMSException
Throws:
JMSException

getJMSReplyTo

public Destination getJMSReplyTo()
                          throws JMSException
Throws:
JMSException

setJMSReplyTo

public void setJMSReplyTo(Destination replyTo)
                   throws JMSException
Throws:
JMSException

getJMSDestination

public Destination getJMSDestination()
                              throws JMSException
Throws:
JMSException

setJMSDestination

public void setJMSDestination(Destination destination)
                       throws JMSException
Throws:
JMSException

getJMSDeliveryMode

public int getJMSDeliveryMode()
                       throws JMSException
Throws:
JMSException

setJMSDeliveryMode

public void setJMSDeliveryMode(int deliveryMode)
                        throws JMSException
Throws:
JMSException

getJMSRedelivered

public boolean getJMSRedelivered()
                          throws JMSException
Throws:
JMSException

setJMSRedelivered

public void setJMSRedelivered(boolean redelivered)
                       throws JMSException
Throws:
JMSException

getJMSType

public java.lang.String getJMSType()
                            throws JMSException
Throws:
JMSException

setJMSType

public void setJMSType(java.lang.String type)
                throws JMSException
Throws:
JMSException

getJMSExpiration

public long getJMSExpiration()
                      throws JMSException
Throws:
JMSException

setJMSExpiration

public void setJMSExpiration(long expiration)
                      throws JMSException
Throws:
JMSException

getJMSPriority

public int getJMSPriority()
                   throws JMSException
Throws:
JMSException

setJMSPriority

public void setJMSPriority(int priority)
                    throws JMSException
Throws:
JMSException

clearProperties

public void clearProperties()
                     throws JMSException
Throws:
JMSException

propertyExists

public boolean propertyExists(java.lang.String name)
                       throws JMSException
Throws:
JMSException

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)
                           throws JMSException
Throws:
JMSException

getByteProperty

public byte getByteProperty(java.lang.String name)
                     throws JMSException
Throws:
JMSException

getShortProperty

public short getShortProperty(java.lang.String name)
                       throws JMSException
Throws:
JMSException

getIntProperty

public int getIntProperty(java.lang.String name)
                   throws JMSException
Throws:
JMSException

getLongProperty

public long getLongProperty(java.lang.String name)
                     throws JMSException
Throws:
JMSException

getFloatProperty

public float getFloatProperty(java.lang.String name)
                       throws JMSException
Throws:
JMSException

getDoubleProperty

public double getDoubleProperty(java.lang.String name)
                         throws JMSException
Throws:
JMSException

getStringProperty

public java.lang.String getStringProperty(java.lang.String name)
                                   throws JMSException
Throws:
JMSException

getObjectProperty

public java.lang.Object getObjectProperty(java.lang.String name)
                                   throws JMSException
Throws:
JMSException

getPropertyNames

public java.util.Enumeration getPropertyNames()
                                       throws JMSException
Throws:
JMSException

setBooleanProperty

public void setBooleanProperty(java.lang.String name,
                               boolean value)
                        throws JMSException
Throws:
JMSException

setByteProperty

public void setByteProperty(java.lang.String name,
                            byte value)
                     throws JMSException
Throws:
JMSException

setShortProperty

public void setShortProperty(java.lang.String name,
                             short value)
                      throws JMSException
Throws:
JMSException

setIntProperty

public void setIntProperty(java.lang.String name,
                           int value)
                    throws JMSException
Throws:
JMSException

setLongProperty

public void setLongProperty(java.lang.String name,
                            long value)
                     throws JMSException
Throws:
JMSException

setFloatProperty

public void setFloatProperty(java.lang.String name,
                             float value)
                      throws JMSException
Throws:
JMSException

setDoubleProperty

public void setDoubleProperty(java.lang.String name,
                              double value)
                       throws JMSException
Throws:
JMSException

setStringProperty

public void setStringProperty(java.lang.String name,
                              java.lang.String value)
                       throws JMSException
Throws:
JMSException

setObjectProperty

public void setObjectProperty(java.lang.String name,
                              java.lang.Object value)
                       throws JMSException
Throws:
JMSException

acknowledge

public void acknowledge()
                 throws JMSException
Throws:
JMSException

clearBody

public void clearBody()
               throws JMSException
Throws:
JMSException

setSessionDelegate

public void setSessionDelegate(SessionDelegate sd,
                               boolean isConnectionConsumer)

getSessionDelegate

public SessionDelegate getSessionDelegate()

setSent

public void setSent()

setReceived

public void setReceived()

getMessage

public JBossMessage getMessage()

getDeliveryCount

public int getDeliveryCount()

incDeliveryCount

public void incDeliveryCount()

toString

public java.lang.String toString()

headerChange

protected void headerChange()
                     throws JMSException
Throws:
JMSException

copyMessage

protected void copyMessage()
                    throws JMSException
Throws:
JMSException

isSent

public boolean isSent()

isReceived

public boolean isReceived()

propertyChange

protected void propertyChange()
                       throws JMSException
Throws:
JMSException

propertiesClear

protected void propertiesClear()
                        throws JMSException
Throws:
JMSException

bodyClear

protected void bodyClear()
                  throws JMSException
Throws:
JMSException

bodyChange

protected void bodyChange()
                   throws JMSException
Throws:
JMSException


Copyright © 2006 JBoss Inc. All Rights Reserved.