You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ar...@apache.org on 2007/07/27 18:10:32 UTC

svn commit: r560296 [1/3] - in /incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient: ./ api/ jms/ jms/message/

Author: arnaudsimon
Date: Fri Jul 27 09:10:27 2007
New Revision: 560296

URL: http://svn.apache.org/viewvc?view=rev&rev=560296
Log: (empty)

Added:
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageListenerWrapper.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/AbstractBytesMessage.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/AbstractBytesTypedMessage.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/AbstractJMSMessage.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/AbstractJMSMessageFactory.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSBytesMessage.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSBytesMessageFactory.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSHeaderAdapter.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSMapMessage.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSMapMessageFactory.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSObjectMessage.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSObjectMessageFactory.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSStreamMessage.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSStreamMessageFactory.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSTextMessage.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/JMSTextMessageFactory.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/MessageConverter.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/MessageFactory.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/MessageFactoryRegistry.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/QpidMessage.java   (with props)
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/UnprocessedMessage.java   (with props)
Modified:
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/FieldTable.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Connection.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/CreateReceiverOption.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeclareExchangeOption.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeclareQueueOption.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeleteExchangeOption.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeleteQueueOption.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DtxSession.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/ExceptionListener.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Message.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageListener.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageReceiver.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageSender.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Resource.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Session.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ConnectionImpl.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ConnectionMetaDataImpl.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/CustomJMSXProperty.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ExceptionHelper.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QpidExceptionListenerImpl.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueSessionImpl.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/SessionImpl.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSessionImpl.java

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/FieldTable.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/FieldTable.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/FieldTable.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/FieldTable.java Fri Jul 27 09:10:27 2007
@@ -19,9 +19,7 @@
 package org.apache.qpid.nclient;
 
 /**
- * Created by Arnaud Simon
- * Date: 23-Jul-2007
- * Time: 09:47:32
+ * 
  */
 public interface FieldTable
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Connection.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Connection.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Connection.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Connection.java Fri Jul 27 09:10:27 2007
@@ -25,10 +25,6 @@
 
 /**
  * This represents a physical connection to a broker.
- * <p/>
- * Created by Arnaud Simon
- * Date: 20-Jul-2007
- * Time: 09:34:15
  */
 public interface Connection
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/CreateReceiverOption.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/CreateReceiverOption.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/CreateReceiverOption.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/CreateReceiverOption.java Fri Jul 27 09:10:27 2007
@@ -2,10 +2,6 @@
 
 /**
  * Enumeration of the options available when creating a receiver
- *
- * Created by Arnaud Simon
- * Date: 20-Jul-2007
- * Time: 09:43:31
  */
 public enum CreateReceiverOption
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeclareExchangeOption.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeclareExchangeOption.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeclareExchangeOption.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeclareExchangeOption.java Fri Jul 27 09:10:27 2007
@@ -2,10 +2,6 @@
 
 /**
  * Enumeration of the options available when declaring an exchange
- *
- * Created by Arnaud Simon
- * Date: 20-Jul-2007
- * Time: 09:44:52
  */
 public enum DeclareExchangeOption
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeclareQueueOption.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeclareQueueOption.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeclareQueueOption.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeclareQueueOption.java Fri Jul 27 09:10:27 2007
@@ -3,9 +3,6 @@
 /**
  * Enumeration of the options available when declaring a queue
  *
- * Created by Arnaud Simon
- * Date: 23-Jul-2007
- * Time: 09:44:36
  */
 public enum DeclareQueueOption
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeleteExchangeOption.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeleteExchangeOption.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeleteExchangeOption.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeleteExchangeOption.java Fri Jul 27 09:10:27 2007
@@ -1,9 +1,7 @@
 package org.apache.qpid.nclient.api;
 
 /**
- * Created by Arnaud Simon
- * Date: 23-Jul-2007
- * Time: 12:55:55
+ * Available options for deleting an exchange.
  */
 public enum DeleteExchangeOption
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeleteQueueOption.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeleteQueueOption.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeleteQueueOption.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DeleteQueueOption.java Fri Jul 27 09:10:27 2007
@@ -1,9 +1,7 @@
 package org.apache.qpid.nclient.api;
 
 /**
- * Created by Arnaud Simon
- * Date: 23-Jul-2007
- * Time: 12:44:43
+ * Available options for deleting a queue.
  */
 public enum DeleteQueueOption
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DtxSession.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DtxSession.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DtxSession.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/DtxSession.java Fri Jul 27 09:10:27 2007
@@ -22,10 +22,6 @@
 
 /**
  * This session�s resources are control under the scope of a distributed transaction.
- *
- * Created by Arnaud Simon
- * Date: 20-Jul-2007
- * Time: 09:39:11
  */
 public interface DtxSession extends Session
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/ExceptionListener.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/ExceptionListener.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/ExceptionListener.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/ExceptionListener.java Fri Jul 27 09:10:27 2007
@@ -23,10 +23,6 @@
 /**
  * If the communication layer detects a serious problem with a <CODE>connection</CODE>, it
  * informs the connection's ExceptionListener
- *
- * Created by Arnaud Simon
- * Date: 25-Jul-2007
- * Time: 12:00:27
  */
 public interface ExceptionListener
 {
@@ -35,7 +31,7 @@
      * informs the connection's ExceptionListener
      *
      * @param exception The exception comming from the communication layer.
-     * @see org.apache.qpid.nclient.qpidapi.Connection
+     * @see org.apache.qpid.nclient.api.Connection
      */
     public void onException(QpidException exception);
 }

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Message.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Message.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Message.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Message.java Fri Jul 27 09:10:27 2007
@@ -26,10 +26,6 @@
 
 /**
  * A message is sent and received by resources. It is composed of a set of header and a payload.
- * <p/>
- * Created by Arnaud Simon
- * Date: 20-Jul-2007
- * Time: 09:40:49
  */
 public interface Message
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageListener.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageListener.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageListener.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageListener.java Fri Jul 27 09:10:27 2007
@@ -20,10 +20,6 @@
 
 /**
  * MessageListeners are used to asynchronously receive messages.
- *
- * Created by Arnaud Simon
- * Date: 2o-Jul-2007
- * Time: 09:42:52
  */
 public interface MessageListener
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageReceiver.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageReceiver.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageReceiver.java Fri Jul 27 09:10:27 2007
@@ -24,11 +24,6 @@
 
 /**
  * Used to receive messages from a queue
- * 
- * <p/>
- * Created by Arnaud Simon
- * Date: 20-Jul-2007
- * Time: 09:42:37
  */
 public interface MessageReceiver extends Resource
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageSender.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageSender.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageSender.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/MessageSender.java Fri Jul 27 09:10:27 2007
@@ -22,10 +22,6 @@
 
 /**
  * A sender is used to send message to its queue.
- * <p/>
- * Created by Arnaud Simon
- * Date: 22-Jul-2007
- * Time: 09:41:58
  */
 public interface MessageSender extends Resource
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Resource.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Resource.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Resource.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Resource.java Fri Jul 27 09:10:27 2007
@@ -22,10 +22,6 @@
 
 /**
  * A Resource is associated with a session and can be independently closed.
- *
- * Created by Arnaud Simon
- * Date: 21-Jul-2007
- * Time: 09:41:30
  */
 public interface Resource
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Session.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Session.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Session.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/api/Session.java Fri Jul 27 09:10:27 2007
@@ -25,10 +25,6 @@
  * A session is associated with a connection.
  * <p> When created a Session is not attached with an underlying channel. Unsuspended a Session is
  * equivalent to attaching a communication channel that can be used to communicate with the broker.
- * <p/>
- * Created by Arnaud Simon
- * Date: 20-Jul-2007
- * Time: 09:36:24
  */
 public interface Session
 {
@@ -198,7 +194,6 @@
      * @param queueName    The queue to be bound.
      * @param exchangeName The exchange name.
      * @param routingKey   The routing key.
-     * @param nowait       nowait
      * @throws QpidException If the session fails to bind the queue due to some error.
      */
     public void queueBind(String queueName, String exchangeName, String routingKey)
@@ -224,7 +219,6 @@
      * TODO: Define the exact semantic i.e. are message sent to a dead letter queue?
      *
      * @param queueName The queue to be purged
-     * @param nowait    nowait
      * @throws QpidException If the session fails to purge the queue due to some error.
      */
     public void queuePurge(String queueName)

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ConnectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ConnectionImpl.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ConnectionImpl.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ConnectionImpl.java Fri Jul 27 09:10:27 2007
@@ -30,9 +30,7 @@
 
 
 /**
- * Created by Arnaud Simon
- * Date: 25-Jul-2007
- * Time: 09:47:17
+ * 
  */
 public class ConnectionImpl implements Connection, QueueConnection, TopicConnection
 {
@@ -106,9 +104,7 @@
 
     //---- Interface javax.jms.Connection ---//
 
-    public Session createSession(boolean b, int i)
-            throws
-            JMSException
+    public Session createSession(boolean b, int i) throws JMSException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
@@ -123,9 +119,7 @@
      * @return The unique client identifier.
      * @throws JMSException If this connection is closed.
      */
-    public String getClientID()
-            throws
-            JMSException
+    public String getClientID() throws JMSException
     {
         checkNotClosed();
 
@@ -147,9 +141,7 @@
      * @param clientID the unique client identifier
      * @throws JMSException Always as clientID is always set at construction time.
      */
-    public void setClientID(String clientID)
-            throws
-            JMSException
+    public void setClientID(String clientID) throws JMSException
     {
         checkNotClosed();
         throw new IllegalStateException("Client name cannot be changed after being set");
@@ -162,9 +154,7 @@
      * @throws JMSException If there ie a problem getting the connection metadata for this connection.
      * @see javax.jms.ConnectionMetaData
      */
-    public ConnectionMetaData getMetaData()
-            throws
-            JMSException
+    public ConnectionMetaData getMetaData() throws JMSException
     {
         checkNotClosed();
         return ConnectionMetaDataImpl.getInstance();
@@ -176,9 +166,7 @@
      * @return the <CODE>ExceptionListener</CODE> for this connection
      * @throws JMSException In case of unforeseen problem
      */
-    public ExceptionListener getExceptionListener()
-            throws
-            JMSException
+    public ExceptionListener getExceptionListener() throws JMSException
     {
         checkNotClosed();
         return _exceptionListener;
@@ -203,9 +191,7 @@
      * @param exceptionListener The connection listener.
      * @throws JMSException If the connection is closed.
      */
-    public void setExceptionListener(ExceptionListener exceptionListener)
-            throws
-            JMSException
+    public void setExceptionListener(ExceptionListener exceptionListener) throws JMSException
     {
         checkNotClosed();
         _exceptionListener = exceptionListener;
@@ -219,9 +205,7 @@
      *
      * @throws JMSException In case of a problem due to some internal error.
      */
-    public void start()
-            throws
-            JMSException
+    public void start() throws JMSException
     {
         checkNotClosed();
         if (!_started)
@@ -246,9 +230,7 @@
      *
      * @throws JMSException In case of a problem due to some internal error.
      */
-    public void stop()
-            throws
-            JMSException
+    public void stop() throws JMSException
     {
         checkNotClosed();
         if (_started)
@@ -278,9 +260,7 @@
      *
      * @throws JMSException In case of a problem due to some internal error.
      */
-    public void close()
-            throws
-            JMSException
+    public void close() throws JMSException
     {
         checkNotClosed();
         if (!_isClosed)
@@ -317,9 +297,8 @@
      * @throws JMSException In case of a problem due to some internal error.
      */
     public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector,
-                                                       ServerSessionPool sessionPool, int maxMessages)
-            throws
-            JMSException
+                                                       ServerSessionPool sessionPool, int maxMessages) throws
+                                                                                                       JMSException
     {
         checkNotClosed();
         return null;
@@ -338,9 +317,7 @@
      */
     public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName,
                                                               String messageSelector, ServerSessionPool sessionPool,
-                                                              int maxMessages)
-            throws
-            JMSException
+                                                              int maxMessages) throws JMSException
     {
         checkNotClosed();
         return null;
@@ -348,9 +325,7 @@
 
     //-------------- QueueConnection API
 
-    public QueueSession createQueueSession(boolean b, int i)
-            throws
-            JMSException
+    public QueueSession createQueueSession(boolean b, int i) throws JMSException
     {
         checkNotClosed();
         //TODO: create a queue session
@@ -359,25 +334,21 @@
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
 
-    public ConnectionConsumer createConnectionConsumer(Queue queue, String string, ServerSessionPool serverSessionPool, int i)
-            throws
-            JMSException
+    public ConnectionConsumer createConnectionConsumer(Queue queue, String string, ServerSessionPool serverSessionPool,
+                                                       int i) throws JMSException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
 
     //-------------- TopicConnection API
 
-    public TopicSession createTopicSession(boolean b, int i)
-            throws
-            JMSException
+    public TopicSession createTopicSession(boolean b, int i) throws JMSException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
 
-    public ConnectionConsumer createConnectionConsumer(Topic topic, String string, ServerSessionPool serverSessionPool, int i)
-            throws
-            JMSException
+    public ConnectionConsumer createConnectionConsumer(Topic topic, String string, ServerSessionPool serverSessionPool,
+                                                       int i) throws JMSException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
@@ -387,15 +358,12 @@
     /**
      * Validate that the Connection is not closed.
      * <p/>
-     * If the Connection has been closed, throw a javax.jms.IllegalStateException. This behaviour is
+     * If the Connection has been closed, throw a IllegalStateException. This behaviour is
      * required by the JMS specification.
      *
-     * @throws javax.jms.IllegalStateException
-     *          If the session is closed.
+     * @throws IllegalStateException If the session is closed.
      */
-    protected synchronized void checkNotClosed()
-            throws
-            IllegalStateException
+    protected synchronized void checkNotClosed() throws IllegalStateException
     {
         if (_isClosed)
         {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ConnectionMetaDataImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ConnectionMetaDataImpl.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ConnectionMetaDataImpl.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ConnectionMetaDataImpl.java Fri Jul 27 09:10:27 2007
@@ -26,10 +26,6 @@
 /**
  * A <CODE>ConnectionMetaDataImpl</CODE> object provides information describing the
  * JMS <CODE>Connection</CODE>.
- * <p/>
- * Created by Arnaud Simon
- * Date: 25-Jul-2007
- * Time: 10:47:20
  */
 public class ConnectionMetaDataImpl implements ConnectionMetaData
 {
@@ -53,8 +49,7 @@
     // Provider minor version
     private static final int PROVIDER_MINOR_VERSION = 10;
     // Provider version
-    private static final String PROVIDER_VERSION = QpidProperties.getProductName() + " (Client: ["
-            + QpidProperties.getBuildVersion() + "]  ; Protocol: [ 0.10 ] )";
+    private static final String PROVIDER_VERSION = QpidProperties.getProductName() + " (Client: [" + QpidProperties.getBuildVersion() + "]  ; Protocol: [ 0.10 ] )";
 
     /**
      * Prevent instantiation.
@@ -81,9 +76,7 @@
      * @return the JMS API version
      * @throws JMSException Never
      */
-    public String getJMSVersion()
-            throws
-            JMSException
+    public String getJMSVersion() throws JMSException
     {
         return JMS_VERSION;
     }
@@ -95,9 +88,7 @@
      * @return the JMS API major version number
      * @throws JMSException Never
      */
-    public int getJMSMajorVersion()
-            throws
-            JMSException
+    public int getJMSMajorVersion() throws JMSException
     {
         return JMS_MAJOR_VERSION;
     }
@@ -109,9 +100,7 @@
      * @return the JMS API minor version number
      * @throws JMSException Never
      */
-    public int getJMSMinorVersion()
-            throws
-            JMSException
+    public int getJMSMinorVersion() throws JMSException
     {
         return JMS_MINOR_VERSION;
     }
@@ -123,9 +112,7 @@
      * @return Qpid name
      * @throws JMSException Never
      */
-    public String getJMSProviderName()
-            throws
-            JMSException
+    public String getJMSProviderName() throws JMSException
     {
         return PROVIDER_NAME;
     }
@@ -136,9 +123,7 @@
      * @return Qpid version
      * @throws JMSException Never
      */
-    public String getProviderVersion()
-            throws
-            JMSException
+    public String getProviderVersion() throws JMSException
     {
         return PROVIDER_VERSION;
         // TODO: We certainly can dynamically get the server version.
@@ -150,9 +135,7 @@
      * @return Qpid major version number
      * @throws JMSException Never
      */
-    public int getProviderMajorVersion()
-            throws
-            JMSException
+    public int getProviderMajorVersion() throws JMSException
     {
         return PROVIDER_MAJOR_VERSION;
     }
@@ -163,9 +146,7 @@
      * @return Qpid minor version number
      * @throws JMSException Never
      */
-    public int getProviderMinorVersion()
-            throws
-            JMSException
+    public int getProviderMinorVersion() throws JMSException
     {
         return PROVIDER_MINOR_VERSION;
     }
@@ -176,9 +157,7 @@
      * @return an Enumeration of JMSX property names
      * @throws JMSException if cannot retrieve metadata due to some internal error.
      */
-    public Enumeration getJMSXPropertyNames()
-            throws
-            JMSException
+    public Enumeration getJMSXPropertyNames() throws JMSException
     {
         return CustomJMSXProperty.asEnumeration();
     }

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/CustomJMSXProperty.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/CustomJMSXProperty.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/CustomJMSXProperty.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/CustomJMSXProperty.java Fri Jul 27 09:10:27 2007
@@ -32,11 +32,11 @@
 
     public static synchronized Enumeration asEnumeration()
     {
-        if(_names == null)
+        if (_names == null)
         {
             CustomJMSXProperty[] properties = values();
             ArrayList<String> nameList = new ArrayList<String>(properties.length);
-            for(CustomJMSXProperty property :  properties)
+            for (CustomJMSXProperty property : properties)
             {
                 nameList.add(property.toString());
             }

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ExceptionHelper.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ExceptionHelper.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ExceptionHelper.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/ExceptionHelper.java Fri Jul 27 09:10:27 2007
@@ -22,9 +22,7 @@
 import javax.jms.JMSException;
 
 /**
- * Created by Arnaud Simon
- * Date: 25-Jul-2007
- * Time: 12:54:00
+ *Helper class for handling exceptions
  */
 public class ExceptionHelper
 {

Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java?view=auto&rev=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java (added)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java Fri Jul 27 09:10:27 2007
@@ -0,0 +1,140 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.nclient.jms;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.qpid.nclient.api.Resource;
+import org.apache.qpid.nclient.exception.QpidException;
+
+import javax.jms.IllegalStateException;
+import javax.jms.JMSException;
+
+/**
+ * MessageActor is the superclass for MessageProducerImpl and MessageProducerImpl.
+ */
+public abstract class MessageActor
+{
+    /**
+     * Used for debugging.
+     */
+    private static final Logger _logger = LoggerFactory.getLogger(MessageActor.class);
+
+    /**
+     * Indicates whether this MessageActor is closed.
+     */
+    boolean _isClosed = false;
+
+    /**
+     * This messageActor's session
+     */
+    SessionImpl _session;
+
+    /**
+     * The underlying Qpid Resource
+     */
+    Resource _qpidResource;
+
+    //-- Constructor
+
+    //TODO define the parameters
+
+     protected MessageActor()
+    {
+        
+    }
+
+    protected MessageActor(SessionImpl session)
+    {
+        // TODO create the qpidResource _qpidResource =
+        _session = session;
+    }
+
+    //--- public methods (part of the jms public API)
+    /**
+     * Closes the MessageActor and deregister it from its session.
+     *
+     * @throws JMSException if the MessaeActor cannot be closed due to some internal error.
+     */
+    public void close() throws JMSException
+    {
+        if (!_isClosed)
+        {
+            closeMessageActor();
+            // notify the session that this message actor is closing
+
+            //TODO _session.removeActor(_actorID);
+        }
+    }
+
+    //-- protected methods
+     /**
+     * Check if this MessageActor is not closed.
+     * <p> If the MessageActor is closed, throw a javax.jms.IllegalStateException.
+     * <p> The method is not synchronized, since MessageProducers can only be used by a single thread.
+     *
+     * @throws IllegalStateException if the MessageActor is closed
+     */
+    protected void checkNotClosed() throws IllegalStateException
+    {
+        if (_isClosed || _session == null)
+        {
+            if (_logger.isDebugEnabled())
+            {
+                _logger.debug("Actor " + this + " is already closed");
+            }
+            throw new IllegalStateException("Actor " + this + " is already closed");
+        }
+        _session.checkNotClosed();
+    }
+
+    /**
+     * Closes a MessageActor.
+     * <p> This method is invoked when the session is closing or when this
+     * messageActor is closing.
+     *
+     * @throws JMSException If the MessaeActor cannot be closed due to some internal error.
+     */
+    protected void closeMessageActor() throws JMSException
+    {
+        if (!_isClosed)
+        {
+            // close the underlying qpid resource
+            try
+            {
+                _qpidResource.close();
+            }
+            catch (QpidException e)
+            {
+                throw ExceptionHelper.convertQpidExceptionToJMSException(e);
+            }
+            _isClosed = true;
+        }
+    }
+
+    /**
+     * Get the associated session object. 
+     *
+     * @return This Actor's Session.
+     */
+    protected  SessionImpl getSession()
+    {
+        return _session;
+    }
+
+}

Propchange: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java?view=auto&rev=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java (added)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java Fri Jul 27 09:10:27 2007
@@ -0,0 +1,148 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.nclient.jms;
+
+import org.apache.qpid.nclient.api.MessageReceiver;
+import org.apache.qpid.nclient.exception.QpidException;
+
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Message;
+
+/**
+ * Implementation of JMS message consumer 
+ */
+public class MessageConsumerImpl extends MessageActor implements MessageConsumer
+{
+    /**
+     * The underlying qpid receiver
+     */
+    MessageReceiver _qpidReceiver;
+
+    /**
+     * This MessageConsumer's messageselector.
+     */
+    protected String _messageSelector = null;
+
+    /**
+     * A MessageListener set up for this consumer.
+     */
+    private MessageListener _messageListener = null;
+
+    //----- Message consumer API
+
+    /**
+     * Gets this  MessageConsumer's message selector.
+     *
+     * @return This MessageConsumer's message selector, or null if no
+     *         message selector exists for the message consumer (that is, if
+     *         the message selector was not set or was set to null or the
+     *         empty string)
+     * @throws JMSException if getting the message selector fails due to some internal error.
+     */
+    public String getMessageSelector() throws JMSException
+    {
+        checkNotClosed();
+        return _messageSelector;
+    }
+
+    /**
+     * Gets this MessageConsumer's <CODE>MessageListener</CODE>.
+     *
+     * @return The listener for the MessageConsumer, or null if no listener is set
+     * @throws JMSException if getting the message listener fails due to some internal error.
+     */
+    public MessageListener getMessageListener() throws JMSException
+    {
+        checkNotClosed();
+        return _messageListener;
+    }
+
+    /**
+     * Sets the MessageConsumer's <CODE>MessageListener</CODE>.
+     * <p> The JMS specification says:
+     * <P>Setting the message listener to null is the equivalent of
+     * unsetting the message listener for the message consumer.
+     * <P>The effect of calling <CODE>MessageConsumer.setMessageListener</CODE>
+     * while messages are being consumed by an existing listener
+     * or the consumer is being used to consume messages synchronously
+     * is undefined.
+     *
+     * @param messageListener The listener to which the messages are to be delivered
+     * @throws JMSException If setting the message listener fails due to some internal error.
+     */
+    public void setMessageListener(MessageListener messageListener) throws JMSException
+    {
+         checkNotClosed();
+         // create a message listener wrapper 
+    }
+
+    public Message receive() throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public Message receive(long l) throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public Message receiveNoWait() throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+
+    // not public methods
+    /**
+     * Stop the delivery of messages to this receiver.
+     * <p>For asynchronous receiver, this operation blocks until the message listener
+     * finishes processing the current message,
+     *
+     * @throws JMSException If the consumer cannot be stopped due to some internal error.
+     */
+    void stop() throws JMSException
+    {
+        try
+        {
+            _qpidReceiver.stop();
+        }
+        catch (QpidException e)
+        {
+            throw ExceptionHelper.convertQpidExceptionToJMSException(e);
+        }
+    }
+
+    /**
+     * Start the delivery of messages to this consumer.
+     *
+     * @throws JMSException If the consumer cannot be started due to some internal error.
+     */
+    void start() throws JMSException
+    {
+        try
+        {
+            _qpidReceiver.start();
+        }
+        catch (QpidException e)
+        {
+            throw ExceptionHelper.convertQpidExceptionToJMSException(e);
+        }
+    }
+}

Propchange: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageListenerWrapper.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageListenerWrapper.java?view=auto&rev=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageListenerWrapper.java (added)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageListenerWrapper.java Fri Jul 27 09:10:27 2007
@@ -0,0 +1,115 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.nclient.jms;
+
+import org.apache.qpid.nclient.api.MessageListener;
+import org.apache.qpid.nclient.api.Message;
+import org.apache.qpid.nclient.jms.message.AbstractJMSMessage;
+import org.apache.qpid.nclient.jms.message.QpidMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jms.JMSException;
+
+/**
+ * This is a wrapper for the JMS message listener
+ */
+public class MessageListenerWrapper implements MessageListener
+{
+    /**
+     * Used for debugging.
+     */
+    private static final Logger _logger = LoggerFactory.getLogger(SessionImpl.class);
+
+    /**
+     * This message listener consumer
+     */
+    MessageConsumerImpl _consumer = null;
+
+    /**
+     * The jms listener of this consumer.
+     */
+    javax.jms.MessageListener _jmsMessageLstener = null;
+
+    //---- constructor
+    /**
+     * Create a message listener wrapper for a given consumer
+     *
+     * @param consumer The consumer of this listener
+     */
+    public MessageListenerWrapper(MessageConsumerImpl consumer)
+    {
+        _consumer = consumer;
+    }
+
+    //---- org.apache.qpid.nclient.api.MessageListener API
+    /**
+     * Deliver a message to the listener.
+     *
+     * @param message The message delivered to the listner.
+     */
+    public void onMessage(Message message)
+    {
+        try
+        {
+            // tell the session that a message is in process
+            _consumer.getSession().preProcessMessage((QpidMessage) message);
+            //TODO build the JMS message form a qpid message
+            AbstractJMSMessage jmsMessage = null;
+            // If the session is transacted we need to ack the message first
+            // This is because a message is associated with its tx only when acked
+            if (_consumer.getSession().getTransacted())
+            {
+                _consumer.getSession().acknowledgeMessage(jmsMessage);
+            }
+            // The JMS specs says:
+            /* The result of a listener throwing a RuntimeException depends on the session’s
+            * acknowledgment mode.
+            • --- AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE - the message
+            * will be immediately redelivered. The number of times a JMS provider will
+            * redeliver the same message before giving up is provider-dependent.
+            • --- CLIENT_ACKNOWLEDGE - the next message for the listener is delivered.
+            * --- Transacted Session - the next message for the listener is delivered.
+            *
+            * The number of time we try redelivering the message is 0
+            **/
+            try
+            {
+                _jmsMessageLstener.onMessage(jmsMessage);
+            }
+            catch (RuntimeException re)
+            {
+                // do nothing as this message will not be redelivered
+            }
+            // If the session has been recovered we then need to redelivered this message
+            if (_consumer.getSession().isInRecovery())
+            {
+                message.release();
+            }
+            // Tell the jms Session to ack this message if required
+            else if (!_consumer.getSession().getTransacted())
+            {
+                _consumer.getSession().acknowledgeMessage(jmsMessage);
+            }
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+}

Propchange: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageListenerWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java?view=auto&rev=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java (added)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java Fri Jul 27 09:10:27 2007
@@ -0,0 +1,25 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.nclient.jms;
+
+/**
+ * 
+ */
+public class MessageProducerImpl extends MessageActor
+{
+}

Propchange: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QpidExceptionListenerImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QpidExceptionListenerImpl.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QpidExceptionListenerImpl.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QpidExceptionListenerImpl.java Fri Jul 27 09:10:27 2007
@@ -23,9 +23,7 @@
 import javax.jms.JMSException;
 
 /**
- * Created by Arnaud Simon
- * Date: 25-Jul-2007
- * Time: 12:08:47
+ * An exception listner 
  */
 public class QpidExceptionListenerImpl implements ExceptionListener
 {
@@ -37,7 +35,7 @@
 
     void setJMSExceptionListner(javax.jms.ExceptionListener jmsExceptionListener)
     {
-       _jmsExceptionListener = jmsExceptionListener;
+        _jmsExceptionListener = jmsExceptionListener;
     }
     //----- ExceptionListener API
 
@@ -46,7 +44,7 @@
         // convert this exception in a JMS exception
         JMSException jmsException = ExceptionHelper.convertQpidExceptionToJMSException(exception);
         // propagate to the jms exception listener
-        if( _jmsExceptionListener != null )
+        if (_jmsExceptionListener != null)
         {
             _jmsExceptionListener.onException(jmsException);
         }

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueSessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueSessionImpl.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueSessionImpl.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueSessionImpl.java Fri Jul 27 09:10:27 2007
@@ -20,9 +20,7 @@
 import org.apache.qpid.nclient.jms.SessionImpl;
 
 /**
- * Created by Arnaud Simon
- * Date: 25-Jul-2007
- * Time: 13:38:58
+ * 
  */
 public class QueueSessionImpl extends SessionImpl
 {

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/SessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/SessionImpl.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/SessionImpl.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/SessionImpl.java Fri Jul 27 09:10:27 2007
@@ -17,11 +17,564 @@
  */
 package org.apache.qpid.nclient.jms;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.qpid.nclient.exception.QpidException;
+import org.apache.qpid.nclient.jms.message.*;
+
+import javax.jms.*;
+import javax.jms.IllegalStateException;
+import javax.jms.Session;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Vector;
+
 /**
- * Created by Arnaud Simon
- * Date: 25-Jul-2007
- * Time: 12:35:36
+ * Implementation of the JMS Session interface
  */
-public class  SessionImpl
+public class SessionImpl implements Session
 {
+    /**
+     * this session's logger
+     */
+    private static final Logger _logger = LoggerFactory.getLogger(SessionImpl.class);
+
+    /**
+     * The messageConsumers of this session.
+     */
+    private ArrayList<MessageConsumerImpl> _messageConsumers = new ArrayList<MessageConsumerImpl>();
+
+    /**
+     * The messageProducers of this session.
+     */
+    private ArrayList<MessageProducerImpl> _messageProducers = new ArrayList<MessageProducerImpl>();
+
+    /**
+     * All the not yet acknoledged messages
+     * We use a vector as access to this list has to be synchronised
+     * This is because messages are acked from messagelistner threads
+     */
+    private Vector<QpidMessage> _unacknowledgedMessages = new Vector<QpidMessage>();
+
+    /**
+     * Indicates whether this session is closed.
+     */
+    private boolean _isClosed = false;
+
+    /**
+     * Used to indicate whether or not this is a transactional session.
+     */
+    private boolean _transacted;
+
+    /**
+     * Holds the sessions acknowledgement mode.
+     */
+    private int _acknowledgeMode;
+
+    /**
+     * The underlying QpidSession
+     */
+    private org.apache.qpid.nclient.api.Session _qpidSession;
+
+    /**
+     * Indicates whether this session is recovering
+     */
+    private boolean _inRecovery = false;
+
+    //--- javax.jms.Session API
+
+    /**
+     * Creates a <CODE>BytesMessage</CODE> object used to send a message
+     * containing a stream of uninterpreted bytes.
+     *
+     * @return A BytesMessage.
+     * @throws JMSException If Creating a BytesMessage object fails due to some internal error.
+     */
+    public BytesMessage createBytesMessage() throws JMSException
+    {
+        checkNotClosed();
+        return new JMSBytesMessage();
+    }
+
+    /**
+     * Creates a <CODE>MapMessage</CODE> object used to send a self-defining set
+     * of name-value pairs, where names are Strings and values are primitive values.
+     *
+     * @return A MapMessage.
+     * @throws JMSException If Creating a MapMessage object fails due to some internal error.
+     */
+    public MapMessage createMapMessage() throws JMSException
+    {
+        checkNotClosed();
+        return new JMSMapMessage();
+    }
+
+    /**
+     * Creates a <CODE>Message</CODE> object that holds all the
+     * standard message header information. It can be sent when a message
+     * containing only header information is sufficient.
+     * We simply return a ByteMessage
+     *
+     * @return A Message.
+     * @throws JMSException If Creating a Message object fails due to some internal error.
+     */
+    public Message createMessage() throws JMSException
+    {
+        return createBytesMessage();
+    }
+
+    /**
+     * Creates an <CODE>ObjectMessage</CODE> used to send a message
+     * that contains a serializable Java object.
+     *
+     * @return An ObjectMessage.
+     * @throws JMSException If Creating an ObjectMessage object fails due to some internal error.
+     */
+    public ObjectMessage createObjectMessage() throws JMSException
+    {
+        checkNotClosed();
+        return new JMSObjectMessage();
+    }
+
+    /**
+     * Creates an initialized <CODE>ObjectMessage</CODE> used to send a message that contains
+     * a serializable Java object.
+     *
+     * @param serializable The object to use to initialize this message.
+     * @return An initialised ObjectMessage.
+     * @throws JMSException If Creating an initialised ObjectMessage object fails due to some internal error.
+     */
+    public ObjectMessage createObjectMessage(Serializable serializable) throws JMSException
+    {
+        ObjectMessage msg = createObjectMessage();
+        msg.setObject(serializable);
+        return msg;
+    }
+
+    /**
+     * Creates a <CODE>StreamMessage</CODE>  used to send a
+     * self-defining stream of primitive values in the Java programming
+     * language.
+     *
+     * @return A StreamMessage
+     * @throws JMSException If Creating an StreamMessage object fails due to some internal error.
+     */
+    public StreamMessage createStreamMessage() throws JMSException
+    {
+        checkNotClosed();
+        return new JMSStreamMessage();
+    }
+
+    /**
+     * Creates a <CODE>TextMessage</CODE> object used to send a message containing a String.
+     *
+     * @return A TextMessage object
+     * @throws JMSException If Creating an TextMessage object fails due to some internal error.
+     */
+    public TextMessage createTextMessage() throws JMSException
+    {
+        checkNotClosed();
+        return new JMSTextMessage();
+    }
+
+    /**
+     * Creates an initialized <CODE>TextMessage</CODE>  used to send
+     * a message containing a String.
+     *
+     * @param text The string used to initialize this message.
+     * @return An initialized TextMessage
+     * @throws JMSException If Creating an initialised TextMessage object fails due to some internal error.
+     */
+    public TextMessage createTextMessage(String text) throws JMSException
+    {
+        TextMessage msg = createTextMessage();
+        msg.setText(text);
+        return msg;
+    }
+
+    /**
+     * Indicates whether the session is in transacted mode.
+     *
+     * @return true if the session is in transacted mode
+     * @throws JMSException If geting the transaction mode fails due to some internal error.
+     */
+    public boolean getTransacted() throws JMSException
+    {
+        checkNotClosed();
+        return _transacted;
+    }
+
+    /**
+     * Returns the acknowledgement mode of this session.
+     * <p> The acknowledgement mode is set at the time that the session is created.
+     * If the session is transacted, the acknowledgement mode is ignored.
+     *
+     * @return If the session is not transacted, returns the current acknowledgement mode for the session.
+     *         else returns SESSION_TRANSACTED.
+     * @throws JMSException if geting the acknowledgement mode fails due to some internal error.
+     */
+    public int getAcknowledgeMode() throws JMSException
+    {
+        checkNotClosed();
+        return _acknowledgeMode;
+    }
+
+    /**
+     * Commits all messages done in this transaction.
+     *
+     * @throws JMSException                   If committing the transaction fails due to some internal error.
+     * @throws TransactionRolledBackException If the transaction is rolled back due to some internal error during commit.
+     * @throws javax.jms.IllegalStateException
+     *                                        If the method is not called by a transacted session.
+     */
+    public void commit() throws JMSException
+    {
+        checkNotClosed();
+        //make sure the Session is a transacted one
+        if (!_transacted)
+        {
+            throw new IllegalStateException("Cannot commit non-transacted session", "Session is not transacted");
+        }
+        // commit the underlying Qpid Session
+        try
+        {
+            // Note: this operation makes sure that asynch message processing has returned
+            _qpidSession.commit();
+        }
+        catch (org.apache.qpidity.QpidException e)
+        {
+            throw ExceptionHelper.convertQpidExceptionToJMSException(e);
+        }
+    }
+
+    /**
+     * Rolls back any messages done in this transaction.
+     *
+     * @throws JMSException If rolling back the session fails due to some internal error.
+     * @throws javax.jms.IllegalStateException
+     *                      If the method is not called by a transacted session.
+     */
+    public void rollback() throws JMSException
+    {
+        checkNotClosed();
+        //make sure the Session is a transacted one
+        if (!_transacted)
+        {
+            throw new IllegalStateException("Cannot rollback non-transacted session", "Session is not transacted");
+        }
+        // rollback the underlying Qpid Session
+        try
+        {
+            // Note: this operation makes sure that asynch message processing has returned
+            _qpidSession.rollback();
+        }
+        catch (org.apache.qpidity.QpidException e)
+        {
+            throw ExceptionHelper.convertQpidExceptionToJMSException(e);
+        }
+    }
+
+    /**
+     * Closes this session.
+     * <p> The JMS specification says
+     * <P> This call will block until a <CODE>receive</CODE> call or message
+     * listener in progress has completed. A blocked message consumer
+     * <CODE>receive</CODE> call returns <CODE>null</CODE> when this session is closed.
+     * <P>Closing a transacted session must roll back the transaction in progress.
+     * <P>This method is the only <CODE>Session</CODE> method that can be called concurrently.
+     * <P>Invoking any other <CODE>Session</CODE> method on a closed session
+     * must throw a <CODE>javax.jms.IllegalStateException</CODE>.
+     * <p> Closing a closed session must <I>not</I> throw an exception.
+     *
+     * @throws JMSException If closing the session fails due to some internal error.
+     */
+    public synchronized void close() throws JMSException
+    {
+        if (!_isClosed)
+        {
+            // from now all the session methods will throw a IllegalStateException
+            _isClosed = true;
+            // close all the actors
+            closeAllActors();
+            // close the underlaying QpidSession
+            try
+            {
+                _qpidSession.sessionClose();
+            }
+            catch ( org.apache.qpidity.QpidException e)
+            {
+                throw ExceptionHelper.convertQpidExceptionToJMSException(e);
+            }
+        }
+    }
+
+    /**
+     * Stops message delivery in this session, and restarts message delivery with
+     * the oldest unacknowledged message.
+     * <p>Recovering a session causes it to take the following actions:
+     * <ul>
+     * <li>Stop message delivery.
+     * <li>Mark all messages that might have been delivered but not acknowledged as "redelivered".
+     * <li>Restart the delivery sequence including all unacknowledged messages that had been
+     * previously delivered.
+     * Redelivered messages do not have to be delivered in exactly their original delivery order.
+     * </ul>
+     *
+     * @throws JMSException If the JMS provider fails to stop and restart message delivery due to some internal error.
+     *                      Not that this does not necessarily mean that the recovery has failed, but simply that it is
+     *                      not possible to tell if it has or not.
+     */
+    public void recover() throws JMSException
+    {
+        // Ensure that the session is open.
+        checkNotClosed();
+        // we are recovering
+        _inRecovery = true;
+        // Ensure that the session is not transacted.
+        if (getTransacted())
+        {
+            throw new IllegalStateException("Session is transacted");
+        }
+        // release all unack messages
+        for(QpidMessage message : _unacknowledgedMessages)
+        {
+            // release all those messages
+            //Todo: message.getQpidMEssage.release();
+        }
+    }
+
+    /**
+     * Returns the session's distinguished message listener (optional).
+     * <p>This is an expert facility used only by Application Servers.
+     * <p> This is an optional operation that is not yet supported
+     *
+     * @return The message listener associated with this session.
+     * @throws JMSException If getting the message listener fails due to an internal error.
+     */
+    public MessageListener getMessageListener() throws JMSException
+    {
+        checkNotClosed();
+        throw new java.lang.UnsupportedOperationException();
+    }
+
+    /**
+     * Sets the session's distinguished message listener.
+     * <p>This is an expert facility used only by Application Servers.
+     * <p> This is an optional operation that is not yet supported
+     *
+     * @param messageListener The message listener to associate with this session
+     * @throws JMSException If setting the message listener fails due to an internal error.
+     */
+    public void setMessageListener(MessageListener messageListener) throws JMSException
+    {
+        checkNotClosed();
+        throw new java.lang.UnsupportedOperationException();
+    }
+
+    /**
+     * Optional operation, intended to be used only by Application Servers,
+     * not by ordinary JMS clients.
+     * <p> This is an optional operation that is not yet supported
+     */
+    public void run()
+    {
+        throw new java.lang.UnsupportedOperationException();
+    }
+
+    public MessageProducer createProducer(Destination destination) throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public MessageConsumer createConsumer(Destination destination) throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public MessageConsumer createConsumer(Destination destination, String string) throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public MessageConsumer createConsumer(Destination destination, String string, boolean b) throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public Queue createQueue(String string) throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public Topic createTopic(String string) throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public TopicSubscriber createDurableSubscriber(Topic topic, String string) throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public TopicSubscriber createDurableSubscriber(Topic topic, String string, String string1, boolean b) throws
+                                                                                                          JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public QueueBrowser createBrowser(Queue queue) throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public QueueBrowser createBrowser(Queue queue, String string) throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public TemporaryQueue createTemporaryQueue() throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public TemporaryTopic createTemporaryTopic() throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+   /**
+    * Unsubscribes a durable subscription that has been created by a client.
+    *
+    * <P>This method deletes the state being maintained on behalf of the
+    * subscriber by its provider.
+    *
+    * <P>It is erroneous for a client to delete a durable subscription
+    * while there is an active <CODE>TopicSubscriber</CODE> for the
+    * subscription, or while a consumed message is part of a pending
+    * transaction or has not been acknowledged in the session.
+    *
+    * @param name the name used to identify this subscription
+    *
+    * @exception JMSException if the session fails to unsubscribe to the durable subscription due to some internal error.
+    * @exception InvalidDestinationException if an invalid subscription name
+    *                                        is specified.
+    */
+   public void unsubscribe(String name) throws JMSException
+   {
+      checkNotClosed();
+
+   }
+
+    //----- Protected methods
+    /**
+     * Notify this session that a message is processed
+     * @param message The processed message.
+     */
+    protected void preProcessMessage(QpidMessage message)
+    {
+        _inRecovery = false;
+    }
+
+    /**
+     * Indicate whether this session is recovering .
+     *
+     * @return true if this session is recovering.
+     */
+    protected  boolean isInRecovery()
+    {
+        return _inRecovery;
+    }
+
+    /**
+     * Validate that the Session is not closed.
+     * <p/>
+     * If the Session has been closed, throw a IllegalStateException. This behaviour is
+     * required by the JMS specification.
+     *
+     * @throws IllegalStateException If the session is closed.
+     */
+    protected void checkNotClosed() throws IllegalStateException
+    {
+        if (_isClosed)
+        {
+            if (_logger.isDebugEnabled())
+            {
+                _logger.debug("Session has been closed. Cannot invoke any further operations.");
+            }
+            throw new javax.jms.IllegalStateException("Session has been closed. Cannot invoke any further operations.");
+        }
+    }
+
+    /**
+     * A session keeps the list of unack messages only when the ack mode is
+     * set to client ack mode. Otherwise messages are always ack.
+     * <p> We can use an ack heuristic for  dups ok mode where bunch of messages are ack.
+     * This has to be done.
+     *
+     * @param message The message to be acknowledged.
+     * @throws JMSException If the message cannot be acknowledged due to an internal error.
+     */
+    protected void acknowledgeMessage(QpidMessage message) throws JMSException
+    {
+        if (getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE)
+        {
+            // messages will be acknowldeged by the client application.
+            // store this message for acknowledging it afterward
+            _unacknowledgedMessages.add(message);
+        }
+        else
+        {
+            // acknowledge this message
+            // TODO: message.acknowledgeQpidMessge();
+        }
+        //TODO: Implement DUPS OK heuristic
+    }
+
+    /**
+     * This method is called when a message is acked.
+     * <p/>
+     * <P>Acknowledgment of a message automatically acknowledges all
+     * messages previously received by the session. Clients may
+     * individually acknowledge messages or they may choose to acknowledge
+     * messages in application defined groups (which is done by acknowledging
+     * the last received message in the group).
+     *
+     * @throws JMSException If this method is called on a closed session.
+     */
+    protected void acknowledge() throws JMSException
+    {
+        checkNotClosed();
+        if (getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE)
+        {
+            for (QpidMessage message : _unacknowledgedMessages)
+            {
+                // acknowledge this message
+                // TODO: message.acknowledgeQpidMessge();
+            }
+            //empty the list of unack messages
+            _unacknowledgedMessages.clear();
+        }
+        //else there is no effect
+    }
+
+    //------ Private Methods
+
+    /**
+     * Close the producer and the consumers of this session
+     *
+     * @throws JMSException If one of the MessaeActor cannot be closed due to some internal error.
+     */
+    private void closeAllActors() throws JMSException
+    {
+        for (MessageActor messageActor : _messageProducers)
+        {
+            messageActor.closeMessageActor();
+        }
+        for (MessageActor messageActor : _messageConsumers)
+        {
+            messageActor.closeMessageActor();
+        }
+    }
 }

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSessionImpl.java?view=diff&rev=560296&r1=560295&r2=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSessionImpl.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSessionImpl.java Fri Jul 27 09:10:27 2007
@@ -20,9 +20,7 @@
 import org.apache.qpid.nclient.jms.SessionImpl;
 
 /**
- * Created by Arnaud Simon
- * Date: 25-Jul-2007
- * Time: 13:39:35
+ *
  */
 public class TopicSessionImpl extends SessionImpl
 {

Added: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/AbstractBytesMessage.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/AbstractBytesMessage.java?view=auto&rev=560296
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/AbstractBytesMessage.java (added)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/AbstractBytesMessage.java Fri Jul 27 09:10:27 2007
@@ -0,0 +1,151 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package  org.apache.qpid.nclient.jms.message;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+
+import javax.jms.JMSException;
+import javax.jms.MessageEOFException;
+
+import org.apache.mina.common.ByteBuffer;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.ContentHeaderBody;
+
+/**
+ * @author Apache Software Foundation
+ */
+public abstract class AbstractBytesMessage extends AbstractJMSMessage
+{
+
+    /**
+     * The default initial size of the buffer. The buffer expands automatically.
+     */
+    private static final int DEFAULT_BUFFER_INITIAL_SIZE = 1024;
+
+    AbstractBytesMessage()
+    {
+        this(null);
+    }
+
+    /**
+     * Construct a bytes message with existing data.
+     *
+     * @param data the data that comprises this message. If data is null, you get a 1024 byte buffer that is
+     *             set to auto expand
+     */
+    AbstractBytesMessage(ByteBuffer data)
+    {
+        super(data); // this instanties a content header
+        getContentHeaderProperties().setContentType(getMimeTypeAsShortString());
+
+        if (_data == null)
+        {
+            allocateInitialBuffer();
+        }
+    }
+
+    protected void allocateInitialBuffer()
+    {
+        _data = ByteBuffer.allocate(DEFAULT_BUFFER_INITIAL_SIZE);
+        _data.setAutoExpand(true);
+    }
+
+    AbstractBytesMessage(long messageNbr, ContentHeaderBody contentHeader, AMQShortString exchange,
+        AMQShortString routingKey, ByteBuffer data) throws AMQException
+    {
+        // TODO: this casting is ugly. Need to review whole ContentHeaderBody idea
+        super(messageNbr, (BasicContentHeaderProperties) contentHeader.properties, exchange, routingKey, data);
+        getContentHeaderProperties().setContentType(getMimeTypeAsShortString());
+    }
+
+    public void clearBodyImpl() throws JMSException
+    {
+        allocateInitialBuffer();
+    }
+
+    public String toBodyString() throws JMSException
+    {
+        checkReadable();
+        try
+        {
+            return getText();
+        }
+        catch (IOException e)
+        {
+            JMSException jmse = new JMSException(e.toString());
+            jmse.setLinkedException(e);
+            throw jmse;
+        }
+    }
+
+    /**
+     * We reset the stream before and after reading the data. This means that toString() will always output
+     * the entire message and also that the caller can then immediately start reading as if toString() had
+     * never been called.
+     *
+     * @return
+     * @throws IOException
+     */
+    private String getText() throws IOException
+    {
+        // this will use the default platform encoding
+        if (_data == null)
+        {
+            return null;
+        }
+
+        int pos = _data.position();
+        _data.rewind();
+        // one byte left is for the end of frame marker
+        if (_data.remaining() == 0)
+        {
+            // this is really redundant since pos must be zero
+            _data.position(pos);
+
+            return null;
+        }
+        else
+        {
+            String data = _data.getString(Charset.forName("UTF8").newDecoder());
+            _data.position(pos);
+
+            return data;
+        }
+    }
+
+    /**
+     * Check that there is at least a certain number of bytes available to read
+     *
+     * @param len the number of bytes
+     * @throws javax.jms.MessageEOFException if there are less than len bytes available to read
+     */
+    protected void checkAvailable(int len) throws MessageEOFException
+    {
+        if (_data.remaining() < len)
+        {
+            throw new MessageEOFException("Unable to read " + len + " bytes");
+        }
+    }
+}

Propchange: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/message/AbstractBytesMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native