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 2010/02/03 18:34:56 UTC
svn commit: r906145 - in
/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging:
./ address/ address/AddressHelper.java address/QpidExchangeOptions.java
address/QpidQueueOptions.java
Author: rajith
Date: Wed Feb 3 17:34:56 2010
New Revision: 906145
URL: http://svn.apache.org/viewvc?rev=906145&view=rev
Log:
This is related to QPID-1831
Contains helper classes for retrieving and holding information from a parsed address string
Added:
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidExchangeOptions.java
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidQueueOptions.java
Added: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java?rev=906145&view=auto
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java (added)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java Wed Feb 3 17:34:56 2010
@@ -0,0 +1,215 @@
+/*
+ *
+ * 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.client.messaging.address;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.qpid.client.AMQDestination.Binding;
+import org.apache.qpid.configuration.Accessor;
+import org.apache.qpid.configuration.Accessor.MapAccessor;
+import org.apache.qpid.messaging.Address;
+
+/**
+ * Utility class for extracting information
+ * from the address class
+ */
+public class AddressHelper
+{
+ public static final String NODE_PROPS = "node-properties";
+ public static final String X_PROPS = "x-properties";
+ public static final String CREATE = "create";
+ public static final String ASSERT = "assert";
+ public static final String DELETE = "delete";
+ public static final String FILTER = "filter";
+ public static final String NO_LOCAL = "no-local";
+ public static final String DURABLE = "durable";
+ public static final String EXCLUSIVE = "exclusive";
+ public static final String AUTO_DELETE = "auto-delete";
+ public static final String TYPE = "type";
+ public static final String ALT_EXCHANGE = "alt-exchange";
+ public static final String BINDINGS = "bindings";
+ public static final String BROWSE_ONLY = "browse";
+
+ private Address address;
+ private Accessor addressProps;
+ private Accessor nodeProps;
+ private Accessor xProps;
+
+ public AddressHelper(Address address)
+ {
+ this.address = address;
+ addressProps = new MapAccessor(address.getOptions());
+ Map node_props = address.getOptions() == null ||
+ address.getOptions().get(NODE_PROPS) == null ?
+ null : (Map)address.getOptions().get(NODE_PROPS);
+ nodeProps = new MapAccessor(node_props);
+ xProps = new MapAccessor(node_props == null || node_props.get(X_PROPS) == null?
+ null: (Map)node_props.get(X_PROPS));
+ }
+
+ public String getCreate()
+ {
+ return addressProps.getString(CREATE);
+ }
+
+ public String getAssert()
+ {
+ return addressProps.getString(ASSERT);
+ }
+
+ public String getDelete()
+ {
+ return addressProps.getString(DELETE);
+ }
+
+ public String getFilter()
+ {
+ return addressProps.getString(FILTER);
+ }
+
+ public boolean isNoLocal()
+ {
+ Boolean b = nodeProps.getBoolean(NO_LOCAL);
+ return b == null ? false : b ;
+ }
+
+ public boolean isDurable()
+ {
+ Boolean b = nodeProps.getBoolean(DURABLE);
+ return b == null ? false : b ;
+ }
+
+ public boolean isExclusive()
+ {
+ Boolean b = xProps.getBoolean(EXCLUSIVE);
+ return b == null ? false : b ;
+ }
+
+ public boolean isAutoDelete()
+ {
+ Boolean b = xProps.getBoolean(AUTO_DELETE);
+ return b == null ? false : b ;
+ }
+
+ public boolean isBrowseOnly()
+ {
+ Boolean b = xProps.getBoolean(BROWSE_ONLY);
+ return b == null ? false : b ;
+ }
+
+ public String getNodeType()
+ {
+ return nodeProps.getString(TYPE);
+ }
+
+ public String getAltExchange()
+ {
+ return xProps.getString(ALT_EXCHANGE);
+ }
+
+ public QpidQueueOptions getQpidQueueOptions()
+ {
+ QpidQueueOptions options = new QpidQueueOptions();
+ if (xProps.getInt(QpidQueueOptions.QPID_MAX_COUNT) != null)
+ {
+ options.setMaxCount(xProps.getInt(QpidQueueOptions.QPID_MAX_COUNT));
+ }
+
+ if (xProps.getInt(QpidQueueOptions.QPID_MAX_SIZE) != null)
+ {
+ options.setMaxSize(xProps.getInt(QpidQueueOptions.QPID_MAX_SIZE));
+ }
+
+ if (xProps.getInt(QpidQueueOptions.QPID_POLICY_TYPE) != null)
+ {
+ options.setPolicyType(xProps.getString(QpidQueueOptions.QPID_POLICY_TYPE));
+ }
+
+ if (xProps.getInt(QpidQueueOptions.QPID_PERSIST_LAST_NODE) != null)
+ {
+ options.setPersistLastNode();
+ }
+
+ if (xProps.getString(QpidQueueOptions.QPID_LAST_VALUE_QUEUE) != null)
+ {
+ options.setOrderingPolicy(xProps.getString(QpidQueueOptions.QPID_LAST_VALUE_QUEUE));
+ options.setLvqKey(xProps.getString(QpidQueueOptions.QPID_LVQ_KEY));
+ }
+ else if (xProps.getString(QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE) != null)
+ {
+ options.setOrderingPolicy(xProps.getString(QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE));
+ options.setLvqKey(xProps.getString(QpidQueueOptions.QPID_LVQ_KEY));
+ }
+
+ if (xProps.getString(QpidQueueOptions.QPID_QUEUE_EVENT_GENERATION) != null)
+ {
+ options.setQueueEvents(xProps.getString(QpidQueueOptions.QPID_QUEUE_EVENT_GENERATION));
+ }
+
+ return options;
+ }
+
+ public QpidExchangeOptions getQpidExchangeOptions()
+ {
+ QpidExchangeOptions options = new QpidExchangeOptions();
+ if (xProps.getInt(QpidExchangeOptions.QPID_EXCLUSIVE_BINDING) != null)
+ {
+ options.setExclusiveBinding();
+ }
+
+ if (xProps.getInt(QpidExchangeOptions.QPID_INITIAL_VALUE_EXCHANGE) != null)
+ {
+ options.setInitialValueExchange();
+ }
+
+ if (xProps.getInt(QpidExchangeOptions.QPID_MSG_SEQUENCE) != null)
+ {
+ options.setMessageSequencing();
+ }
+ return options;
+ }
+
+ public List<Binding> getBindings()
+ {
+ List<Binding> bindings = new ArrayList<Binding>();
+ if (address.getOptions() != null &&
+ address.getOptions().get(NODE_PROPS) != null)
+ {
+ Map node_props = (Map)address.getOptions().get(NODE_PROPS);
+ List<String> bindingList =
+ (List<String>)((Map)node_props.get(X_PROPS)).get(BINDINGS);
+ if (bindingList != null)
+ {
+ for (String bindingStr: bindingList)
+ {
+ Address addr = Address.parse(bindingStr);
+ Binding binding = new Binding(addr.getName(),
+ addr.getSubject(),
+ addr.getOptions());
+ bindings.add(binding);
+ }
+ }
+ }
+ return bindings;
+ }
+}
Added: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidExchangeOptions.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidExchangeOptions.java?rev=906145&view=auto
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidExchangeOptions.java (added)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidExchangeOptions.java Wed Feb 3 17:34:56 2010
@@ -0,0 +1,45 @@
+/*
+ *
+ * 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.client.messaging.address;
+
+import java.util.HashMap;
+
+public class QpidExchangeOptions extends HashMap<String,Object>
+{
+ public static final String QPID_MSG_SEQUENCE = "qpid.msg_sequence";
+ public static final String QPID_INITIAL_VALUE_EXCHANGE = "qpid.ive";
+ public static final String QPID_EXCLUSIVE_BINDING = "qpid.exclusive-binding";
+
+ public void setMessageSequencing()
+ {
+ this.put(QPID_MSG_SEQUENCE, 1);
+ }
+
+ public void setInitialValueExchange()
+ {
+ this.put(QPID_INITIAL_VALUE_EXCHANGE, 1);
+ }
+
+ public void setExclusiveBinding()
+ {
+ this.put(QPID_EXCLUSIVE_BINDING, 1);
+ }
+}
Added: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidQueueOptions.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidQueueOptions.java?rev=906145&view=auto
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidQueueOptions.java (added)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidQueueOptions.java Wed Feb 3 17:34:56 2010
@@ -0,0 +1,106 @@
+/*
+ *
+ * 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.client.messaging.address;
+
+import java.util.HashMap;
+
+public class QpidQueueOptions extends HashMap<String,Object>
+{
+ public static final String QPID_MAX_COUNT = "qpid.max_count";
+ public static final String QPID_MAX_SIZE = "qpid.max_size";
+ public static final String QPID_POLICY_TYPE = "qpid.policy_type";
+ public static final String QPID_PERSIST_LAST_NODE = "qpid.persist_last_node";
+ public static final String QPID_LVQ_KEY = "qpid.LVQ_key";
+ public static final String QPID_LAST_VALUE_QUEUE = "qpid.last_value_queue";
+ public static final String QPID_LAST_VALUE_QUEUE_NO_BROWSE = "qpid.last_value_queue_no_browse";
+ public static final String QPID_QUEUE_EVENT_GENERATION = "qpid.queue_event_generation";
+
+ public void validatePolicyType(String type)
+ {
+ if (type == null ||
+ !("reject".equals(type) || "flow_to_disk".equals(type) ||
+ "ring".equals(type) || "ring_strict".equals(type)))
+ {
+ throw new IllegalArgumentException("Invalid Queue Policy Type" +
+ " should be one of {reject|flow_to_disk|ring|ring_strict}");
+ }
+ }
+
+ public void setPolicyType(String s)
+ {
+ validatePolicyType(s);
+ this.put(QPID_POLICY_TYPE, s);
+ }
+
+ public void setMaxCount(Integer i)
+ {
+ this.put(QPID_MAX_COUNT, i);
+ }
+
+ public void setMaxSize(Integer i)
+ {
+ this.put(QPID_MAX_SIZE, i);
+ }
+
+ public void setPersistLastNode()
+ {
+ this.put(QPID_PERSIST_LAST_NODE, 1);
+ }
+
+ public void setOrderingPolicy(String s)
+ {
+ if ("lvq".equals(s))
+ {
+ this.put(QPID_LAST_VALUE_QUEUE, 1);
+ }
+ else if ("lvq_no_browse".equals(s))
+ {
+ this.put(QPID_LAST_VALUE_QUEUE_NO_BROWSE,1);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid Ordering Policy" +
+ " should be one of {lvq|lvq_no_browse}");
+ }
+ }
+
+ public void setLvqKey(String key)
+ {
+ this.put(QPID_LVQ_KEY, key);
+ }
+
+ public void setQueueEvents(String s)
+ {
+ if (s.equals("enque_only"))
+ {
+ this.put(QPID_QUEUE_EVENT_GENERATION, 1);
+ }
+ else if (s.equals("enque_and_dequeue"))
+ {
+ this.put(QPID_QUEUE_EVENT_GENERATION,2);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid value" +
+ " should be one of {enqueue_only|enqueue_and_dequeue}");
+ }
+ }
+}
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org