summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2010-07-29 02:07:57 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2010-07-29 02:07:57 +0000
commit2751b05dcc2ccedd65d4fe227dc06d9e7cd9e17b (patch)
tree128ec335ddc6c37edb625b33937acf10fb17af77
parent09c4ebc1ca200b2e985b05cd310fc96c9537625f (diff)
downloadqpid-python-2751b05dcc2ccedd65d4fe227dc06d9e7cd9e17b.tar.gz
Removed an import (related to a work-in-progress) that got accidently included in the AddressHelper.java
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@980287 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java221
1 files changed, 115 insertions, 106 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java b/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java
index 2e165954a6..f4e8fa8d2f 100644
--- a/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java
+++ b/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java
@@ -27,7 +27,6 @@ import java.util.Map;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQDestination.Binding;
-import org.apache.qpid.client.messaging.address.Link.Reliability;
import org.apache.qpid.client.messaging.address.Node.ExchangeNode;
import org.apache.qpid.client.messaging.address.Node.QueueNode;
import org.apache.qpid.client.messaging.address.Node.UnknownNodeType;
@@ -36,8 +35,7 @@ import org.apache.qpid.configuration.Accessor.MapAccessor;
import org.apache.qpid.messaging.Address;
/**
- * Utility class for extracting information
- * from the address class
+ * Utility class for extracting information from the address class
*/
public class AddressHelper
{
@@ -68,40 +66,45 @@ public class AddressHelper
public static final String KEY = "key";
public static final String ARGUMENTS = "arguments";
public static final String RELIABILITY = "reliability";
-
+
private Address address;
private Accessor addressProps;
private Accessor nodeProps;
private Accessor linkProps;
-
+
public AddressHelper(Address address)
{
this.address = address;
addressProps = new MapAccessor(address.getOptions());
- Map node_props = address.getOptions() == null ||
- address.getOptions().get(NODE) == null ?
- null : (Map)address.getOptions().get(NODE);
-
- if (node_props != null) { nodeProps = new MapAccessor(node_props); }
-
-
- Map link_props = address.getOptions() == null ||
- address.getOptions().get(LINK) == null ?
- null : (Map)address.getOptions().get(LINK);
-
- if (link_props != null) { linkProps = new MapAccessor(link_props); }
+ Map node_props = address.getOptions() == null
+ || address.getOptions().get(NODE) == null ? null
+ : (Map) address.getOptions().get(NODE);
+
+ if (node_props != null)
+ {
+ nodeProps = new MapAccessor(node_props);
+ }
+
+ Map link_props = address.getOptions() == null
+ || address.getOptions().get(LINK) == null ? null
+ : (Map) address.getOptions().get(LINK);
+
+ if (link_props != null)
+ {
+ linkProps = new MapAccessor(link_props);
+ }
}
-
+
public String getCreate()
{
return addressProps.getString(CREATE);
}
-
+
public String getAssert()
{
return addressProps.getString(ASSERT);
}
-
+
public String getDelete()
{
return addressProps.getString(DELETE);
@@ -110,15 +113,15 @@ public class AddressHelper
public boolean isNoLocal()
{
Boolean b = nodeProps.getBoolean(NO_LOCAL);
- return b == null ? false : b ;
+ return b == null ? false : b;
}
-
+
public boolean isBrowseOnly()
{
String mode = addressProps.getString(MODE);
- return mode != null && mode.equals(BROWSE) ? true : false ;
+ return mode != null && mode.equals(BROWSE) ? true : false;
}
-
+
public QpidQueueOptions getQpidQueueOptions(MapAccessor args)
{
QpidQueueOptions options = new QpidQueueOptions();
@@ -126,39 +129,42 @@ public class AddressHelper
{
options.setMaxCount(args.getInt(QpidQueueOptions.QPID_MAX_COUNT));
}
-
+
if (args.getInt(QpidQueueOptions.QPID_MAX_SIZE) != null)
{
options.setMaxSize(args.getInt(QpidQueueOptions.QPID_MAX_SIZE));
- }
-
+ }
+
if (args.getString(QpidQueueOptions.QPID_POLICY_TYPE) != null)
{
- options.setPolicyType(args.getString(QpidQueueOptions.QPID_POLICY_TYPE));
+ options.setPolicyType(args
+ .getString(QpidQueueOptions.QPID_POLICY_TYPE));
}
-
+
if (args.getInt(QpidQueueOptions.QPID_PERSIST_LAST_NODE) != null)
{
options.setPersistLastNode();
- }
-
+ }
+
if (args.getString(QpidQueueOptions.QPID_LAST_VALUE_QUEUE) != null)
{
options.setOrderingPolicy(QpidQueueOptions.QPID_LAST_VALUE_QUEUE);
- }
- else if (args.getString(QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE) != null)
+ } else if (args
+ .getString(QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE) != null)
{
- options.setOrderingPolicy(QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE);
+ options
+ .setOrderingPolicy(QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE);
}
-
+
if (args.getString(QpidQueueOptions.QPID_QUEUE_EVENT_GENERATION) != null)
{
- options.setQueueEvents(args.getString(QpidQueueOptions.QPID_QUEUE_EVENT_GENERATION));
+ options.setQueueEvents(args
+ .getString(QpidQueueOptions.QPID_QUEUE_EVENT_GENERATION));
}
-
+
return options;
}
-
+
public QpidExchangeOptions getQpidExchangeOptions(MapAccessor args)
{
QpidExchangeOptions options = new QpidExchangeOptions();
@@ -166,177 +172,180 @@ public class AddressHelper
{
options.setExclusiveBinding();
}
-
+
if (args.getInt(QpidExchangeOptions.QPID_INITIAL_VALUE_EXCHANGE) != null)
{
options.setInitialValueExchange();
- }
-
+ }
+
if (args.getInt(QpidExchangeOptions.QPID_MSG_SEQUENCE) != null)
{
options.setMessageSequencing();
}
return options;
}
-
+
@SuppressWarnings("unchecked")
public List<Binding> getBindings(Map props)
{
- List<Binding> bindings = new ArrayList<Binding>();
- List<Map> bindingList = (List<Map>)props.get(X_BINDINGS);
+ List<Binding> bindings = new ArrayList<Binding>();
+ List<Map> bindingList = (List<Map>) props.get(X_BINDINGS);
if (bindingList != null)
{
- for (Map bindingMap: bindingList)
+ for (Map bindingMap : bindingList)
{
- Binding binding = new Binding((String)bindingMap.get(EXCHANGE),
- (String)bindingMap.get(QUEUE),
- (String)bindingMap.get(KEY),
- bindingMap.get(ARGUMENTS) == null ?
- Collections.EMPTY_MAP:
- (Map<String,Object>)bindingMap.get(ARGUMENTS));
+ Binding binding = new Binding(
+ (String) bindingMap.get(EXCHANGE),
+ (String) bindingMap.get(QUEUE),
+ (String) bindingMap.get(KEY),
+ bindingMap.get(ARGUMENTS) == null ? Collections.EMPTY_MAP
+ : (Map<String, Object>) bindingMap
+ .get(ARGUMENTS));
bindings.add(binding);
}
}
return bindings;
}
-
+
public Map getDeclareArgs(Map props)
{
if (props != null)
{
- return (Map)props.get(X_DECLARE);
- }
- else
+ return (Map) props.get(X_DECLARE);
+ } else
{
return Collections.EMPTY_MAP;
}
}
-
+
public int getTargetNodeType() throws Exception
{
if (nodeProps == null || nodeProps.getString(TYPE) == null)
{
// need to query and figure out
- return AMQDestination.UNKNOWN_TYPE;
- }
- else if (nodeProps.getString(TYPE).equals("queue"))
+ return AMQDestination.UNKNOWN_TYPE;
+ } else if (nodeProps.getString(TYPE).equals("queue"))
{
return AMQDestination.QUEUE_TYPE;
- }
- else if (nodeProps.getString(TYPE).equals("topic"))
+ } else if (nodeProps.getString(TYPE).equals("topic"))
{
return AMQDestination.TOPIC_TYPE;
- }
- else
+ } else
{
throw new Exception("unkown exchange type");
}
}
-
+
public Node getTargetNode(int addressType)
{
// target node here is the default exchange
if (nodeProps == null || addressType == AMQDestination.QUEUE_TYPE)
{
return new ExchangeNode();
- }
- else if (addressType == AMQDestination.TOPIC_TYPE)
+ } else if (addressType == AMQDestination.TOPIC_TYPE)
{
- Map node = (Map)address.getOptions().get(NODE);
+ Map node = (Map) address.getOptions().get(NODE);
return createExchangeNode(node);
- }
- else
+ } else
{
// don't know yet
return null;
}
}
-
+
private Node createExchangeNode(Map parent)
{
Map declareArgs = getDeclareArgs(parent);
MapAccessor argsMap = new MapAccessor(declareArgs);
ExchangeNode node = new ExchangeNode();
- node.setExchangeType(argsMap.getString(TYPE) == null?
- null:argsMap.getString(TYPE));
+ node.setExchangeType(argsMap.getString(TYPE) == null ? null : argsMap
+ .getString(TYPE));
node.setDeclareArgs(getQpidExchangeOptions(argsMap));
- fillInCommonNodeArgs(node,parent,argsMap);
+ fillInCommonNodeArgs(node, parent, argsMap);
return node;
}
-
+
private Node createQueueNode(Map parent)
{
Map declareArgs = getDeclareArgs(parent);
MapAccessor argsMap = new MapAccessor(declareArgs);
QueueNode node = new QueueNode();
node.setAlternateExchange(argsMap.getString(ALT_EXCHANGE));
- node.setExclusive(argsMap.getBoolean(EXCLUSIVE) == null? false : argsMap.getBoolean(EXCLUSIVE));
+ node.setExclusive(argsMap.getBoolean(EXCLUSIVE) == null ? false
+ : argsMap.getBoolean(EXCLUSIVE));
node.setDeclareArgs(getQpidQueueOptions(argsMap));
- fillInCommonNodeArgs(node,parent,argsMap);
-
+ fillInCommonNodeArgs(node, parent, argsMap);
+
return node;
}
-
- private void fillInCommonNodeArgs(Node node,Map parent,MapAccessor argsMap)
+
+ private void fillInCommonNodeArgs(Node node, Map parent, MapAccessor argsMap)
{
if (nodeProps != null)
{
- node.setDurable(nodeProps.getBoolean(DURABLE) == null? false : nodeProps.getBoolean(DURABLE));
+ node.setDurable(nodeProps.getBoolean(DURABLE) == null ? false
+ : nodeProps.getBoolean(DURABLE));
}
- node.setAutoDelete(argsMap.getBoolean(AUTO_DELETE) == null? false : argsMap.getBoolean(AUTO_DELETE));
+ node.setAutoDelete(argsMap.getBoolean(AUTO_DELETE) == null ? false
+ : argsMap.getBoolean(AUTO_DELETE));
node.setAlternateExchange(argsMap.getString(ALT_EXCHANGE));
node.setBindings(getBindings(parent));
}
-
+
/**
- * if the type == queue x-declare args from the node props is used.
- * if the type == exchange x-declare args from the link props is used
- * else just create a default temp queue.
+ * if the type == queue x-declare args from the node props is used. if the
+ * type == exchange x-declare args from the link props is used else just
+ * create a default temp queue.
*/
public Node getSourceNode(int addressType)
{
if (addressType == AMQDestination.QUEUE_TYPE && nodeProps != null)
{
- return createQueueNode((Map)address.getOptions().get(NODE));
- }
+ return createQueueNode((Map) address.getOptions().get(NODE));
+ }
if (addressType == AMQDestination.TOPIC_TYPE && linkProps != null)
{
- return createQueueNode((Map)address.getOptions().get(LINK));
- }
- else
+ return createQueueNode((Map) address.getOptions().get(LINK));
+ } else
{
// need to query the info
return new QueueNode();
}
}
-
+
public Link getLink()
{
Link link = new Link();
if (linkProps != null)
- {
- link.setDurable(linkProps.getBoolean(DURABLE)== null? false : linkProps.getBoolean(DURABLE));
+ {
+ link.setDurable(linkProps.getBoolean(DURABLE) == null ? false
+ : linkProps.getBoolean(DURABLE));
link.setName(linkProps.getString(NAME));
-
- if (((Map)address.getOptions().get(LINK)).get(CAPACITY) instanceof Map)
- {
+
+ if (((Map) address.getOptions().get(LINK)).get(CAPACITY) instanceof Map)
+ {
MapAccessor capacityProps = new MapAccessor(
- (Map)((Map)address.getOptions().get(LINK)).get(CAPACITY));
- link.setConsumerCapacity(capacityProps.getInt(CAPACITY_SOURCE) == null ?
- 0 : capacityProps.getInt(CAPACITY_SOURCE));
- link.setProducerCapacity(capacityProps.getInt(CAPACITY_TARGET) == null ?
- 0 : capacityProps.getInt(CAPACITY_TARGET));
- }
- else
+ (Map) ((Map) address.getOptions().get(LINK))
+ .get(CAPACITY));
+ link
+ .setConsumerCapacity(capacityProps
+ .getInt(CAPACITY_SOURCE) == null ? 0
+ : capacityProps.getInt(CAPACITY_SOURCE));
+ link
+ .setProducerCapacity(capacityProps
+ .getInt(CAPACITY_TARGET) == null ? 0
+ : capacityProps.getInt(CAPACITY_TARGET));
+ } else
{
- int cap = linkProps.getInt(CAPACITY) == null ? 0 : linkProps.getInt(CAPACITY);
- link.setConsumerCapacity(cap);
+ int cap = linkProps.getInt(CAPACITY) == null ? 0 : linkProps
+ .getInt(CAPACITY);
+ link.setConsumerCapacity(cap);
link.setProducerCapacity(cap);
}
link.setFilter(linkProps.getString(FILTER));
// so far filter type not used
}
-
+
return link;
}
}