summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/jms/DestinationStringParser.java193
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/jms/QpidDestination.java8
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/jms/QpidQueue.java26
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/jms/QpidTopic.java33
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/messaging/address/AddressPolicy.java40
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/messaging/address/FilterType.java22
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Link.java158
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Node.java151
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/messaging/address/NodeType.java40
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Reliability.java41
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressHelper.java4
11 files changed, 353 insertions, 363 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/DestinationStringParser.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/DestinationStringParser.java
index 9356a13153..fe7b83fcfb 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/DestinationStringParser.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/DestinationStringParser.java
@@ -22,23 +22,22 @@ package org.apache.qpid.jms;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import javax.jms.JMSException;
-
import org.apache.qpid.configuration.ClientProperties;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.jms.QpidDestination.DestinationType;
import org.apache.qpid.messaging.Address;
import org.apache.qpid.messaging.address.AddressException;
+import org.apache.qpid.messaging.address.AddressPolicy;
import org.apache.qpid.messaging.address.Link;
-import org.apache.qpid.messaging.address.Link.Reliability;
+import org.apache.qpid.messaging.address.Reliability;
import org.apache.qpid.messaging.address.Node;
-import org.apache.qpid.messaging.address.Node.AddressPolicy;
-import org.apache.qpid.messaging.address.Node.NodeType;
+import org.apache.qpid.messaging.address.NodeType;
import org.apache.qpid.messaging.util.AddressHelper;
import org.apache.qpid.url.AMQBindingURL;
import org.slf4j.Logger;
@@ -48,83 +47,79 @@ public class DestinationStringParser
{
private static final Logger _logger = LoggerFactory.getLogger(DestinationStringParser.class);
- private static final String BURL_STR = "BURL";
- private static final String ADDR_STR = "ADDR";
-
public enum DestSyntax
{
- BURL,ADDR;
+ BURL
+ {
+ public Address parseAddress(String addressString, DestinationType type) throws AddressException
+ {
+ return DestinationStringParser.parseBURLString(addressString, type);
+ }
+ },
+ ADDR
+ {
+ public Address parseAddress(String addressString, DestinationType type) throws AddressException
+ {
+ return DestinationStringParser.parseAddressString(addressString,type);
+ }
+ };
- public static DestSyntax getSyntaxType(String s)
+ abstract Address parseAddress(String addressString, DestinationType type) throws AddressException;
+
+ public static DestSyntax getDestSyntax(String name)
{
try
{
- return Enum.valueOf(DestSyntax.class, s.toUpperCase());
+ return DestSyntax.valueOf(name);
}
catch (IllegalArgumentException e)
{
- throw new IllegalArgumentException("Invalid Destination Syntax Type" +
- " should be one of {BURL|ADDR}");
+ throw new IllegalArgumentException("Invalid Destination Syntax Type '"
+ + name
+ + "' should be one of " + Arrays.asList(DestSyntax.values()));
}
}
+
}
private static final DestSyntax _defaultDestSyntax;
+
static
{
- _defaultDestSyntax = DestSyntax.getSyntaxType(
- System.getProperty(ClientProperties.DEST_SYNTAX,
- DestSyntax.ADDR.toString()));
+ _defaultDestSyntax =
+ DestSyntax.getDestSyntax(System.getProperty(ClientProperties.DEST_SYNTAX, DestSyntax.ADDR.name()));
+
}
public static DestSyntax getDestType(String str)
{
- if (str.startsWith(ADDR_STR))
+ DestSyntax chosenSyntax = _defaultDestSyntax;
+ for(DestSyntax syntax : DestSyntax.values())
{
- return DestSyntax.ADDR;
- }
- else if (str.startsWith(BURL_STR))
- {
- return DestSyntax.BURL;
+ if(str.startsWith(syntax.name() +":"))
+ {
+ chosenSyntax = syntax;
+ break;
+ }
}
- else
+
+ if (_logger.isDebugEnabled())
{
- return _defaultDestSyntax;
- }
+ _logger.debug("Based on " + str + " the selected destination syntax is " + chosenSyntax);
+ }
+
+ return chosenSyntax;
+
}
- public static String stripSyntaxPrefix(String str)
- {
- if (str.startsWith(BURL_STR) || str.startsWith(ADDR_STR))
- {
- return str.substring(5,str.length());
- }
- else
- {
- return str;
- }
- }
public static Address parseDestinationString(String str, DestinationType type) throws JMSException
{
- DestSyntax destSyntax = getDestType(str);
- str = stripSyntaxPrefix(str);
-
- if (_logger.isDebugEnabled())
- {
- _logger.debug("Based on " + str + " the selected destination syntax is " + destSyntax);
- }
-
try
{
- if (destSyntax == DestSyntax.BURL)
- {
- return DestinationStringParser.parseAddressString(str,type);
- }
- else
- {
- return DestinationStringParser.parseBURLString(str,type);
- }
+
+ return getDestType(str).parseAddress(str, type);
+
}
catch (AddressException e)
{
@@ -138,23 +133,21 @@ public class DestinationStringParser
public static Address parseAddressString(String str, DestinationType type) throws AddressException
{
+ if(str.startsWith(DestSyntax.ADDR.name() + ":"))
+ {
+ str = str.substring(DestSyntax.ADDR.name().length() + 1);
+ }
+
Address addr = Address.parse(str);
AddressHelper helper = new AddressHelper(addr);
- Node node = new Node();
- node.setName(addr.getName());
- node.setAssertPolicy(AddressPolicy.getAddressPolicy(helper.getAssert()));
- node.setCreatePolicy(AddressPolicy.getAddressPolicy(helper.getCreate()));
- node.setDeletePolicy(AddressPolicy.getAddressPolicy(helper.getDelete()));
- node.setDurable(helper.isNodeDurable());
-
+
if (DestinationType.TOPIC == type)
{
if (helper.getNodeType() == NodeType.QUEUE)
{
throw new AddressException("Destination is marked as a Topic, but address is defined as a Queue");
}
- node.setType(NodeType.TOPIC);
}
else
{
@@ -162,25 +155,28 @@ public class DestinationStringParser
{
throw new AddressException("Destination is marked as a Queue, but address is defined as a Topic");
}
- node.setType(NodeType.QUEUE);
}
- node.setDeclareProps(helper.getNodeDeclareArgs());
- node.setBindingProps(helper.getNodeBindings());
+
+ Node node = new Node(addr.getName(), helper.getNodeType(), helper.isNodeDurable(),
+ AddressPolicy.getAddressPolicy(helper.getCreate()),
+ AddressPolicy.getAddressPolicy(helper.getAssert()),
+ AddressPolicy.getAddressPolicy(helper.getDelete()),
+ helper.getNodeDeclareArgs(),
+ helper.getNodeBindings());
+
addr.setNode(node);
- node.markReadOnly();
-
- Link link = new Link();
- link.setName(helper.getLinkName());
- link.setDurable(helper.isLinkDurable());
- link.setReliability(Reliability.getReliability(helper.getLinkReliability()));
- link.setProducerCapacity(helper.getProducerCapacity());
- link.setConsumerCapacity(helper.getConsumeCapacity());
- link.setDeclareProps(helper.getLinkDeclareArgs());
- link.setBindingProps(helper.getLinkBindings());
- link.setSubscribeProps(helper.getLinkSubscribeArgs());
+
+
+ Link link = new Link(helper.getLinkName(),
+ helper.isLinkDurable(),
+ Reliability.getReliability(helper.getLinkReliability()),
+ helper.getProducerCapacity(),
+ helper.getConsumeCapacity(),
+ helper.getLinkDeclareArgs(),
+ helper.getLinkBindings(),
+ helper.getLinkSubscribeArgs());
addr.setLink(link);
- link.markReadOnly();
addr.markReadOnly();
return addr;
@@ -188,6 +184,11 @@ public class DestinationStringParser
public static Address parseBURLString(String str, DestinationType type) throws AddressException
{
+ if(str.startsWith(DestSyntax.BURL.name() + ":"))
+ {
+ str = str.substring(DestSyntax.BURL.name().length() + 1);
+ }
+
AMQBindingURL burl;
try
{
@@ -201,17 +202,19 @@ public class DestinationStringParser
}
Address addr;
- Node node = new Node();
- Link link = new Link();
-
+
+ String linkName;
+
+ List<Object> nodeBindings;
+
if (type == DestinationType.TOPIC)
{
addr = new Address(burl.getExchangeName().asString(),
burl.getRoutingKey().asString(),
Collections.emptyMap());
- link.setName(burl.getQueueName().asString());
- node.setBindingProps(Collections.emptyList());
+ linkName = burl.getQueueName().asString();
+ nodeBindings = Collections.emptyList();
}
else
{
@@ -224,25 +227,39 @@ public class DestinationStringParser
binding.put(AddressHelper.EXCHANGE, burl.getExchangeName().asString());
binding.put(AddressHelper.KEY, burl.getRoutingKey());
bindings.add(binding);
- node.setBindingProps(bindings);
+ nodeBindings = bindings;
+ linkName = null; // ??? This doesn't seem right
}
- List<Object> bindings = node.getBindingProperties();
for (AMQShortString key: burl.getBindingKeys())
{
Map<String,Object> binding = new HashMap<String,Object>();
binding.put(AddressHelper.EXCHANGE, burl.getExchangeName().asString());
binding.put(AddressHelper.KEY, key.asString());
- bindings.add(binding);
+ nodeBindings.add(binding);
}
- node.setAssertPolicy(AddressPolicy.NEVER);
- node.setCreatePolicy(AddressPolicy.RECEIVER);
- node.setDeletePolicy(AddressPolicy.NEVER);
- node.markReadOnly();
+ Node node =
+ new Node(null, // ?? This seems wrong
+ type == DestinationType.TOPIC ? NodeType.TOPIC : NodeType.QUEUE,
+ false, // ?? should this not be determined
+ AddressPolicy.NEVER, // ?? should this not be determined
+ AddressPolicy.NEVER, // ?? should this not be determined
+ AddressPolicy.NEVER, // ?? should this not be determined
+ Collections.EMPTY_MAP, // ?? should this not be determined
+ nodeBindings);
+
addr.setNode(node);
- link.markReadOnly();
+ Link link = new Link(linkName,
+ false, // ?? should this not be determined
+ Reliability.AT_LEAST_ONCE, // ?? should this not be determined
+ 0, // ?? should this not be determined
+ 0, // ?? should this not be determined
+ Collections.EMPTY_MAP, // ?? should this not be determined
+ Collections.EMPTY_LIST, // ?? should this not be determined
+ Collections.EMPTY_MAP); // ?? should this not be determined
+
addr.setLink(link);
addr.markReadOnly();
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidDestination.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidDestination.java
index d05ca34e31..e60088f948 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidDestination.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidDestination.java
@@ -26,11 +26,8 @@ import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.Referenceable;
import javax.naming.StringRefAddr;
-
import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.configuration.ClientProperties;
import org.apache.qpid.messaging.Address;
-import org.apache.qpid.messaging.address.AddressException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,8 +37,8 @@ public abstract class QpidDestination implements Destination, Referenceable
public enum DestinationType {QUEUE, TOPIC};
- protected String _destinationString;
- protected Address _address;
+ private String _destinationString;
+ private Address _address;
protected QpidDestination()
{
@@ -89,4 +86,5 @@ public abstract class QpidDestination implements Destination, Referenceable
{
return _address == null ? "" : _address.toString();
}
+
}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidQueue.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidQueue.java
index 6263c13511..5e50e113e3 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidQueue.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidQueue.java
@@ -23,9 +23,7 @@ package org.apache.qpid.jms;
import javax.jms.JMSException;
import javax.jms.Queue;
-import org.apache.qpid.jms.QpidDestination.DestinationType;
-
-public class QpidQueue extends QpidDestination implements Queue
+public class QpidQueue extends QpidDestination implements Queue
{
public QpidQueue()
{
@@ -43,9 +41,9 @@ public class QpidQueue extends QpidDestination implements Queue
}
@Override
- public String getQueueName() throws JMSException
+ public String getQueueName()
{
- return _address.getName();
+ return getAddress().getName();
}
@Override
@@ -62,21 +60,17 @@ public class QpidQueue extends QpidDestination implements Queue
}
QpidQueue queue = (QpidQueue)obj;
- try
- {
- return getQueueName().equals(queue.getQueueName());
- }
- catch (Exception e)
- {
- return false;
- }
+ return getQueueName().equals(queue.getQueueName());
+
}
@Override
public int hashCode()
{
- int base = 22;
- String queue = _address == null ? "" : _address.getName();
- return base * 25 + queue.hashCode();
+ String queue = getAddress() == null ? "" : getAddress().getName();
+ int result = 17;
+ result = 37*result + queue.hashCode();
+ return result;
+
}
}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidTopic.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidTopic.java
index 90ef29ef86..193e375cc5 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidTopic.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/QpidTopic.java
@@ -41,9 +41,9 @@ public class QpidTopic extends QpidDestination implements Topic
}
@Override
- public String getTopicName() throws JMSException
+ public String getTopicName()
{
- return _address.getSubject() == null ? "" : _address.getSubject();
+ return getAddress().getSubject() == null ? "" : getAddress().getSubject();
}
@Override
@@ -61,20 +61,13 @@ public class QpidTopic extends QpidDestination implements Topic
QpidTopic topic = (QpidTopic)obj;
- try
+ if (!getAddress().getName().equals(topic.getAddress().getName()))
{
- if (!_address.getName().equals(topic.getAddress().getName()))
- {
- return false;
- }
-
- // The subject being the topic name
- if (!_address.getSubject().equals(topic.getAddress().getSubject()))
- {
- return false;
- }
+ return false;
}
- catch (Exception e)
+
+ // The subject being the topic name
+ if (!getAddress().getSubject().equals(topic.getAddress().getSubject()))
{
return false;
}
@@ -85,11 +78,11 @@ public class QpidTopic extends QpidDestination implements Topic
@Override
public int hashCode()
{
- int hash = 55;
- String name = _address == null ? "" : _address.getName();
- String subject = _address == null ? "" : _address.getSubject();
- hash = hash * 25 + name.hashCode();
- hash = hash * 35 + subject.hashCode();
- return hash;
+ String name = getAddress() == null ? "" : getAddress().getName();
+ String subject = getAddress() == null ? "" : getAddress().getSubject();
+ int result = 17;
+ result = 37*result + name.hashCode();
+ result = 37*result + subject.hashCode();
+ return result;
}
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/AddressPolicy.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/AddressPolicy.java
new file mode 100644
index 0000000000..acf6542353
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/AddressPolicy.java
@@ -0,0 +1,40 @@
+package org.apache.qpid.messaging.address;
+
+import java.util.Arrays;
+
+/**
+* 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
+* <p/>
+* http://www.apache.org/licenses/LICENSE-2.0
+* <p/>
+* 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.
+*/
+public enum AddressPolicy
+{
+ NEVER, SENDER, RECEIVER, ALWAYS;
+
+ public static AddressPolicy getAddressPolicy(String policy) throws AddressException
+ {
+ try
+ {
+ return policy == null ? NEVER : AddressPolicy.valueOf(policy.toUpperCase());
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new AddressException ("Invalid address policy '"
+ + policy
+ + "'. Valid policy types are "
+ + Arrays.asList(AddressPolicy.values())
+ + ".");
+ }
+ }
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/FilterType.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/FilterType.java
new file mode 100644
index 0000000000..d524caf95b
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/FilterType.java
@@ -0,0 +1,22 @@
+package org.apache.qpid.messaging.address;
+
+/**
+* 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
+* <p/>
+* http://www.apache.org/licenses/LICENSE-2.0
+* <p/>
+* 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.
+*/
+public enum FilterType
+{
+ SQL92, XQUERY, SUBJECT
+}
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
index 491f2f9bab..4d0fd9725e 100644
--- 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
@@ -20,55 +20,55 @@
*/
package org.apache.qpid.messaging.address;
-import static org.apache.qpid.messaging.address.Link.Reliability.AT_LEAST_ONCE;
-
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
public class Link
{
- public enum FilterType
- {
- SQL92, XQUERY, SUBJECT
- }
- public enum Reliability
- {
- UNRELIABLE, AT_LEAST_ONCE;
-
- public static Reliability getReliability(String str)
- throws AddressException
- {
- try
- {
- return str == null ? AT_LEAST_ONCE : Enum.valueOf(Reliability.class, str.toUpperCase());
- }
- catch (IllegalArgumentException e)
- {
- throw new AddressException((new StringBuffer("The reliability mode")
- .append(" '").append(str).append("' ")
- .append("is not yet supported, supported.")
- .append("Supported types are { UNRELIABLE, AT_LEAST_ONCE }.")).toString());
- }
- }
- }
+ private final String _name;
+ private final boolean _durable;
+ private final int _consumerCapacity;
+ private final int _producerCapacity;
+ private final Reliability _reliability;
- private String name;
- private String _filter;
- private FilterType _filterType = FilterType.SUBJECT;
- private boolean _noLocal;
- private boolean _durable;
- private int _consumerCapacity = 0;
- private int _producerCapacity = 0;
- private Reliability _reliability = AT_LEAST_ONCE;
+ private final Map<String, Object> _xDeclareProps;
+ private final List<Object> _xBindingProps;
+ private final Map<String, Object> _xSubscribeProps;
- private Map<String, Object> _xDeclareProps = Collections.emptyMap();
- private List<Object> _xBindingProps = Collections.emptyList();
- private Map<String, Object> _xSubscribeProps = Collections.emptyMap();
+ // TODO - these should all be made final and added to the constructor
- private AtomicBoolean readOnly = new AtomicBoolean(false);
+ private boolean _noLocal;
+ private String _filter;
+ private FilterType _filterType;
+
+ public Link(String name,
+ boolean durable,
+ Reliability reliability,
+ int producerCapacity,
+ int consumerCapacity,
+ Map<String, Object> xDeclareProps,
+ List<Object> xBindingProps,
+ Map<String, Object> xSubscribeProps)
+ {
+ _name = name;
+ _durable = durable;
+ _reliability = reliability;
+ _producerCapacity = producerCapacity;
+ _consumerCapacity = consumerCapacity;
+ _xDeclareProps = xDeclareProps == null
+ ? Collections.EMPTY_MAP
+ : Collections.unmodifiableMap(new HashMap<String, Object>(xDeclareProps));
+ _xBindingProps = xBindingProps == null
+ ? Collections.EMPTY_LIST
+ : Collections.unmodifiableList(new ArrayList<Object>(xBindingProps));
+ _xSubscribeProps = xSubscribeProps == null
+ ? Collections.EMPTY_MAP
+ : Collections.unmodifiableMap(new HashMap<String, Object>(xSubscribeProps));
+ }
public Reliability getReliability()
{
@@ -107,7 +107,7 @@ public class Link
public String getName()
{
- return name;
+ return _name;
}
public Map<String, Object> getDeclareProperties()
@@ -125,82 +125,4 @@ public class Link
return Collections.unmodifiableMap(_xSubscribeProps);
}
- public void setName(String name)
- {
- checkReadOnly();
- this.name = name;
- }
-
- public void setFilter(String filter)
- {
- checkReadOnly();
- this._filter = filter;
- }
-
- public void setFilterType(FilterType filterType)
- {
- checkReadOnly();
- this._filterType = filterType;
- }
-
- public void setNoLocal(boolean noLocal)
- {
- checkReadOnly();
- this._noLocal = noLocal;
- }
-
- public void setDurable(boolean durable)
- {
- checkReadOnly();
- this._durable = durable;
- }
-
- public void setConsumerCapacity(int consumerCapacity)
- {
- checkReadOnly();
- this._consumerCapacity = consumerCapacity;
- }
-
- public void setProducerCapacity(int producerCapacity)
- {
- checkReadOnly();
- this._producerCapacity = producerCapacity;
- }
-
- public void setReliability(Reliability reliability)
- {
- checkReadOnly();
- this._reliability = reliability;
- }
-
- public void setDeclareProps(Map<String, Object> xDeclareProps)
- {
- checkReadOnly();
- this._xDeclareProps = xDeclareProps;
- }
-
- public void setBindingProps(List<Object> xBindingProps)
- {
- checkReadOnly();
- this._xBindingProps = xBindingProps;
- }
-
- public void setSubscribeProps(Map<String, Object> xSubscribeProps)
- {
- checkReadOnly();
- this._xSubscribeProps = xSubscribeProps;
- }
-
- public void checkReadOnly()
- {
- if (readOnly.get())
- {
- throw new IllegalArgumentException("Once initialized the Link object is immutable");
- }
- }
-
- public void markReadOnly()
- {
- readOnly.set(true);
- }
}
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
index a909fee675..f35a2e873b 100644
--- 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
@@ -20,68 +20,53 @@
*/
package org.apache.qpid.messaging.address;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
public class Node
{
- public enum AddressPolicy
- {
- NEVER, SENDER, RECEIVER, ALWAYS;
-
- public static AddressPolicy getAddressPolicy(String policy)
- throws AddressException
- {
- try
- {
- return policy == null ? NEVER : Enum.valueOf(AddressPolicy.class, policy.toUpperCase());
- }
- catch (IllegalArgumentException e)
- {
- throw new AddressException ((new StringBuffer("Invalid address policy")
- .append(" '").append(policy).append("' ")
- .append("Valid policy types are { NEVER, ALWAYS, SENDER, RECEIVER}.")).toString());
- }
- }
- };
-
- public enum NodeType
- {
- QUEUE, TOPIC;
-
- public static NodeType getNodeType(String type) throws AddressException
- {
- try
- {
- return type == null ? QUEUE : Enum.valueOf(NodeType.class, type.toUpperCase());
- }
- catch (IllegalArgumentException e)
- {
- throw new AddressException ((new StringBuffer("Invalid node type")
- .append(" '").append(type).append("' ")
- .append("Valid node types are { QUEUE, TOPIC }.")).toString());
- }
- }
- };
-
- private String name;
-
- private boolean _durable = false;
- private NodeType _type = NodeType.QUEUE;
-
- private AddressPolicy _createPolicy = AddressPolicy.NEVER;
- private AddressPolicy _assertPolicy = AddressPolicy.NEVER;
- private AddressPolicy _deletePolicy = AddressPolicy.NEVER;
-
- private Map<String, Object> _xDeclareProps = Collections.emptyMap();
- private List<Object> _xBindingProps = Collections.emptyList();
- private AtomicBoolean readOnly = new AtomicBoolean(false);
+
+ private final String _name;
+
+ private final boolean _durable;
+ private final NodeType _type;
+
+ private final AddressPolicy _createPolicy;
+ private final AddressPolicy _assertPolicy;
+ private final AddressPolicy _deletePolicy;
+
+ private final Map<String, Object> _xDeclareProps;
+ private final List<Object> _xBindingProps;
+
+ public Node(String name,
+ NodeType type,
+ boolean durable,
+ AddressPolicy createPolicy,
+ AddressPolicy assertPolicy,
+ AddressPolicy deletePolicy,
+ Map<String, Object> xDeclareProps,
+ List<Object> xBindingProps)
+ {
+ _name = name;
+ _durable = durable;
+ _type = type == null ? NodeType.QUEUE : type;
+ _createPolicy = createPolicy == null ? AddressPolicy.NEVER : createPolicy;
+ _assertPolicy = assertPolicy == null ? AddressPolicy.NEVER : assertPolicy;
+ _deletePolicy = deletePolicy == null ? AddressPolicy.NEVER : deletePolicy;
+ _xDeclareProps = xDeclareProps == null
+ ? Collections.EMPTY_MAP
+ : Collections.unmodifiableMap(new HashMap<String, Object>(xDeclareProps));
+ _xBindingProps = xBindingProps == null
+ ? Collections.emptyList()
+ : Collections.unmodifiableList(new ArrayList<Object>(xBindingProps));
+ }
public String getName()
{
- return name;
+ return _name;
}
public boolean isDurable()
@@ -119,64 +104,4 @@ public class Node
return Collections.unmodifiableList(_xBindingProps);
}
- public void setName(String name)
- {
- checkReadOnly();
- this.name = name;
- }
-
- public void setDurable(boolean durable)
- {
- checkReadOnly();
- this._durable = durable;
- }
-
- public void setType(NodeType type)
- {
- checkReadOnly();
- this._type = type;
- }
-
- public void setCreatePolicy(AddressPolicy createPolicy)
- {
- checkReadOnly();
- this._createPolicy = createPolicy;
- }
-
- public void setAssertPolicy(AddressPolicy assertPolicy)
- {
- checkReadOnly();
- this._assertPolicy = assertPolicy;
- }
-
- public void setDeletePolicy(AddressPolicy deletePolicy)
- {
- checkReadOnly();
- this._deletePolicy = deletePolicy;
- }
-
- public void setDeclareProps(Map<String, Object> xDeclareProps)
- {
- checkReadOnly();
- this._xDeclareProps = xDeclareProps;
- }
-
- public void setBindingProps(List<Object> xBindingProps)
- {
- checkReadOnly();
- this._xBindingProps = xBindingProps;
- }
-
- public void checkReadOnly()
- {
- if (readOnly.get())
- {
- throw new IllegalArgumentException("Once initialized the Link object is immutable");
- }
- }
-
- public void markReadOnly()
- {
- readOnly.set(true);
- }
} \ No newline at end of file
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/NodeType.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/NodeType.java
new file mode 100644
index 0000000000..72710a9e21
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/NodeType.java
@@ -0,0 +1,40 @@
+package org.apache.qpid.messaging.address;
+
+import java.util.Arrays;
+
+/**
+* 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
+* <p/>
+* http://www.apache.org/licenses/LICENSE-2.0
+* <p/>
+* 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.
+*/
+public enum NodeType
+{
+ QUEUE, TOPIC;
+
+ public static NodeType getNodeType(String type) throws AddressException
+ {
+ try
+ {
+ return type == null ? QUEUE : NodeType.valueOf(type.toUpperCase());
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new AddressException ("Invalid node type '"
+ + type
+ + "'. Valid node types are "
+ + Arrays.asList(NodeType.values())
+ + ".");
+ }
+ }
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Reliability.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Reliability.java
new file mode 100644
index 0000000000..3570342557
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/address/Reliability.java
@@ -0,0 +1,41 @@
+package org.apache.qpid.messaging.address;
+
+import java.util.Arrays;
+
+/**
+* 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
+* <p/>
+* http://www.apache.org/licenses/LICENSE-2.0
+* <p/>
+* 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.
+*/
+public enum Reliability
+{
+ UNRELIABLE, AT_LEAST_ONCE;
+
+ public static Reliability getReliability(String str)
+ throws AddressException
+ {
+ try
+ {
+ return str == null ? AT_LEAST_ONCE : Reliability.valueOf(str.toUpperCase());
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new AddressException("The reliability mode '"
+ + str
+ + "' is not supported. Supported types are "
+ + Arrays.asList(Reliability.values())
+ + ".");
+ }
+ }
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressHelper.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressHelper.java
index 736b4f7376..29c0af6a6c 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressHelper.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressHelper.java
@@ -24,11 +24,9 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.apache.qpid.configuration.Accessor;
-import org.apache.qpid.configuration.Accessor.MapAccessor;
import org.apache.qpid.configuration.Accessor.NestedMapAccessor;
import org.apache.qpid.messaging.Address;
-import org.apache.qpid.messaging.address.Node.NodeType;
+import org.apache.qpid.messaging.address.NodeType;
import org.apache.qpid.messaging.address.AddressException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;