Author: arnaudsimon
Date: Wed Aug  8 08:31:52 2007
New Revision: 563917

URL: http://svn.apache.org/viewvc?view=rev&rev=563917
Log:
implemented Message 

Modified:
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/Session.java
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/MessageActor.java
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/MessageConsumerImpl.java
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/SessionImpl.java
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/MessageImpl.java
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/QpidMessage.java

Modified: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/Session.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/Session.java?view=diff&rev=563917&r1=563916&r2=563917
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/Session.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/Session.java
 Wed Aug  8 08:31:52 2007
@@ -212,6 +212,8 @@
      * that the previous message listener is replaced. This is done gracefully 
i.e. the message
      * listener is replaced once it return from the processing of a message.
      *
+     * // todo when a listener is null then received messages must be released 
+     *
      * @param destination The destination the listener is associated with.
      * @param listener    The new listener for this destination.
      */
@@ -287,7 +289,7 @@
      * <p>Message must have been previously acquired either by receiving them 
in
      * pre-acquire mode or by explicitly acquiring them.
      *
-     * @param range Range of acknowledged messages.
+     * @param ranges Range of acknowledged messages.
      * @throws QpidException If the acknowledgement of the messages fails due 
to some error.
      */
     public void messageAcknowledge(RangeSet ranges) throws QpidException;
@@ -297,7 +299,7 @@
      * <p> A rejected message will not be delivered to any receiver
      * and may be either discarded or moved to the broker dead letter queue.
      *
-     * @param range Range of rejected messages.
+     * @param ranges Range of rejected messages.
      * @throws QpidException If those messages cannot be rejected dus to some 
error
      */
     public void messageReject(RangeSet ranges) throws QpidException;

Modified: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/MessageActor.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/MessageActor.java?view=diff&rev=563917&r1=563916&r2=563917
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/MessageActor.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/MessageActor.java
 Wed Aug  8 08:31:52 2007
@@ -85,6 +85,16 @@
         if (!_isClosed)
         {
             closeMessageActor();
+            try
+            {
+                // cancel this destination
+                
getSession().getQpidSession().messageCancel(getMessageActorID());
+            }
+            catch (QpidException e)
+            {
+                throw ExceptionHelper.convertQpidExceptionToJMSException(e);
+            }
+            //todo: We need to unset the qpid message listener  
             // notify the session that this message actor is closing
             _session.closeMessageActor(this);
         }
@@ -145,15 +155,6 @@
     {
         if (!_isClosed)
         {
-            try
-            {
-                // cancle this destination 
-                
getSession().getQpidSession().messageCancel(getMessageActorID());
-            }
-            catch (QpidException e)
-            {
-                throw ExceptionHelper.convertQpidExceptionToJMSException(e);
-            }
             _isClosed = true;
         }
     }

Modified: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/MessageConsumerImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/MessageConsumerImpl.java?view=diff&rev=563917&r1=563916&r2=563917
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/MessageConsumerImpl.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/MessageConsumerImpl.java
 Wed Aug  8 08:31:52 2007
@@ -569,7 +569,8 @@
         if (_preAcquire)
         {
             RangeSet ranges = new RangeSet();
-            ranges.add(message.getMessageID());
+            // TODO: messageID is a string but range need a long???
+            //ranges.add(message.getMessageID());
             getSession().getQpidSession().messageRelease(ranges);
         }
     }
@@ -587,12 +588,13 @@
         if (!_preAcquire)
         {
             RangeSet ranges = new RangeSet();
-            ranges.add(message.getMessageID());
+            // TODO: messageID is a string but range need a long???
+            // ranges.add(message.getMessageID());
 
             RangeSet acquired = 
getSession().getQpidSession().messageAcquire(ranges);
             if (acquired.size() > 0)
             {
-                result = acquired.iterator().next().getLower() == 
message.getMessageID();
+                result = true; // todo acquired.iterator().next().getLower() 
== message.getMessageID();
             }
         }
         return result;
@@ -609,7 +611,8 @@
         if (!_preAcquire)
         {
             RangeSet ranges = new RangeSet();
-            ranges.add(message.getMessageID());
+            // TODO: messageID is a string but range need a long???
+            // ranges.add(message.getMessageID());
             getSession().getQpidSession().messageAcknowledge(ranges);
         }
     }

Modified: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/SessionImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/SessionImpl.java?view=diff&rev=563917&r1=563916&r2=563917
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/SessionImpl.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/SessionImpl.java
 Wed Aug  8 08:31:52 2007
@@ -21,8 +21,8 @@
 import org.slf4j.LoggerFactory;
 import org.apache.qpidity.jms.message.*;
 import org.apache.qpidity.QpidException;
-import org.apache.qpidity.Range;
 import org.apache.qpidity.RangeSet;
+import org.apache.qpidity.Range;
 
 import javax.jms.*;
 import javax.jms.IllegalStateException;
@@ -143,8 +143,7 @@
             acknowledgeMode = Session.SESSION_TRANSACTED;
         }
         _acknowledgeMode = acknowledgeMode;
-   /*
-        
+
         // create the qpid session with an expiry  <= 0 so that the session 
does not expire
         _qpidSession = _connection.getQpidConnection().createSession(0);
         // set transacted if required
@@ -152,7 +151,7 @@
         {
             _qpidSession.txSelect();
         }
-   */     
+
         // init the message dispatcher.
         initMessageDispatcherThread();
     }
@@ -445,7 +444,8 @@
         {
             // release this message
             RangeSet ranges = new RangeSet();
-            ranges.add(message.getMessageID());
+            // TODO: messageID is a string but range need a long???
+            // ranges.add(message.getMessageID());
             try
             {
                 getQpidSession().messageRelease(ranges);
@@ -985,7 +985,8 @@
         {
             // acknowledge this message
             RangeSet ranges = new RangeSet();
-            ranges.add(message.getMessageID());
+            // TODO: messageID is a string but range need a long???
+           // ranges.add(message.getMessageID());
             try
             {
                 getQpidSession().messageAcknowledge(ranges);
@@ -1020,7 +1021,8 @@
                 {
                     // acknowledge this message
                     RangeSet ranges = new RangeSet();
-                    ranges.add(message.getMessageID());
+                    // TODO: messageID is a string but range need a long???
+                    // ranges.add(message.getMessageID());
                     try
                     {
                         getQpidSession().messageAcknowledge(ranges);

Modified: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/MessageImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/MessageImpl.java?view=diff&rev=563917&r1=563916&r2=563917
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/MessageImpl.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/MessageImpl.java
 Wed Aug  8 08:31:52 2007
@@ -17,9 +17,13 @@
  */
 package org.apache.qpidity.jms.message;
 
+import org.apache.qpidity.jms.ExceptionHelper;
+import org.apache.qpidity.QpidException;
+
 import javax.jms.Message;
 import javax.jms.JMSException;
 import javax.jms.Destination;
+import javax.jms.DeliveryMode;
 import java.util.Enumeration;
 
 /**
@@ -27,7 +31,25 @@
  */
 public class MessageImpl extends QpidMessage implements Message
 {
-    private String _messageID;
+    /**
+     * The ReplyTo destination for this message
+     * TODO set it when the message is received
+     */
+    private Destination _replyTo;
+
+    /**
+     * The destination to which the message has been sent.
+     * <p>When a message is sent this value is ignored. After completion
+     * of the send method it holds the destination specified by the send.
+     * <p>When a message is received, its destination value must be
+     * equivalent to the value assigned when it was sent.  --> TODO
+     */
+    private Destination _destination;
+
+    /**
+     * Indicates whether the message properties are in writeable status.
+     */
+    private boolean _readOnly = false;
 
     //---- javax.jms.Message interface
     /**
@@ -42,16 +64,17 @@
      * not required.
      *
      * @return The message ID
-     * @throws JMSException If getting the message Id fails due to internal 
JMS error.
+     * @throws JMSException If getting the message Id fails due to internal 
error.
      */
     public String getJMSMessageID() throws JMSException
     {
-        // check if the message ID has been set
-        if (_messageID == null)
+        String messageID = super.getMessageID();
+
+        if (messageID != null)
         {
-            _messageID = super.getJMSMessageID();
+            messageID = "ID:" + messageID;
         }
-        return _messageID;
+        return messageID;
     }
 
     /**
@@ -61,26 +84,32 @@
      * can be used to change the value of a message that's been received.
      *
      * @param messageID The ID of the message
-     * @throws JMSException If setting the message Id fails due to internal 
JMS error.
+     * @throws JMSException If setting the message Id fails due to internal 
error.
      */
     public void setJMSMessageID(String messageID) throws JMSException
     {
-        _messageID = messageID;
+        String qpidmessageID = null;
+        if (messageID != null)
+        {
+            if (messageID.substring(0, 3).equals("ID:"))
+            {
+                qpidmessageID = messageID.substring(3, messageID.length());
+            }
+        }
+        super.setMessageID(qpidmessageID);
     }
 
     /**
      * Get the message timestamp.
-     * <p> The JMS sepc says:  
+     * <p> The JMS sepc says:
      * <P>The JMSTimestamp header field contains the time a message was
      * handed off to a provider to be sent. It is not the time the
      * message was actually transmitted because the actual send may occur
      * later due to transactions or other client side queueing of messages.
-     * <p/>
      * <P>When a message is sent, JMSTimestamp is ignored. When the send
      * method returns it contains a a time value somewhere in the interval
      * between the call and the return. It is in the format of a normal
      * Java millis time value.
-     * <p/>
      * <P>Since timestamps take some effort to create and increase a
      * message's size, some JMS providers may be able to optimize message
      * overhead if they are given a hint that timestamp is not used by an
@@ -92,129 +121,340 @@
      * be set to its normal value.
      *
      * @return the message timestamp
-     * @throws JMSException if JMS fails to get the Timestamp
-     *                      due to internal JMS error.
-     * @see Message#setJMSTimestamp(long)
+     * @throws JMSException If getting the Timestamp fails due to internal 
error.
      */
     public long getJMSTimestamp() throws JMSException
     {
-        // TODO
-        return 0;
+        return super.getTimestamp();
     }
 
-    public void setJMSTimestamp(long l) throws JMSException
+    /**
+     * Set the message timestamp.
+     * <p> The JMS spec says:
+     * <P>Providers set this field when a message is sent. This operation
+     * can be used to change the value of a message that's been received.
+     *
+     * @param timestamp The timestamp for this message
+     * @throws JMSException If setting the timestamp fails due to some 
internal error.
+     */
+    public void setJMSTimestamp(long timestamp) throws JMSException
     {
-        // TODO
-
+        super.setTimestamp(timestamp);
     }
 
+    /**
+     * Get the correlation ID as an array of bytes for the message.
+     * <p> JMS spec says:
+     * <P>The use of a byte[] value for JMSCorrelationID is non-portable.
+     *
+     * @return the correlation ID of a message as an array of bytes.
+     * @throws JMSException If getting correlationId fails due to some 
internal error.
+     */
     public byte[] getJMSCorrelationIDAsBytes() throws JMSException
     {
-        // TODO
-        return new byte[0];
+        String correlationID = getJMSCorrelationID();
+        if (correlationID != null)
+        {
+            return correlationID.getBytes();
+        }
+        return null;
     }
 
-    public void setJMSCorrelationIDAsBytes(byte[] bytes) throws JMSException
+    /**
+     * Set the correlation ID as an array of bytes for the message.
+     * <p> JMS spec says:
+     * <P>If a provider supports the native concept of correlation id, a
+     * JMS client may need to assign specific JMSCorrelationID values to
+     * match those expected by non-JMS clients. JMS providers without native
+     * correlation id values are not required to support this (and the
+     * corresponding get) method; their implementation may throw
+     * java.lang.UnsupportedOperationException).
+     * <P>The use of a byte[] value for JMSCorrelationID is non-portable.
+     *
+     * @param correlationID The correlation ID value as an array of bytes.
+     * @throws JMSException If setting correlationId fails due to some 
internal error.
+     */
+    public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws 
JMSException
     {
-        // TODO
-
+        setJMSCorrelationID(new String(correlationID));
     }
 
-    public void setJMSCorrelationID(String string) throws JMSException
+    /**
+     * Set the correlation ID for the message.
+     * <p> JMS spec says:
+     * <P>A client can use the JMSCorrelationID header field to link one
+     * message with another. A typically use is to link a response message
+     * with its request message.
+     * <P>Since each message sent by a JMS provider is assigned a message ID
+     * value it is convenient to link messages via message ID. All message ID
+     * values must start with the `ID:' prefix.
+     * <P>In some cases, an application (made up of several clients) needs to
+     * use an application specific value for linking messages. For instance,
+     * an application may use JMSCorrelationID to hold a value referencing
+     * some external information. Application specified values must not start
+     * with the `ID:' prefix; this is reserved for provider-generated message
+     * ID values.
+     *
+     * @param correlationID The message ID of a message being referred to.
+     * @throws JMSException If setting the correlationId fails due to some 
internal error.
+     */
+    public void setJMSCorrelationID(String correlationID) throws JMSException
     {
-        // TODO
+        super.setCorrelationID(correlationID);
 
     }
 
+    /**
+     * Get the correlation ID for the message.
+     *
+     * @return The correlation ID of a message as a String.
+     * @throws JMSException If getting the correlationId fails due to some 
internal error.
+     */
     public String getJMSCorrelationID() throws JMSException
     {
-        // TODO
-        return null;
+        return super.getCorrelationID();
     }
 
+    /**
+     * Get where a reply to this message should be sent.
+     *
+     * @return The destination where a reply to this message should be sent.
+     * @throws JMSException If getting the ReplyTo Destination fails due to 
some internal error.
+     */
     public Destination getJMSReplyTo() throws JMSException
     {
-        // TODO
-        return null;
+        return _replyTo;
     }
 
+    /**
+     * Set where a reply to this message should be sent.
+     * <p> The JMS spec says:
+     * <P>The replyTo header field contains the destination where a reply
+     * to the current message should be sent. If it is null no reply is
+     * expected. The destination may be either a Queue or a Topic.
+     * <P>Messages with a null replyTo value are called JMS datagrams.
+     * Datagrams may be a notification of some change in the sender (i.e.
+     * they signal a sender event) or they may just be some data the sender
+     * thinks is of interest.
+     * <p> Messages with a replyTo value are typically expecting a response.
+     * A response may be optional, it is up to the client to decide. These
+     * messages are called JMS requests. A message sent in response to a
+     * request is called a reply.
+     *
+     * @param destination The destination where a reply to this message should 
be sent.
+     * @throws JMSException If setting the ReplyTo Destination fails due to 
some internal error.
+     */
     public void setJMSReplyTo(Destination destination) throws JMSException
     {
-        // TODO
-
+        _replyTo = destination;
     }
 
+    /**
+     * Get the destination for this message.
+     * <p> The JMS spec says:
+     * <p>The destination field contains the destination to which the
+     * message is being sent.
+     * <p>When a message is sent this value is ignored. After completion
+     * of the send method it holds the destination specified by the send.
+     * <p>When a message is received, its destination value must be
+     * equivalent to the value assigned when it was sent.
+     *
+     * @return The destination of this message.
+     * @throws JMSException If getting the JMS Destination fails due to some 
internal error.
+     */
     public Destination getJMSDestination() throws JMSException
     {
-        // TODO
-        return null;
+        return _destination;
     }
 
+    /**
+     * Set the destination for this message.
+     * <p: JMS spec says:
+     * <p>Providers set this field when a message is sent. This operation
+     * can be used to change the value of a message that's been received.
+     *
+     * @param destination The destination this message has been sent.
+     * @throws JMSException If setting the JMS Destination fails due to some 
internal error.
+     */
     public void setJMSDestination(Destination destination) throws JMSException
     {
-        // TODO
-
+        _destination = destination;
     }
 
+    /**
+     * Get the delivery mode for this message.
+     *
+     * @return the delivery mode of this message.
+     * @throws JMSException If getting the JMS DeliveryMode fails due to some 
internal error.
+     */
     public int getJMSDeliveryMode() throws JMSException
     {
-        // TODO
-        return 0;
+        int result = DeliveryMode.NON_PERSISTENT;
+        short amqpDeliveryMode = super.getdeliveryMode();
+        if (amqpDeliveryMode == QpidMessage.DELIVERY_MODE_PERSISTENT)
+        {
+            result = DeliveryMode.PERSISTENT;
+        }
+        else if (amqpDeliveryMode != DELIVERY_MODE_NON_PERSISTENT)
+        {
+            throw new JMSException("Problem when accessing message delivery 
mode");
+        }
+        return result;
     }
 
-    public void setJMSDeliveryMode(int i) throws JMSException
+    /**
+     * Set the delivery mode for this message.
+     * <p> The JMS spec says:
+     * <p>Providers set this field when a message is sent. This operation
+     * can be used to change the value of a message that's been received.
+     *
+     * @param deliveryMode the delivery mode for this message.
+     * @throws JMSException If setting the JMS DeliveryMode fails due to some 
internal error.
+     */
+    public void setJMSDeliveryMode(int deliveryMode) throws JMSException
     {
-        // TODO
-
+        short amqpDeliveryMode = DELIVERY_MODE_PERSISTENT;
+        if (deliveryMode == DeliveryMode.NON_PERSISTENT)
+        {
+            amqpDeliveryMode = DELIVERY_MODE_NON_PERSISTENT;
+        }
+        else if (deliveryMode != DeliveryMode.PERSISTENT)
+        {
+            throw new JMSException(
+                    "Problem when setting message delivery mode, " + 
deliveryMode + " is not a valid mode");
+        }
+        try
+        {
+            super.setDeliveryMode(amqpDeliveryMode);
+        }
+        catch (QpidException e)
+        {
+            throw ExceptionHelper.convertQpidExceptionToJMSException(e);
+        }
     }
 
+    /**
+     * Get an indication of whether this message is being redelivered.
+     * <p> The JMS spec says:
+     * <p>If a client receives a message with the redelivered indicator set,
+     * it is likely, but not guaranteed, that this message was delivered to
+     * the client earlier but the client did not acknowledge its receipt at
+     * that earlier time.
+     *
+     * @return true if this message is being redelivered, false otherwise
+     * @throws JMSException If getting the JMS Redelivered fails due to some 
internal error.
+     */
     public boolean getJMSRedelivered() throws JMSException
     {
-        // TODO
-        return false;
+        return super.getRedelivered();
     }
 
-    public void setJMSRedelivered(boolean b) throws JMSException
+    /**
+     * Indicate whether this message is being redelivered.
+     * <p> The JMS spec says:
+     * <p>This field is set at the time the message is delivered. This
+     * operation can be used to change the value of a message that's
+     * been received.
+     *
+     * @param redelivered true indicates that the message is being redelivered.
+     * @throws JMSException If setting the JMS Redelivered fails due to some 
internal error.
+     */
+    public void setJMSRedelivered(boolean redelivered) throws JMSException
     {
-        // TODO
-
+        super.setRedelivered(redelivered);
     }
 
+    /**
+     * Get the message type.
+     * <p> The JMS spec says:
+     * <p>Some JMS providers use a message repository that contains the
+     * definition of messages sent by applications. The type header field
+     * contains the name of a message's definition.
+     * <p>JMS does not define a standard message definition repository nor
+     * does it define a naming policy for the definitions it contains. JMS
+     * clients should use symbolic values for type that can be configured
+     * at installation time to the values defined in the current providers
+     * message repository.
+     * <p>JMS clients should assign a value to type whether the application
+     * makes use of it or not. This insures that it is properly set for
+     * those providers that require it.
+     *
+     * @return The message type
+     * @throws JMSException If getting the  JMS message type fails due to some 
internal error.
+     */
     public String getJMSType() throws JMSException
     {
-        // TODO
-        return null;
+        return super.getMessageType();
     }
 
-    public void setJMSType(String string) throws JMSException
+    /**
+     * Set this message type.
+     *
+     * @param type The type of message.
+     * @throws JMSException If setting the JMS message type fails due to some 
internal error.
+     */
+    public void setJMSType(String type) throws JMSException
     {
-        // TODO
-
+        super.setMessageType(type);
     }
 
+    /**
+     * Get the message's expiration value.
+     * <p> The JMS spec says:
+     * <p>When a message is sent, expiration is left unassigned. After
+     * completion of the send method, it holds the expiration time of the
+     * message. This is the sum of the time-to-live value specified by the
+     * client and the GMT at the time of the send.
+     * <p>If the time-to-live is specified as zero, expiration is set to
+     * zero which indicates the message does not expire.
+     *
+     * @return The time the message expires.
+     * @throws JMSException If getting the JMS message expiration fails due to 
some internal error.
+     */
     public long getJMSExpiration() throws JMSException
     {
-        // TODO
-        return 0;
+        return super.getExpiration();
     }
 
-    public void setJMSExpiration(long l) throws JMSException
+    /**
+     * Set the message's expiration value.
+     *
+     * @param expiration the message's expiration time
+     * @throws JMSException If setting the JMS message expiration fails due to 
some internal error.
+     */
+    public void setJMSExpiration(long expiration) throws JMSException
     {
-        // TODO
-
+        super.setExpiration(expiration);
     }
 
+
+    /**
+     * Get the message priority.
+     * <p> The JMS spec says:
+     * <p>JMS defines a ten level priority value with 0 as the lowest
+     * priority and 9 as the highest. In addition, clients should consider
+     * priorities 0-4 as gradations of normal priority and priorities 5-9
+     * as gradations of expedited priority.
+     *
+     * @return The message priority.
+     * @throws JMSException If getting the JMS message priority fails due to 
some internal error.
+     */
     public int getJMSPriority() throws JMSException
     {
-        // TODO
-        return 0;
+        return super.getMessagePriority();
     }
 
-    public void setJMSPriority(int i) throws JMSException
+    /**
+     * Set the priority for this message.
+     *
+     * @param priority The priority of this message.
+     * @throws JMSException If setting the JMS message priority fails due to 
some internal error.
+     */
+    public void setJMSPriority(int priority) throws JMSException
     {
-        // TODO
-
+        super.setMessagePriority((short) priority);
     }
+
 
     public void clearProperties() throws JMSException
     {

Modified: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/QpidMessage.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/QpidMessage.java?view=diff&rev=563917&r1=563916&r2=563917
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/QpidMessage.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/QpidMessage.java
 Wed Aug  8 08:31:52 2007
@@ -20,50 +20,214 @@
  */
 package org.apache.qpidity.jms.message;
 
+import org.apache.qpidity.ReplyTo;
+import org.apache.qpidity.QpidException;
+
 import javax.jms.Message;
-import javax.jms.JMSException;
 
 
 public class QpidMessage
 {
     /**
-     * The underlying qpidity message 
+     * The underlying qpidity message
      */
     private org.apache.qpidity.api.Message _qpidityMessage;
 
+    //--- This is required as AMQP delivery modes are different from the JMS 
ones
+    public static final short DELIVERY_MODE_PERSISTENT = 2;
+    public static final short DELIVERY_MODE_NON_PERSISTENT = 1;
+    //--- This is the default message type
+    public static final String MESSAGE_TYPE = "JMS Message";
 
-    //---  javax.jsm.Message API
+    /**
+     * The message properties
+     */
+    
     /**
      * Get the message ID.
-     * <p> The JMS sprec says:
-     * <p>The messageID header field contains a value that uniquely
-     * identifies each message sent by a provider.
-     * <p>When a message is sent, messageID can be ignored. When
-     * the send method returns it contains a provider-assigned value.
-     * <P>All JMSMessageID values must start with the prefix `ID:'.
-     * Uniqueness of message ID values across different providers is
-     * not required.
      *
      * @return The message ID
-     * @throws JMSException If getting the message Id fails due to internal 
JMS error.
      */
-    public String getJMSMessageID() throws JMSException
+    public String getMessageID()
     {
-        return "ID:" + _qpidityMessage.getMessageProperties().getMessageId();
+        return _qpidityMessage.getMessageProperties().getMessageId();
     }
 
+    /**
+     * Set the message ID.
+     *
+     * @param messageID The ID of the message
+     */
+    protected void setMessageID(String messageID)
+    {
+        _qpidityMessage.getMessageProperties().setMessageId(messageID);
+    }
+
+    /**
+     * Get the message timestamp.
+     *
+     * @return The message timestamp.
+     */
+    protected long getTimestamp()
+    {
+        return _qpidityMessage.getDeliveryProperties().getTimestamp();
+    }
 
+    /**
+     * Set the message timestamp.
+     *
+     * @param timestamp the timestamp for this message
+     */
+    protected void setTimestamp(long timestamp)
+    {
+        _qpidityMessage.getDeliveryProperties().setTimestamp(timestamp);
+    }
 
-    public Message getJMSMessage()
+    /**
+     * Set the JMS correlation ID
+     *
+     * @param correlationID The JMS correlation ID.
+     */
+    protected void setCorrelationID(String correlationID)
     {
-        // todo
-        return null;
+        _qpidityMessage.getMessageProperties().setCorrelationId(correlationID);
+    }
+
+    /**
+     * Get the JMS correlation ID
+     *
+     * @return The JMS correlation ID
+     */
+    protected String getCorrelationID()
+    {
+        return _qpidityMessage.getMessageProperties().getCorrelationId();
+    }
+
+    /**
+     * Get the ReplyTo for this message.
+     *
+     * @return The ReplyTo for this message.
+     */
+    protected ReplyTo getReplyTo()
+    {
+        return _qpidityMessage.getMessageProperties().getReplyTo();
+    }
+
+    /**
+     * Get this message  Delivery mode
+     * The delivery mode may be non-persistent (1) or persistent (2)
+     *
+     * @return the delivery mode of this message.
+     */
+    protected short getdeliveryMode()
+    {
+        return _qpidityMessage.getDeliveryProperties().getDeliveryMode();
+    }
+
+    /**
+     * Set the delivery mode for this message.
+     *
+     * @param deliveryMode the delivery mode for this message.
+     * @throws QpidException If the delivery mode is not supported.
+     */
+    protected void setDeliveryMode(short deliveryMode) throws QpidException
+    {
+        if (deliveryMode != DELIVERY_MODE_PERSISTENT && deliveryMode != 
DELIVERY_MODE_NON_PERSISTENT)
+        {
+            throw new QpidException(
+                    "Problem when setting message delivery mode, " + 
deliveryMode + " is not a valid mode",
+                    "wrong delivery mode", null);
+        }
+        _qpidityMessage.getDeliveryProperties().setDeliveryMode(deliveryMode);
+    }
+
+    /**
+     * Get an indication of whether this message is being redelivered.
+     *
+     * @return true if this message is redelivered, false otherwise.
+     */
+    protected boolean getRedelivered()
+    {
+        return _qpidityMessage.getDeliveryProperties().getRedelivered();
+    }
+
+    /**
+     * Indicate whether this message is being redelivered.
+     *
+     * @param redelivered true indicates that the message is being redelivered.
+     */
+    protected void setRedelivered(boolean redelivered)
+    {
+        _qpidityMessage.getDeliveryProperties().setRedelivered(redelivered);
+    }
+
+    /**
+     * Get this message type.
+     * The default value is [EMAIL PROTECTED] QpidMessage#MESSAGE_TYPE}
+     *
+     * @return This message type.
+     */
+    protected String getMessageType()
+    {
+        return _qpidityMessage.getMessageProperties().getType();
     }
 
-    public Long getMessageID()
+    /**
+     * Set this message type.
+     *
+     * @param type The type of message.
+     */
+    protected void setMessageType(String type)
     {
-        //todo
-        return new Long(1);
+        _qpidityMessage.getMessageProperties().setType(type);
+    }
+
+    /**
+     * Get the message's expiration value.
+     *
+     * @return The message's expiration value.
+     */
+    protected long getExpiration()
+    {
+        return _qpidityMessage.getDeliveryProperties().getExpiration();
+    }
+
+    /**
+     * Set the message's expiration value.
+     *
+     * @param expiration The message's expiration value.
+     */
+    protected void setExpiration(long expiration)
+    {
+        _qpidityMessage.getDeliveryProperties().setExpiration(expiration);
+    }
+
+    /**
+     * Get the priority for this message.
+     *
+     * @return The priority for this message.
+     */
+    protected short getMessagePriority()
+    {
+        return _qpidityMessage.getDeliveryProperties().getPriority();
+    }
+
+    /**
+     * Set the priority for this message.
+     *
+     * @param priority The priority for this message.
+     */
+    protected void setMessagePriority(short priority)
+    {
+        _qpidityMessage.getDeliveryProperties().setPriority(priority);
+    }
+
+
+
+    public Message getJMSMessage()
+    {
+        // todo
+        return null;
     }
 
 }


Reply via email to