Author: arnaudsimon
Date: Mon Jul 30 10:20:40 2007
New Revision: 561051

URL: http://svn.apache.org/viewvc?view=rev&rev=561051
Log:
updated implementation

Added:
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/DestinationImpl.java
   (with props)
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueBrowserImpl.java
   (with props)
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueImpl.java
   (with props)
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryDestination.java
   (with props)
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryQueueImpl.java
   (with props)
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryTopicImpl.java
   (with props)
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicImpl.java
   (with props)
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSubscriberImpl.java
   (with props)
Modified:
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/SessionImpl.java

Added: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/DestinationImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/DestinationImpl.java?view=auto&rev=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/DestinationImpl.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/DestinationImpl.java
 Mon Jul 30 10:20:40 2007
@@ -0,0 +1,76 @@
+/* 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 javax.jms.Destination;
+
+/**
+ * Implementation of the JMS Destination interface
+ */
+public class DestinationImpl implements Destination
+{
+    /**
+     * The destination's name
+     */
+    protected String _name = null;
+
+    //--- Constructor
+    /**
+     * Create a new DestinationImpl with a given name.
+     * @param name The name of this destination 
+     */
+    protected DestinationImpl(String name)
+    {
+        _name = name;
+    }
+
+    //---- Getters and Setters
+    
+    /**
+     * Gets the name of this destination.
+     *
+     * @return The destination name.
+     */
+    public String getName()
+    {
+        return _name;
+    }
+
+    /**
+     * set the destination name
+     * <p> This name is not verified until producing or consuming messages for 
that destination.
+     *
+     * @param name The destination name.
+     */
+    public void setName(String name)
+    {
+        _name = name;
+    }
+
+    /**
+     * Overrides Object.toString();
+     *
+     * @return Stringified destination representation.
+     */
+    public String toString()
+    {
+        return _name;
+    }
+
+}
+

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

Modified: 
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=diff&rev=561051&r1=561050&r2=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java
 Mon Jul 30 10:20:40 2007
@@ -20,7 +20,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.qpid.nclient.api.Resource;
-import org.apache.qpid.nclient.exception.QpidException;
+import org.apache.qpidity.QpidException;
 
 import javax.jms.IllegalStateException;
 import javax.jms.JMSException;
@@ -50,6 +50,11 @@
      */
     Resource _qpidResource;
 
+    /**
+     * The JMS destination this actor is set for.
+     */
+    DestinationImpl _destination;
+
     //-- Constructor
 
     //TODO define the parameters
@@ -59,10 +64,11 @@
         
     }
 
-    protected MessageActor(SessionImpl session)
+    protected MessageActor(SessionImpl session, DestinationImpl destination)
     {
         // TODO create the qpidResource _qpidResource =
         _session = session;
+        _destination = destination;
     }
 
     //--- public methods (part of the jms public API)

Modified: 
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=diff&rev=561051&r1=561050&r2=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java
 Mon Jul 30 10:20:40 2007
@@ -18,7 +18,7 @@
 package org.apache.qpid.nclient.jms;
 
 import org.apache.qpid.nclient.api.MessageReceiver;
-import org.apache.qpid.nclient.exception.QpidException;
+import org.apache.qpidity.QpidException;
 
 import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
@@ -26,25 +26,47 @@
 import javax.jms.Message;
 
 /**
- * Implementation of JMS message consumer 
+ * Implementation of JMS message consumer
  */
 public class MessageConsumerImpl extends MessageActor implements 
MessageConsumer
 {
     /**
      * The underlying qpid receiver
      */
-    MessageReceiver _qpidReceiver;
+    private MessageReceiver _qpidReceiver;
 
     /**
      * This MessageConsumer's messageselector.
      */
-    protected String _messageSelector = null;
+    private String _messageSelector = null;
+
+    /**
+     * NoLocal
+     * If true, and the destination is a topic then inhibits the delivery of 
messages published
+     * by its own connection.  The behavior for NoLocal is not specified if 
the destination is a queue.
+     */
+    protected boolean _noLocal;
+
+    /**
+     * The subscription name
+     */
+    private String _subscriptionName;
 
     /**
      * A MessageListener set up for this consumer.
      */
     private MessageListener _messageListener = null;
 
+    //----- Constructors
+    protected MessageConsumerImpl(SessionImpl session, DestinationImpl 
destination, String messageSelector,
+                                  boolean noLocal, String subscriptionName)
+    {
+        super(session, destination);
+        _messageSelector = messageSelector;
+        _noLocal = noLocal;
+        _subscriptionName = subscriptionName;
+
+    }
     //----- Message consumer API
 
     /**
@@ -89,8 +111,8 @@
      */
     public void setMessageListener(MessageListener messageListener) throws 
JMSException
     {
-         checkNotClosed();
-         // create a message listener wrapper 
+        checkNotClosed();
+        // create a message listener wrapper
     }
 
     public Message receive() throws JMSException

Modified: 
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=diff&rev=561051&r1=561050&r2=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java
 Mon Jul 30 10:20:40 2007
@@ -17,9 +17,96 @@
  */
 package org.apache.qpid.nclient.jms;
 
+import javax.jms.MessageProducer;
+import javax.jms.JMSException;
+import javax.jms.Destination;
+import javax.jms.Message;
+
 /**
  * 
  */
-public class MessageProducerImpl extends MessageActor
+public class MessageProducerImpl extends MessageActor implements 
MessageProducer
 {
+
+    public MessageProducerImpl(SessionImpl session, DestinationImpl 
destination)
+    {
+        super(session, destination);
+    }
+
+    // Interface javax.jms.MessageProducer
+
+    public void setDisableMessageID(boolean b) throws JMSException
+    {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
+
+    public boolean getDisableMessageID() throws JMSException
+    {
+        return false;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public void setDisableMessageTimestamp(boolean b) throws JMSException
+    {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
+
+    public boolean getDisableMessageTimestamp() throws JMSException
+    {
+        return false;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public void setDeliveryMode(int i) throws JMSException
+    {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
+
+    public int getDeliveryMode() throws JMSException
+    {
+        return 0;  //To change body of implemented methods use File | Settings 
| File Templates.
+    }
+
+    public void setPriority(int i) throws JMSException
+    {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
+
+    public int getPriority() throws JMSException
+    {
+        return 0;  //To change body of implemented methods use File | Settings 
| File Templates.
+    }
+
+    public void setTimeToLive(long l) throws JMSException
+    {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
+
+    public long getTimeToLive() throws JMSException
+    {
+        return 0;  //To change body of implemented methods use File | Settings 
| File Templates.
+    }
+
+    public Destination getDestination() throws JMSException
+    {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public void send(Message message) throws JMSException
+    {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
+
+    public void send(Message message, int i, int i1, long l) throws 
JMSException
+    {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
+
+    public void send(Destination destination, Message message) throws 
JMSException
+    {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
+
+    public void send(Destination destination, Message message, int i, int i1, 
long l) throws JMSException
+    {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
 }

Added: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueBrowserImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueBrowserImpl.java?view=auto&rev=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueBrowserImpl.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueBrowserImpl.java
 Mon Jul 30 10:20:40 2007
@@ -0,0 +1,86 @@
+/* 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 javax.jms.QueueBrowser;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import java.util.Enumeration;
+
+/**
+ * Implementation of the JMS QueueBrowser interface
+ */
+public class QueueBrowserImpl extends MessageActor implements QueueBrowser
+{
+    /**
+     * The browsers MessageSelector.
+     */
+    private String _messageSelector = null;
+
+    //--- constructor
+
+    /**
+     * Create a QueueBrowser for a specific queue and a given message selector.
+     *
+     * @param session         The session of this browser.
+     * @param queue           The queue name for this browser
+     * @param messageSelector only messages with properties matching the 
message selector expression are delivered.
+     * @throws JMSException In case of internal problem when creating this 
browser.
+     */
+    protected QueueBrowserImpl(SessionImpl session, Queue queue, String 
messageSelector) throws JMSException
+    {
+        super(session, (DestinationImpl) queue);
+        _messageSelector = messageSelector;
+        //-- TODO: Create the QPid browser
+    }
+
+    //--- javax.jms.QueueBrowser API
+    /**
+     * Get an enumeration for browsing the current queue messages in the order 
they would be received.
+     *
+     * @return An enumeration for browsing the messages
+     * @throws JMSException If  getting the enumeration for this browser fails 
due to some internal error.
+     */
+    public Enumeration getEnumeration() throws JMSException
+    {
+        // TODO
+        return null;
+    }
+
+    /**
+     * Get the queue associated with this queue browser.
+     *
+     * @return The queue associated with this queue browser.
+     * @throws JMSException If getting the queue associated with this browser 
failts due to some internal error.
+     */
+    public Queue getQueue() throws JMSException
+    {
+        return (Queue) _destination;
+    }
+
+    /**
+     * Get this queue browser's message selector expression.
+     *
+     * @return This queue browser's message selector, or null if no message 
selector exists.
+     * @throws JMSException if getting the message selector for this browser 
fails due to some internal error.
+     */
+    public String getMessageSelector() throws JMSException
+    {
+        return _messageSelector;
+    }
+}

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

Added: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueImpl.java?view=auto&rev=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueImpl.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueImpl.java
 Mon Jul 30 10:20:40 2007
@@ -0,0 +1,49 @@
+/* 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 javax.jms.Queue;
+import javax.jms.JMSException;
+
+/**
+ * Implementation of the JMS Queue interface
+ */
+public class QueueImpl extends DestinationImpl implements Queue
+{
+
+    //--- Constructor
+    /**
+     * Create a new QueueImpl with a given name.
+     */
+    public QueueImpl(String name)
+    {
+        super(name);
+    }
+
+    //---- Interface javax.jms.Queue
+
+    /**
+     * Gets the name of this queue.
+     *
+     * @return This queue's name.
+     */
+    public String getQueueName() throws JMSException
+    {
+        return super.getName();
+    }
+}

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

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=561051&r1=561050&r2=561051
==============================================================================
--- 
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
 Mon Jul 30 10:20:40 2007
@@ -83,6 +83,10 @@
      */
     private boolean _inRecovery = false;
 
+    /**
+     * This session connection
+     */
+    private ConnectionImpl _connection;
     //--- javax.jms.Session API
 
     /**
@@ -303,7 +307,7 @@
             {
                 _qpidSession.sessionClose();
             }
-            catch ( org.apache.qpidity.QpidException e)
+            catch (org.apache.qpidity.QpidException e)
             {
                 throw ExceptionHelper.convertQpidExceptionToJMSException(e);
             }
@@ -338,7 +342,7 @@
             throw new IllegalStateException("Session is transacted");
         }
         // release all unack messages
-        for(QpidMessage message : _unacknowledgedMessages)
+        for (QpidMessage message : _unacknowledgedMessages)
         {
             // release all those messages
             //Todo: message.getQpidMEssage.release();
@@ -383,93 +387,244 @@
         throw new java.lang.UnsupportedOperationException();
     }
 
+    /**
+     * Creates a MessageProducer to send messages to the specified destination.
+     *
+     * @param destination the Destination to send messages to, or null if this 
is a producer
+     *                    which does not have a specified destination.
+     * @return A new MessageProducer
+     * @throws JMSException                If the session fails to create a 
MessageProducer
+     *                                     due to some internal error.
+     * @throws InvalidDestinationException If an invalid destination is 
specified.
+     */
     public MessageProducer createProducer(Destination destination) throws 
JMSException
     {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        checkNotClosed();
+        return new MessageProducerImpl(this, (DestinationImpl) destination);
     }
 
+    /**
+     * Creates a MessageConsumer for the specified destination.
+     *
+     * @param destination The <CODE>Destination</CODE> to access
+     * @return A new MessageConsumer for the specified destination.
+     * @throws JMSException                If the session fails to create a 
MessageConsumer due to some internal error.
+     * @throws InvalidDestinationException If an invalid destination is 
specified.
+     */
     public MessageConsumer createConsumer(Destination destination) throws 
JMSException
     {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        return createConsumer(destination, null);
     }
 
-    public MessageConsumer createConsumer(Destination destination, String 
string) throws JMSException
+    /**
+     * Creates a MessageConsumer for the specified destination, using a 
message selector.
+     *
+     * @param destination     The <CODE>Destination</CODE> to access
+     * @param messageSelector Only messages with properties matching the 
message selector expression are delivered.
+     * @return A new MessageConsumer for the specified destination.
+     * @throws JMSException                If the session fails to create a 
MessageConsumer due to some internal error.
+     * @throws InvalidDestinationException If an invalid destination is 
specified.
+     * @throws InvalidSelectorException    If the message selector is invalid.
+     */
+    public MessageConsumer createConsumer(Destination destination, String 
messageSelector) throws JMSException
     {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+
+        return createConsumer(destination, messageSelector, false);
     }
 
-    public MessageConsumer createConsumer(Destination destination, String 
string, boolean b) throws JMSException
+    /**
+     * Creates MessageConsumer for the specified destination, using a message 
selector.
+     * <p> This method can specify whether messages published by its own 
connection should
+     * be delivered to it, if the destination is a topic.
+     * <p/>
+     * <P>In some cases, a connection may both publish and subscribe to a 
topic. The consumer
+     * NoLocal attribute allows a consumer to inhibit the delivery of messages 
published by its
+     * own connection. The default value for this attribute is False.
+     *
+     * @param destination     The <CODE>Destination</CODE> to access
+     * @param messageSelector Only messages with properties matching the 
message selector expression are delivered.
+     * @param noLocal         If true, and the destination is a topic, 
inhibits the delivery of messages published
+     *                        by its own connection.
+     * @return A new MessageConsumer for the specified destination.
+     * @throws JMSException                If the session fails to create a 
MessageConsumer due to some internal error.
+     * @throws InvalidDestinationException If an invalid destination is 
specified.
+     * @throws InvalidSelectorException    If the message selector is invalid.
+     */
+    public MessageConsumer createConsumer(Destination destination, String 
messageSelector, boolean noLocal) throws
+                                                                               
                             JMSException
     {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        checkNotClosed();
+        checkDestination(destination);
+        return new MessageConsumerImpl(this, (DestinationImpl) destination, 
messageSelector, noLocal, null);
     }
 
-    public Queue createQueue(String string) throws JMSException
+    /**
+     * Creates a queue identity by a given name.
+     * <P>This facility is provided for the rare cases where clients need to
+     * dynamically manipulate queue identity. It allows the creation of a
+     * queue identity with a provider-specific name. Clients that depend
+     * on this ability are not portable.
+     * <P>Note that this method is not for creating the physical queue.
+     * The physical creation of queues is an administrative task and is not
+     * to be initiated by the JMS API. The one exception is the
+     * creation of temporary queues, which is accomplished with the
+     * <CODE>createTemporaryQueue</CODE> method.
+     *
+     * @param queueName the name of this <CODE>Queue</CODE>
+     * @return a <CODE>Queue</CODE> with the given name
+     * @throws JMSException If the session fails to create a queue due to some 
internal error.
+     */
+    public Queue createQueue(String queueName) throws JMSException
     {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        checkNotClosed();
+        // todo: check that this destiantion name does exist
+        return new QueueImpl(queueName);
     }
 
-    public Topic createTopic(String string) throws JMSException
+    /**
+     * reates a topic identity given a Topicname.
+     * <P>This facility is provided for the rare cases where clients need to
+     * dynamically manipulate queue identity. It allows the creation of a
+     * queue identity with a provider-specific name. Clients that depend
+     * on this ability are not portable.
+     * <P>Note that this method is not for creating the physical queue.
+     * The physical creation of queues is an administrative task and is not
+     * to be initiated by the JMS API. The one exception is the
+     * creation of temporary queues, which is accomplished with the
+     * <CODE>createTemporaryTopic</CODE> method.
+     *
+     * @param topicName The name of this <CODE>Topic</CODE>
+     * @return a <CODE>Topic</CODE> with the given name
+     * @throws JMSException If the session fails to create a topic due to some 
internal error.
+     */
+    public Topic createTopic(String topicName) throws JMSException
     {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        checkNotClosed();
+        // todo: check that this destiantion name does exist
+        return new TopicImpl(topicName);
     }
 
-    public TopicSubscriber createDurableSubscriber(Topic topic, String string) 
throws JMSException
+    /**
+     * Creates a durable subscriber to the specified topic,
+     *
+     * @param topic The non-temporary <CODE>Topic</CODE> to subscribe to.
+     * @param name  The name used to identify this subscription.
+     * @return A durable subscriber to the specified topic,
+     * @throws JMSException                If creating a subscriber fails due 
to some internal error.
+     * @throws InvalidDestinationException If an invalid topic is specified.
+     * @throws InvalidSelectorException    If the message selector is invalid.
+     */
+    public TopicSubscriber createDurableSubscriber(Topic topic, String name) 
throws JMSException
     {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        // by default, use a null messageselector and set noLocal to falsen
+        return createDurableSubscriber(topic, name, null, false);
     }
 
-    public TopicSubscriber createDurableSubscriber(Topic topic, String string, 
String string1, boolean b) throws
-                                                                               
                           JMSException
+    /**
+     * Creates a durable subscriber to the specified topic, using a message 
selector and specifying whether messages
+     * published by its
+     * own connection should be delivered to it.
+     * <p> A client can change an existing durable subscription by creating a 
durable <CODE>TopicSubscriber</CODE> with
+     * the same name and a new topic and/or message selector. Changing a 
durable subscriber is equivalent to
+     * unsubscribing (deleting) the old one and creating a new one.
+     *
+     * @param topic           The non-temporary <CODE>Topic</CODE> to 
subscribe to.
+     * @param name            The name used to identify this subscription.
+     * @param messageSelector Only messages with properties matching the 
message selector expression are delivered.
+     * @param noLocal         If set, inhibits the delivery of messages 
published by its own connection
+     * @return A durable subscriber to the specified topic,
+     * @throws JMSException                If creating a subscriber fails due 
to some internal error.
+     * @throws InvalidDestinationException If an invalid topic is specified.
+     * @throws InvalidSelectorException    If the message selector is invalid.
+     */
+    public TopicSubscriber createDurableSubscriber(Topic topic, String name, 
String messageSelector,
+                                                   boolean noLocal) throws 
JMSException
     {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        checkNotClosed();
+        checkDestination(topic);
+        return new TopicSubscriberImpl(this, topic, messageSelector, noLocal, 
_connection.getClientID() + ":" + name);
     }
 
+    /**
+     * Create a QueueBrowser to peek at the messages on the specified queue.
+     *
+     * @param queue The <CODE>Queue</CODE> to browse.
+     * @return A QueueBrowser.
+     * @throws JMSException                If creating a browser fails due to 
some internal error.
+     * @throws InvalidDestinationException If an invalid queue is specified.
+     */
     public QueueBrowser createBrowser(Queue queue) throws JMSException
     {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        return createBrowser(queue, null);
     }
 
-    public QueueBrowser createBrowser(Queue queue, String string) throws 
JMSException
+    /**
+     * Create a QueueBrowser to peek at the messages on the specified queue 
using a message selector.
+     *
+     * @param queue           The <CODE>Queue</CODE> to browse.
+     * @param messageSelector Only messages with properties matching the 
message selector expression are delivered.
+     * @return A QueueBrowser.
+     * @throws JMSException                If creating a browser fails due to 
some internal error.
+     * @throws InvalidDestinationException If an invalid queue is specified.
+     * @throws InvalidSelectorException    If the message selector is invalid.
+     */
+    public QueueBrowser createBrowser(Queue queue, String messageSelector) 
throws JMSException
     {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        checkNotClosed();
+        checkDestination(queue);
+        return new QueueBrowserImpl(this, queue, messageSelector);
     }
 
+     /**
+    * Create a TemporaryQueue. Its lifetime will be tha of the Connection 
unless it is deleted earlier.
+    *
+    * @return A temporary queue.
+    *
+    * @exception JMSException If creating the temporary queue fails due to 
some internal error.
+    */
     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.
+        return new TemporaryQueueImpl();
     }
 
    /**
-    * 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.
+    * Create a TemporaryTopic. Its lifetime will be tha of the Connection 
unless it is deleted earlier.
     *
-    * <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.
+    * @return A temporary topic.
     *
-    * @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.
+    * @exception JMSException If creating the temporary topic fails due to 
some internal error.
     */
-   public void unsubscribe(String name) throws JMSException
-   {
-      checkNotClosed();
+    public TemporaryTopic createTemporaryTopic() throws JMSException
+    {
+        return new TemporaryTopicImpl();
+    }
 
-   }
+    /**
+     * Unsubscribes a durable subscription that has been created by a client.
+     * <p/>
+     * <P>This method deletes the state being maintained on behalf of the
+     * subscriber by its provider.
+     * <p/>
+     * <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
+     * @throws JMSException                if the session fails to unsubscribe 
to the durable subscription due to some internal error.
+     * @throws 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)
@@ -482,7 +637,7 @@
      *
      * @return true if this session is recovering.
      */
-    protected  boolean isInRecovery()
+    protected boolean isInRecovery()
     {
         return _inRecovery;
     }
@@ -504,6 +659,19 @@
                 _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.");
+        }
+    }
+
+    /**
+     * Validate that the destination is valid i.e. it is not null
+     *
+     * @throws InvalidDestinationException If the destination not valid.
+     */
+    protected void checkDestination(Destination dest) throws 
InvalidDestinationException
+    {
+        if (dest == null)
+        {
+            throw new javax.jms.InvalidDestinationException("Invalid 
destination specified: " + dest, "Invalid destination");
         }
     }
 

Added: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryDestination.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryDestination.java?view=auto&rev=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryDestination.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryDestination.java
 Mon Jul 30 10:20:40 2007
@@ -0,0 +1,41 @@
+/*
+ * 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 javax.jms.JMSException;
+
+/**
+ * Interface to abstract functionalities of temporary destinations.
+ */
+public interface TemporaryDestination
+{
+    /**
+     * Delete this temporary destination.
+     *
+      * @throws javax.jms.JMSException If the temporary destination cannot be 
deleted due to some internal error.
+     */
+    public void delete() throws JMSException;
+
+     /**
+     * Indicate whether this temporary destination is deleted
+     *  @return  True is this temporary destination is deleted, false 
otherwise 
+     */
+    public boolean isdeleted();
+
+}
\ No newline at end of file

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

Added: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryQueueImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryQueueImpl.java?view=auto&rev=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryQueueImpl.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryQueueImpl.java
 Mon Jul 30 10:20:40 2007
@@ -0,0 +1,53 @@
+/* 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 javax.jms.TemporaryQueue;
+import javax.jms.JMSException;
+
+/**
+ * Implements TemporaryQueue
+ */
+public class TemporaryQueueImpl extends QueueImpl implements TemporaryQueue, 
TemporaryDestination
+{
+    /**
+     * Indicates whether this temporary queue is deleted.
+     */
+    private boolean _isDeleted = false;
+
+    //--- constructor
+
+    public TemporaryQueueImpl()
+    {
+        // temporary destinations do not have names and are not registered in 
the JNDI namespace.
+        super("NAME_NOT_SET");
+    }
+
+    //-- TemporaryDestination Interface
+    public boolean isdeleted()
+    {
+        return _isDeleted;
+    }
+
+    //-- TemporaryTopic Interface
+    public void delete() throws JMSException
+    {
+        // todo delete this temporary queue
+        _isDeleted = true;
+    }
+}

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

Added: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryTopicImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryTopicImpl.java?view=auto&rev=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryTopicImpl.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryTopicImpl.java
 Mon Jul 30 10:20:40 2007
@@ -0,0 +1,53 @@
+/* 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 javax.jms.TemporaryTopic;
+import javax.jms.JMSException;
+
+
+/**
+ * Implements TemporaryTopic
+ */
+public class TemporaryTopicImpl extends TopicImpl implements TemporaryTopic, 
TemporaryDestination
+{
+    /**
+     * Indicates whether this temporary topic is deleted.
+     */
+    private boolean _isDeleted = false;
+
+    //--- constructor
+    public TemporaryTopicImpl()
+    {
+        // temporary destinations do not have names and are not registered in 
the JNDI namespace.
+        super("NAME_NOT_SET");
+    }
+
+    //-- TemporaryDestination Interface
+    public boolean isdeleted()
+    {
+        return _isDeleted;
+    }
+
+    //-- TemporaryTopic Interface
+    public void delete() throws JMSException
+    {
+        // todo: delete this destinaiton
+        _isDeleted = true;
+    }
+}

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

Added: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicImpl.java?view=auto&rev=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicImpl.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicImpl.java
 Mon Jul 30 10:20:40 2007
@@ -0,0 +1,47 @@
+/* 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 javax.jms.Topic;
+
+/**
+ * Implementation of the javax.jms.Topic interface.
+ */
+public class TopicImpl extends DestinationImpl implements Topic
+{
+    //--- Constructor
+    /**
+     * Create a new TopicImpl with a given name.
+     */
+    public TopicImpl(String name)
+    {
+        super(name);
+    }
+
+    //--- javax.jsm.Topic Interface 
+    /**
+     * Gets the name of this topic.
+     *
+     * @return This topic's name.
+     */
+    public String getTopicName()
+    {
+        return super.getName();
+    }
+
+}

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

Added: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSubscriberImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSubscriberImpl.java?view=auto&rev=561051
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSubscriberImpl.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSubscriberImpl.java
 Mon Jul 30 10:20:40 2007
@@ -0,0 +1,72 @@
+/* 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 javax.jms.TopicSubscriber;
+import javax.jms.Topic;
+import javax.jms.JMSException;
+
+/**
+ * Implementation of the JMS TopicSubscriber interface.
+ */
+public class TopicSubscriberImpl extends MessageConsumerImpl implements 
TopicSubscriber
+{
+    //--- Constructor
+    /**
+     * Create a new TopicSubscriberImpl.
+     *
+     * @param session         The session of this topic subscriber.
+     * @param topic           The default topic for this TopicSubscriberImpl
+     * @param messageSelector The MessageSelector
+     * @param noLocal         If true inhibits the delivery of messages 
published by its own connection.
+     * @param name            Name of the subscription if this is to be 
created as a durable subscriber. If this value is null,
+     *                        a non-durable subscription is created.
+     * @throws javax.jms.JMSException If the TopicSubscriberImpl cannot be 
created due to internal error.
+     */
+    protected TopicSubscriberImpl(SessionImpl session, Topic topic, String 
messageSelector, boolean noLocal,
+                                  String name) throws JMSException
+    {
+        super(session, (DestinationImpl) topic, messageSelector, noLocal, 
name);
+    }
+
+    //---  javax.jms.TopicSubscriber interface
+    /**
+     * Get the Topic associated with this subscriber.
+     *
+     * @return This subscriber's Topic
+     * @throws JMSException if getting the topic for this topicSubscriber 
fails due to some internal error.
+     */
+    public Topic getTopic() throws JMSException
+    {
+        checkNotClosed();
+        return (TopicImpl) _destination;
+    }
+
+
+    /**
+     * Get NoLocal for this subscriber.
+     *
+     * @return True if locally published messages are being inhibited, false 
otherwise
+     * @throws JMSException If getting NoLocal for this topic subscriber fails 
due to some internal error.
+     */
+    public boolean getNoLocal() throws JMSException
+    {
+        checkNotClosed();
+        return _noLocal;
+    }
+}

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


Reply via email to