You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ra...@apache.org on 2012/03/05 19:49:44 UTC

svn commit: r1297166 - in /qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging: Address.java address/ address/Link.java address/Node.java

Author: rajith
Date: Mon Mar  5 18:49:43 2012
New Revision: 1297166

URL: http://svn.apache.org/viewvc?rev=1297166&view=rev
Log:
QPID-3401 Added Node and Link data structures to hold information from
address strings after it's being parsed.The Address object now contains
a Node and Link object that contains the same info as in the options but
in a more accessible way.

Added:
    qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/
    qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Link.java
    qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Node.java
Modified:
    qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java

Modified: qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java
URL: http://svn.apache.org/viewvc/qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java?rev=1297166&r1=1297165&r2=1297166&view=diff
==============================================================================
--- qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java (original)
+++ qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java Mon Mar  5 18:49:43 2012
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.messaging;
 
+import org.apache.qpid.messaging.address.Link;
+import org.apache.qpid.messaging.address.Node;
 import org.apache.qpid.messaging.util.AddressParser;
 
 import static org.apache.qpid.messaging.util.PyPrint.pprint;
@@ -40,6 +42,9 @@ public class Address
     private Map _options;
     private final String _myToString;
 
+    private Node node;
+    private Link link;
+
     public static Address parse(String address)
     {
         return new AddressParser(address).parse();
@@ -73,4 +78,23 @@ public class Address
         return _myToString;
     }
 
+    public Node getNode()
+    {
+        return node;
+    }
+
+    public void setNode(Node n)
+    {
+        this.node = n;
+    }
+
+    public Link getLink()
+    {
+        return link;
+    }
+
+    public void setLink(Link l)
+    {
+        this.link = l;
+    }
 }

Added: qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Link.java
URL: http://svn.apache.org/viewvc/qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Link.java?rev=1297166&view=auto
==============================================================================
--- qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Link.java (added)
+++ qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Link.java Mon Mar  5 18:49:43 2012
@@ -0,0 +1,182 @@
+/*
+ *
+ * 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.messaging.address;
+
+import static org.apache.qpid.messaging.address.Link.Reliability.AT_LEAST_ONCE;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class Link
+{
+    public enum FilterType
+    {
+        SQL92, XQUERY, SUBJECT
+    }
+
+    public enum Reliability
+    {
+        UNRELIABLE, AT_MOST_ONCE, AT_LEAST_ONCE, EXACTLY_ONCE;
+
+        public static Reliability getReliability(String reliability)
+                throws AddressException
+        {
+            if (reliability == null)
+            {
+                return AT_LEAST_ONCE;
+            } else if (reliability.equalsIgnoreCase("unreliable"))
+            {
+                return UNRELIABLE;
+            } else if (reliability.equalsIgnoreCase("at-least-once"))
+            {
+                return AT_LEAST_ONCE;
+            } else
+            {
+                throw new AddressException("The reliability mode '"
+                        + reliability + "' is not yet supported");
+            }
+        }
+    }
+
+    protected String name;
+    protected String filter;
+    protected FilterType filterType = FilterType.SUBJECT;
+    protected boolean noLocal;
+    protected boolean durable;
+    protected int consumerCapacity = 0;
+    protected int producerCapacity = 0;
+    protected Reliability reliability = AT_LEAST_ONCE;
+
+    protected Map<String, Object> xDeclareProps = (Map<String, Object>) Collections.EMPTY_MAP;
+    protected Map<String, Object> xBindingProps = (Map<String, Object>) Collections.EMPTY_MAP;
+    protected Map<String, Object> xSubscribeProps = (Map<String, Object>) Collections.EMPTY_MAP;
+
+    public Reliability getReliability()
+    {
+        return reliability;
+    }
+
+    public boolean isDurable()
+    {
+        return durable;
+    }
+
+    public String getFilter()
+    {
+        return filter;
+    }
+
+    public FilterType getFilterType()
+    {
+        return filterType;
+    }
+
+    public boolean isNoLocal()
+    {
+        return noLocal;
+    }
+
+    public int getConsumerCapacity()
+    {
+        return consumerCapacity;
+    }
+
+    public int getProducerCapacity()
+    {
+        return producerCapacity;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public Map<String, Object> getXDeclareProperties()
+    {
+        return xDeclareProps;
+    }
+
+    public Map<String, Object> getXBindingProperties()
+    {
+        return xBindingProps;
+    }
+
+    public Map<String, Object> getXSubscribeProperties()
+    {
+        return xSubscribeProps;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    public void setFilter(String filter)
+    {
+        this.filter = filter;
+    }
+
+    public void setFilterType(FilterType filterType)
+    {
+        this.filterType = filterType;
+    }
+
+    public void setNoLocal(boolean noLocal)
+    {
+        this.noLocal = noLocal;
+    }
+
+    public void setDurable(boolean durable)
+    {
+        this.durable = durable;
+    }
+
+    public void setConsumerCapacity(int consumerCapacity)
+    {
+        this.consumerCapacity = consumerCapacity;
+    }
+
+    public void setProducerCapacity(int producerCapacity)
+    {
+        this.producerCapacity = producerCapacity;
+    }
+
+    public void setReliability(Reliability reliability)
+    {
+        this.reliability = reliability;
+    }
+
+    public void setxDeclareProps(Map<String, Object> xDeclareProps)
+    {
+        this.xDeclareProps = xDeclareProps;
+    }
+
+    public void setxBindingProps(Map<String, Object> xBindingProps)
+    {
+        this.xBindingProps = xBindingProps;
+    }
+
+    public void setxSubscribeProps(Map<String, Object> xSubscribeProps)
+    {
+        this.xSubscribeProps = xSubscribeProps;
+    }
+
+}

Added: qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Node.java
URL: http://svn.apache.org/viewvc/qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Node.java?rev=1297166&view=auto
==============================================================================
--- qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Node.java (added)
+++ qpid/branches/address-refactor2/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Node.java Mon Mar  5 18:49:43 2012
@@ -0,0 +1,176 @@
+/*
+ *
+ * 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.messaging.address;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.qpid.messaging.address.Link.Reliability;
+
+public class Node
+{
+    public enum AddressPolicy
+    {
+        NEVER, SENDER, RECEIVER, ALWAYS;
+
+        public static AddressPolicy getAddressPolicy(String policy)
+                throws AddressException
+        {
+            if (policy == null || policy.equalsIgnoreCase("never"))
+            {
+                return NEVER;
+            }
+            else if (policy.equalsIgnoreCase("always"))
+            {
+                return ALWAYS;
+            }
+            else if (policy.equalsIgnoreCase("sender"))
+            {
+                return SENDER;
+            }
+            else if (policy.equalsIgnoreCase("receiver"))
+            {
+                return RECEIVER;
+            }
+            else
+            {
+                throw new AddressException("Invalid address policy type : '"
+                        + policy + "'");
+            }
+        }
+    };
+
+    public enum NodeType
+    {
+        QUEUE, TOPIC, UNRESOLVED;
+
+        public static NodeType getNodeType(String type) throws AddressException
+        {
+            if (type == null)
+            {
+                return UNRESOLVED;
+            }
+            else if (type.equalsIgnoreCase("queue"))
+            {
+                return QUEUE;
+            }
+            else if (type.equalsIgnoreCase("topic"))
+            {
+                return TOPIC;
+            }else    
+            {
+                throw new AddressException("Invalid node type : '" + type + "'");
+            }
+        }
+    };
+
+    protected String name;
+
+    protected boolean durable = false;
+    protected NodeType type = NodeType.UNRESOLVED;
+
+    protected AddressPolicy createPolicy = AddressPolicy.NEVER;
+    protected AddressPolicy assertPolicy = AddressPolicy.NEVER;
+    protected AddressPolicy deletePolicy = AddressPolicy.NEVER;
+
+    protected Map<String, Object> xDeclareProps = (Map<String, Object>) Collections.EMPTY_MAP;
+    protected Map<String, Object> xBindingProps = (Map<String, Object>) Collections.EMPTY_MAP;
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public boolean isDurable()
+    {
+        return durable;
+    }
+
+    public NodeType getType()
+    {
+        return type;
+    }
+
+    public AddressPolicy getCreatePolicy()
+    {
+        return createPolicy;
+    }
+
+    public AddressPolicy getAssertPolicy()
+    {
+        return assertPolicy;
+    }
+
+    public AddressPolicy getDeletePolicy()
+    {
+        return deletePolicy;
+    }
+
+    public Map<String, Object> getXDeclareProperties()
+    {
+        return xDeclareProps;
+    }
+
+    public Map<String, Object> getXBindingProperties()
+    {
+        return xBindingProps;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    public void setDurable(boolean durable)
+    {
+        this.durable = durable;
+    }
+
+    public void setType(NodeType type)
+    {
+        this.type = type;
+    }
+
+    public void setCreatePolicy(AddressPolicy createPolicy)
+    {
+        this.createPolicy = createPolicy;
+    }
+
+    public void setAssertPolicy(AddressPolicy assertPolicy)
+    {
+        this.assertPolicy = assertPolicy;
+    }
+
+    public void setDeletePolicy(AddressPolicy deletePolicy)
+    {
+        this.deletePolicy = deletePolicy;
+    }
+
+    public void setxDeclareProps(Map<String, Object> xDeclareProps)
+    {
+        this.xDeclareProps = xDeclareProps;
+    }
+
+    public void setxBindingProps(Map<String, Object> xBindingProps)
+    {
+        this.xBindingProps = xBindingProps;
+    }
+}
\ No newline at end of file



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