diff options
Diffstat (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java')
-rw-r--r-- | qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java | 75 |
1 files changed, 28 insertions, 47 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java index 780dbcafc2..6217cb534a 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java @@ -22,7 +22,6 @@ package org.apache.qpid.client; import java.net.URISyntaxException; -import javax.jms.InvalidDestinationException; import javax.jms.JMSException; import javax.jms.Topic; @@ -96,47 +95,39 @@ public class AMQTopic extends AMQDestination implements Topic super(exchangeName, exchangeClass, routingKey, isExclusive, isAutoDelete, queueName, isDurable,bindingKeys); } - public static AMQTopic createDurableTopic(Topic topic, String subscriptionName, AMQConnection connection) + public static AMQTopic createDurableTopic(AMQTopic topic, String subscriptionName, AMQConnection connection) throws JMSException { - if (topic instanceof AMQDestination && topic instanceof javax.jms.Topic) + if (topic.getDestSyntax() == DestSyntax.ADDR) { - AMQDestination qpidTopic = (AMQDestination)topic; - if (qpidTopic.getDestSyntax() == DestSyntax.ADDR) + try { - try - { - AMQTopic t = new AMQTopic(qpidTopic.getAddress()); - AMQShortString queueName = getDurableTopicQueueName(subscriptionName, connection); - // link is never null if dest was created using an address string. - t.getLink().setName(queueName.asString()); - t.getSourceNode().setAutoDelete(false); - t.getSourceNode().setDurable(true); - - // The legacy fields are also populated just in case. - t.setQueueName(queueName); - t.setAutoDelete(false); - t.setDurable(true); - return t; - } - catch(Exception e) - { - JMSException ex = new JMSException("Error creating durable topic"); - ex.initCause(e); - ex.setLinkedException(e); - throw ex; - } + AMQTopic t = new AMQTopic(topic.getAddress()); + AMQShortString queueName = getDurableTopicQueueName(subscriptionName, connection); + // link is never null if dest was created using an address string. + t.getLink().setName(queueName.asString()); + t.getSourceNode().setAutoDelete(false); + t.getSourceNode().setDurable(true); + + // The legacy fields are also populated just in case. + t.setQueueName(queueName); + t.setAutoDelete(false); + t.setDurable(true); + return t; } - else + catch(Exception e) { - return new AMQTopic(qpidTopic.getExchangeName(), qpidTopic.getRoutingKey(), false, - getDurableTopicQueueName(subscriptionName, connection), - true); + JMSException ex = new JMSException("Error creating durable topic"); + ex.initCause(e); + ex.setLinkedException(e); + throw ex; } } else { - throw new InvalidDestinationException("The destination object used is not from this provider or of type javax.jms.Topic"); + return new AMQTopic(topic.getExchangeName(), topic.getRoutingKey(), false, + getDurableTopicQueueName(subscriptionName, connection), + true); } } @@ -147,17 +138,13 @@ public class AMQTopic extends AMQDestination implements Topic public String getTopicName() throws JMSException { - if (getRoutingKey() != null) + if (super.getRoutingKey() == null && super.getSubject() != null) { - return getRoutingKey().asString(); - } - else if (getSubject() != null) - { - return getSubject(); + return super.getSubject(); } else { - return null; + return super.getRoutingKey().toString(); } } @@ -176,18 +163,12 @@ public class AMQTopic extends AMQDestination implements Topic public AMQShortString getRoutingKey() { - if (super.getRoutingKey() != null) - { - return super.getRoutingKey(); - } - else if (getSubject() != null) + if (super.getRoutingKey() == null && super.getSubject() != null) { - return new AMQShortString(getSubject()); + return new AMQShortString(super.getSubject()); } else { - setRoutingKey(new AMQShortString("")); - setSubject(""); return super.getRoutingKey(); } } |