diff options
| author | Arnaud Simon <arnaudsimon@apache.org> | 2007-07-30 17:20:40 +0000 |
|---|---|---|
| committer | Arnaud Simon <arnaudsimon@apache.org> | 2007-07-30 17:20:40 +0000 |
| commit | b7afcf98372c48a1516428be0d33b2d6f260f949 (patch) | |
| tree | f7f458ecf6daed650bd9915c9e8c89af82ff7130 /java | |
| parent | b4faa19ccd52e2b3180e3d160146b185657b72c2 (diff) | |
| download | qpid-python-b7afcf98372c48a1516428be0d33b2d6f260f949.tar.gz | |
updated implementation
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@561051 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
12 files changed, 813 insertions, 53 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/DestinationImpl.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/DestinationImpl.java new file mode 100644 index 0000000000..f9486b027e --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/DestinationImpl.java @@ -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; + } + +} + diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java index 9ed96b1e22..dbb0b94d18 100644 --- a/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageActor.java @@ -20,7 +20,7 @@ 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 org.apache.qpidity.QpidException; import javax.jms.IllegalStateException; import javax.jms.JMSException; @@ -50,6 +50,11 @@ public abstract class MessageActor */ Resource _qpidResource; + /** + * The JMS destination this actor is set for. + */ + DestinationImpl _destination; + //-- Constructor //TODO define the parameters @@ -59,10 +64,11 @@ public abstract class MessageActor } - 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) diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java index 80fba4843d..5e2032d37d 100644 --- a/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageConsumerImpl.java @@ -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.MessageListener; 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 class MessageConsumerImpl extends MessageActor implements MessageConsumer */ public void setMessageListener(MessageListener messageListener) throws JMSException { - checkNotClosed(); - // create a message listener wrapper + checkNotClosed(); + // create a message listener wrapper } public Message receive() throws JMSException diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java index 4bae376492..43e07a9dfa 100644 --- a/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/MessageProducerImpl.java @@ -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. + } } diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueBrowserImpl.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueBrowserImpl.java new file mode 100644 index 0000000000..8d68e4d44d --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueBrowserImpl.java @@ -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; + } +} diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueImpl.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueImpl.java new file mode 100644 index 0000000000..cf16df280d --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/QueueImpl.java @@ -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(); + } +} diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/SessionImpl.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/SessionImpl.java index 6432016992..df286cf273 100644 --- a/java/client/src/main/java/org/apache/qpid/nclient/jms/SessionImpl.java +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/SessionImpl.java @@ -83,6 +83,10 @@ public class SessionImpl implements Session */ private boolean _inRecovery = false; + /** + * This session connection + */ + private ConnectionImpl _connection; //--- javax.jms.Session API /** @@ -303,7 +307,7 @@ public class SessionImpl implements Session { _qpidSession.sessionClose(); } - catch ( org.apache.qpidity.QpidException e) + catch (org.apache.qpidity.QpidException e) { throw ExceptionHelper.convertQpidExceptionToJMSException(e); } @@ -338,7 +342,7 @@ public class SessionImpl implements Session 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 @@ public class SessionImpl implements Session 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. - * - * <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. + * Create a TemporaryTopic. Its lifetime will be tha of the Connection unless it is deleted earlier. * - * @param name the name used to identify this subscription + * @return A temporary topic. * - * @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 @@ public class SessionImpl implements Session * * @return true if this session is recovering. */ - protected boolean isInRecovery() + protected boolean isInRecovery() { return _inRecovery; } @@ -508,6 +663,19 @@ public class SessionImpl implements Session } /** + * 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"); + } + } + + /** * 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. diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryDestination.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryDestination.java new file mode 100644 index 0000000000..d9e20d8d8c --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryDestination.java @@ -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 diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryQueueImpl.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryQueueImpl.java new file mode 100644 index 0000000000..ef5d9858df --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryQueueImpl.java @@ -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; + } +} diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryTopicImpl.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryTopicImpl.java new file mode 100644 index 0000000000..7daad4480b --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/TemporaryTopicImpl.java @@ -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; + } +} diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicImpl.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicImpl.java new file mode 100644 index 0000000000..43fa34b0fe --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicImpl.java @@ -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(); + } + +} diff --git a/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSubscriberImpl.java b/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSubscriberImpl.java new file mode 100644 index 0000000000..9ab45772a7 --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/nclient/jms/TopicSubscriberImpl.java @@ -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; + } +} |
