summaryrefslogtreecommitdiff
path: root/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/client/src/main/java/org/apache/qpid/client/AMQDestination.java')
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQDestination.java44
1 files changed, 38 insertions, 6 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java b/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
index 6401e3b23f..c6f3f9c492 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
@@ -7,9 +7,9 @@
* 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
@@ -79,13 +79,19 @@ public abstract class AMQDestination implements Destination, Referenceable
protected AMQDestination(String exchangeName, String exchangeClass, String destinationName, boolean isExclusive,
boolean isAutoDelete, String queueName)
{
+ this(exchangeName, exchangeClass, destinationName, isExclusive, isAutoDelete, queueName, false);
+ }
+
+ protected AMQDestination(String exchangeName, String exchangeClass, String destinationName, boolean isExclusive,
+ boolean isAutoDelete, String queueName, boolean isDurable)
+ {
if (destinationName == null)
{
- throw new IllegalArgumentException("Destination name must not be null");
+ throw new IllegalArgumentException("Destination exchange must not be null");
}
if (exchangeName == null)
{
- throw new IllegalArgumentException("Exchange name must not be null");
+ throw new IllegalArgumentException("Exchange exchange must not be null");
}
if (exchangeClass == null)
{
@@ -97,9 +103,13 @@ public abstract class AMQDestination implements Destination, Referenceable
_isExclusive = isExclusive;
_isAutoDelete = isAutoDelete;
_queueName = queueName;
+ _isDurable = isDurable;
}
- public abstract String getEncodedName();
+ public String getEncodedName()
+ {
+ return toURL();
+ }
public boolean isDurable()
{
@@ -244,7 +254,7 @@ public abstract class AMQDestination implements Destination, Referenceable
return false;
}
if ((_queueName == null && that._queueName != null) ||
- (_queueName != null && !_queueName.equals(that._queueName)))
+ (_queueName != null && !_queueName.equals(that._queueName)))
{
return false;
}
@@ -282,4 +292,26 @@ public abstract class AMQDestination implements Destination, Referenceable
AMQConnectionFactory.class.getName(),
null); // factory location
}
+
+ public static Destination createDestination(BindingURL binding)
+ {
+ String type = binding.getExchangeClass();
+
+ if (type.equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS))
+ {
+ return new AMQQueue(binding);
+ }
+ else if (type.equals(ExchangeDefaults.TOPIC_EXCHANGE_CLASS))
+ {
+ return new AMQTopic(binding);
+ }
+ else if (type.equals(ExchangeDefaults.HEADERS_EXCHANGE_CLASS))
+ {
+ return new AMQHeadersExchange(binding);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown Exchange Class:" + type + " in binding:" + binding);
+ }
+ }
}