summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2009-02-09 04:30:17 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2009-02-09 04:30:17 +0000
commita25b1f9a7943127822e311c7dfa537133920b2d9 (patch)
treef30069024a86822e374a02387c33cf673433d309
parente776e1e5749b226bf5bd409d4c0295b8ee3bdffb (diff)
downloadqpid-python-a25b1f9a7943127822e311c7dfa537133920b2d9.tar.gz
This is related to QPID-1654
This contains the first step towards supporting a queue bound to any exchange type. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@742250 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java56
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java20
2 files changed, 65 insertions, 11 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
new file mode 100644
index 0000000000..4bb2c12cc8
--- /dev/null
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.client;
+
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.url.BindingURL;
+
+/**
+ * In order to support JMS 1.0 the Qpid implementation maps the
+ * direct exchange to JMS Queue and topic exchange to JMS Topic.
+ *
+ * The JMS 1.1 spec provides a javax.Destination as an abstraction
+ * to represent any type of destination.
+ * The abstract class AMQDestination has most of the functionality
+ * to support any destination defined in AMQP 0-10 spec.
+ */
+public class AMQAnyDestination extends AMQDestination
+{
+ public AMQAnyDestination(BindingURL binding)
+ {
+ super(binding);
+ }
+
+ public AMQAnyDestination(AMQShortString exchangeName,AMQShortString exchangeClass,
+ AMQShortString routingKey,boolean isExclusive,
+ boolean isAutoDelete, AMQShortString queueName,
+ boolean isDurable, AMQShortString[] bindingKeys)
+ {
+ super(exchangeName, exchangeClass, routingKey, isExclusive, isAutoDelete, queueName, isDurable, bindingKeys);
+ }
+
+ @Override
+ public boolean isNameRequired()
+ {
+ return getAMQQueueName() == null;
+ }
+
+}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
index 750599b350..3f2c1af5c2 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
@@ -122,10 +122,11 @@ public abstract class AMQDestination implements Destination, Referenceable
protected AMQDestination(AMQShortString exchangeName, AMQShortString exchangeClass, AMQShortString routingKey, boolean isExclusive,
boolean isAutoDelete, AMQShortString queueName, boolean isDurable,AMQShortString[] bindingKeys)
{
- // If used with a fannout exchange, the routing key can be null
- if ( !ExchangeDefaults.FANOUT_EXCHANGE_CLASS.equals(exchangeClass) && routingKey == null)
+ if ( (ExchangeDefaults.DIRECT_EXCHANGE_CLASS.equals(exchangeClass) ||
+ ExchangeDefaults.TOPIC_EXCHANGE_CLASS.equals(exchangeClass))
+ && routingKey == null)
{
- throw new IllegalArgumentException("routingKey exchange must not be null");
+ throw new IllegalArgumentException("routing/binding key must not be null");
}
if (exchangeName == null)
{
@@ -472,11 +473,12 @@ public abstract class AMQDestination implements Destination, Referenceable
}
else
{
- throw new IllegalArgumentException("Unknown Exchange Class:" + exchangeClass);
+ return new AMQAnyDestination(exchangeName,exchangeClass,
+ routingKey,isExclusive,
+ isAutoDelete,queueName,
+ isDurable, new AMQShortString[0]);
}
-
-
}
public static Destination createDestination(BindingURL binding)
@@ -495,13 +497,9 @@ public abstract class AMQDestination implements Destination, Referenceable
{
return new AMQHeadersExchange(binding);
}
- else if (type.equals(ExchangeDefaults.FANOUT_EXCHANGE_CLASS))
- {
- return new AMQQueue(binding);
- }
else
{
- throw new IllegalArgumentException("Unknown Exchange Class:" + type + " in binding:" + binding);
+ return new AMQAnyDestination(binding);
}
}
}