summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2009-12-14 01:41:28 +0000
committerRobert Gemmell <robbie@apache.org>2009-12-14 01:41:28 +0000
commit9f24c91e95a5016258a86bf0b1a5b88c7cc4657b (patch)
tree68861d9080d6442eb4ce451ed98dcc92a7984c7c /java
parentbb8d501135e1e773ffa202c6fe636e5f4ed0dd98 (diff)
downloadqpid-python-9f24c91e95a5016258a86bf0b1a5b88c7cc4657b.tar.gz
QPID-2268: Use the attribute names for selection instead of their position within the getAttributes return values
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@890153 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java59
1 files changed, 29 insertions, 30 deletions
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java
index 7791b84a4f..1432f18018 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java
@@ -21,8 +21,10 @@
package org.apache.qpid.commands.objects;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.management.Attribute;
@@ -31,6 +33,8 @@ import javax.management.MBeanInfo;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
+import org.apache.qpid.management.common.mbeans.ManagedQueue;
+
public class ObjectNames
{
public String querystring = null;
@@ -38,6 +42,16 @@ public class ObjectNames
public Set<ObjectName> set = null;
public String attributes = "";
public String attributevalues = "";// = null;
+
+ private static final Map<String,Integer> QUEUE_ATTRIBUTES = new HashMap<String,Integer>();
+ static
+ {
+ QUEUE_ATTRIBUTES.put(ManagedQueue.ATTR_NAME, 1);
+ QUEUE_ATTRIBUTES.put(ManagedQueue.ATTR_DURABLE, 2);
+ QUEUE_ATTRIBUTES.put(ManagedQueue.ATTR_ACTIVE_CONSUMER_COUNT, 3);
+ QUEUE_ATTRIBUTES.put(ManagedQueue.ATTR_MSG_COUNT, 4);
+ QUEUE_ATTRIBUTES.put(ManagedQueue.ATTR_RCVD_MSG_COUNT, 5);
+ }
public ObjectNames(MBeanServerConnection mbsc)
{
@@ -318,14 +332,12 @@ public class ObjectNames
Iterator it = set.iterator();
String line = "";
int iterator = 0;
- int attr_count = 0;
String temp1 = "";
String temp2 = "";
try
{
do
{
- attr_count = 0;
ObjectName temp_object = null;
if (it.hasNext())
{
@@ -349,7 +361,13 @@ public class ObjectNames
for (MBeanAttributeInfo attr : attr_info)
{
Object toWrite = null;
- attr_count++;
+ Integer attr_count = QUEUE_ATTRIBUTES.get(attr.getName());
+
+ if(attr_count == null)
+ {
+ continue;
+ }
+
try
{
toWrite = mbsc.getAttribute(temp_object, attr.getName());
@@ -358,7 +376,7 @@ public class ObjectNames
switch (attr_count)
{
case 1:
- case 3:
+ case 2:
temp1 = attr.getName();
while (temp1.length() < 10)
temp1 = " " + temp1;
@@ -368,7 +386,7 @@ public class ObjectNames
temp2 = " " + temp2;
attributevalues = attributevalues + temp2 + "|";
break;
- case 6:
+ case 3:
temp1 = attr.getName();
while (temp1.length() < 20)
temp1 = " " + temp1;
@@ -378,7 +396,7 @@ public class ObjectNames
temp2 = " " + temp2;
attributevalues = attributevalues + temp2 + "|";
break;
- case 7:
+ case 4:
temp1 = attr.getName();
while (temp1.length() < 13)
temp1 = " " + temp1;
@@ -388,7 +406,7 @@ public class ObjectNames
temp2 = " " + temp2;
attributevalues = attributevalues + temp2 + "|";
break;
- case 9:
+ case 5:
temp1 = attr.getName();
while (temp1.length() < 20)
temp1 = " " + temp1;
@@ -402,29 +420,10 @@ public class ObjectNames
}
else if (output.compareToIgnoreCase("csv") == 0)
{
- switch (attr_count)
- {
- case 1:
- case 3:
- case 6:
- temp1 = attr.getName();
- attributes = attributes + temp1 + seperator;
- temp2 = toWrite.toString();
- attributevalues = attributevalues + temp2 + seperator;
- break;
- case 7:
- temp1 = attr.getName();
- attributes = attributes + temp1 + seperator;
- temp2 = toWrite.toString();
- attributevalues = attributevalues + temp2 + seperator;
- break;
- case 9:
- temp1 = attr.getName();
- attributes = attributes + temp1 + seperator;
- temp2 = toWrite.toString();
- attributevalues = attributevalues + temp2 + seperator;
- break;
- }
+ temp1 = attr.getName();
+ attributes = attributes + temp1 + seperator;
+ temp2 = toWrite.toString();
+ attributevalues = attributevalues + temp2 + seperator;
}
else
{