summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2012-03-05 18:49:43 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2012-03-05 18:49:43 +0000
commited8d1322211f717eb38b6d769caeb964523fea97 (patch)
treebd28daad38fea081496077b7d964e140c7ad5845
parentac24059c9f1987e3dea78bb2c1f3b1c23964e3d1 (diff)
downloadqpid-python-ed8d1322211f717eb38b6d769caeb964523fea97.tar.gz
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. git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/address-refactor2@1297166 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java24
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Link.java182
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Node.java176
3 files changed, 382 insertions, 0 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java
index bccae8e671..887800fc4c 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java
@@ -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;
+ }
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Link.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Link.java
new file mode 100644
index 0000000000..0e01b010bb
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Link.java
@@ -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;
+ }
+
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Node.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Node.java
new file mode 100644
index 0000000000..e410f68445
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Node.java
@@ -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