You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2014/12/22 18:34:42 UTC

qpid-jms git commit: Consolidate the properties handling to the properties class.

Repository: qpid-jms
Updated Branches:
  refs/heads/master 6f106f644 -> 2f78161bd


Consolidate the properties handling to the properties class. 

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/2f78161b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/2f78161b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/2f78161b

Branch: refs/heads/master
Commit: 2f78161bd1754712d130bbc73d2da1375615fdbd
Parents: 6f106f6
Author: Timothy Bish <ta...@gmail.com>
Authored: Mon Dec 22 12:34:37 2014 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Mon Dec 22 12:34:37 2014 -0500

----------------------------------------------------------------------
 .../qpid/jms/provider/amqp/AmqpConnection.java  | 32 +++------
 .../provider/amqp/AmqpConnectionProperties.java | 73 +++++++++++++++++---
 2 files changed, 73 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/2f78161b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
index 6423365..b03b58e 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
@@ -50,10 +50,7 @@ public class AmqpConnection extends AmqpAbstractResource<JmsConnectionInfo, Conn
     private boolean connected;
     private AmqpSaslAuthenticator authenticator;
     private final AmqpConnectionSession connectionSession;
-    private AmqpConnectionProperties properties;
-
-    private String queuePrefix;
-    private String topicPrefix;
+    private final AmqpConnectionProperties properties;
 
     private boolean objectMessageUsesAmqpTypes = false;
     private boolean anonymousProducerCache = false;
@@ -72,8 +69,8 @@ public class AmqpConnection extends AmqpAbstractResource<JmsConnectionInfo, Conn
 
         this.resource.getConnectionId().setProviderHint(this);
 
-        this.queuePrefix = info.getQueuePrefix();
-        this.topicPrefix = info.getTopicPrefix();
+        // Create connection properties initialized with defaults from the JmsConnectionInfo
+        this.properties = new AmqpConnectionProperties(info);
 
         // Create a Session for this connection that is used for Temporary Destinations
         // and perhaps later on management and advisory monitoring.
@@ -122,20 +119,7 @@ public class AmqpConnection extends AmqpAbstractResource<JmsConnectionInfo, Conn
         if (!connected && isOpen()) {
             connected = true;
 
-            this.properties = new AmqpConnectionProperties(
-                getEndpoint().getRemoteOfferedCapabilities(), getEndpoint().getRemoteProperties());
-
-            String brokerQueuePrefix = properties.getQueuePrefix();
-            if (brokerQueuePrefix != null) {
-                queuePrefix = brokerQueuePrefix;
-                resource.setQueuePrefix(brokerQueuePrefix);
-            }
-
-            String brokerTopicPrefix = properties.getTopicPrefix();
-            if (brokerTopicPrefix != null) {
-                topicPrefix = brokerTopicPrefix;
-                resource.setTopicPrefix(brokerTopicPrefix);
-            }
+            properties.initialize(getEndpoint().getRemoteOfferedCapabilities(), getEndpoint().getRemoteProperties());
 
             connectionSession.open(new AsyncResult() {
 
@@ -237,19 +221,19 @@ public class AmqpConnection extends AmqpAbstractResource<JmsConnectionInfo, Conn
     }
 
     public String getQueuePrefix() {
-        return queuePrefix;
+        return properties.getQueuePrefix();
     }
 
     public void setQueuePrefix(String queuePrefix) {
-        this.queuePrefix = queuePrefix;
+        properties.setQueuePrefix(queuePrefix);
     }
 
     public String getTopicPrefix() {
-        return topicPrefix;
+        return properties.getTopicPrefix();
     }
 
     public void setTopicPrefix(String topicPrefix) {
-        this.topicPrefix = topicPrefix;
+        properties.setTopicPrefix(topicPrefix);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/2f78161b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
index de513f5..ca24f32 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
@@ -20,7 +20,10 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.qpid.jms.meta.JmsConnectionInfo;
 import org.apache.qpid.proton.amqp.Symbol;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Class used to examine the capabilities and connection properties of the
@@ -29,23 +32,36 @@ import org.apache.qpid.proton.amqp.Symbol;
  */
 public class AmqpConnectionProperties {
 
+    private static final Logger LOG = LoggerFactory.getLogger(AmqpConnectionProperties.class);
+
     public static final Symbol ANONYMOUS_RELAY = Symbol.valueOf("ANONYMOUS-RELAY");
     public static final Symbol QUEUE_PREFIX = Symbol.valueOf("queue-prefix");
     public static final Symbol TOPIC_PREFIX = Symbol.valueOf("topic-prefix");
 
+    private final JmsConnectionInfo connectionInfo;
+
     private boolean anonymousRelaySupported = false;
-    private String queuePrefix = null;
-    private String topicPrefix = null;
 
     /**
-     * Creates a new instance of this class from the given remote capabilities and properties.
+     * Creates a new instance of this class with default values read from the
+     * given JmsConnectionInfo object.
+     *
+     * @param connectionInfo
+     *        the JmsConnectionInfo object used to populate defaults.
+     */
+    public AmqpConnectionProperties(JmsConnectionInfo connectionInfo) {
+        this.connectionInfo = connectionInfo;
+    }
+
+    /**
+     * Configure the properties using values provided from the remote peer.
      *
      * @param capabilities
      *        the capabilities offered by the remote connection.
      * @param properties
      *        the properties offered by the remote connection.
      */
-    public AmqpConnectionProperties(Symbol[] capabilities, Map<Symbol, Object> properties) {
+    public void initialize(Symbol[] capabilities, Map<Symbol, Object> properties) {
         if (capabilities != null) {
             processCapabilities(capabilities);
         }
@@ -68,29 +84,70 @@ public class AmqpConnectionProperties {
         if (properties.containsKey(QUEUE_PREFIX)) {
             Object o = properties.get(QUEUE_PREFIX);
             if (o instanceof String) {
-                queuePrefix = (String) o;
+                LOG.trace("Remote sent Queue prefix value of: {}", o);
+                connectionInfo.setQueuePrefix((String) o);
             }
         }
 
         if (properties.containsKey(TOPIC_PREFIX)) {
             Object o = properties.get(TOPIC_PREFIX);
             if (o instanceof String) {
-                topicPrefix = (String) o;
+                LOG.trace("Remote sent Topic prefix value of: {}", o);
+                connectionInfo.setTopicPrefix((String) o);
             }
         }
 
         // TODO - Inspect properties for any other configuration options
     }
 
+    /**
+     * @return true if the connection supports sending to an anonymous relay.
+     */
     public boolean isAnonymousRelaySupported() {
         return anonymousRelaySupported;
     }
 
+    /**
+     * Sets if the connection supports sending to an anonymous relay link.
+     *
+     * @param anonymousRelaySupported
+     *        true if anonymous relay link is supported.
+     */
+    public void setAnonymousRelaySupported(boolean anonymousRelaySupported) {
+        this.anonymousRelaySupported = anonymousRelaySupported;
+    }
+
+    /**
+     * @return the prefix value used to decorate Queue address values.
+     */
     public String getQueuePrefix() {
-        return queuePrefix;
+        return connectionInfo.getQueuePrefix();
+    }
+
+    /**
+     * Sets the prefix value used to decorate Queue address values.
+     *
+     * @param queuePrefix
+     *        the current queue address prefix.
+     */
+    public void setQueuePrefix(String queuePrefix) {
+        connectionInfo.setQueuePrefix(queuePrefix);
     }
 
+    /**
+     * @return the prefix value used to decorate Topic address values.
+     */
     public String getTopicPrefix() {
-        return topicPrefix;
+        return connectionInfo.getTopicPrefix();
+    }
+
+    /**
+     * Sets the prefix value used to decorate Topic address values.
+     *
+     * @param topicPrefix
+     *        the current topic address prefix.
+     */
+    public void setTopicPrefix(String topicPrefix) {
+        connectionInfo.setTopicPrefix(topicPrefix);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org