From bb8d501135e1e773ffa202c6fe636e5f4ed0dd98 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Mon, 14 Dec 2009 01:40:54 +0000 Subject: QPID-1878: use getAttribute method directly with the attribute name to retrieve the current message count git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@890152 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/commands/objects/QueueObject.java | 33 ++++------------------ 1 file changed, 6 insertions(+), 27 deletions(-) (limited to 'java') diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java index 7c82682c27..fcf0464ced 100644 --- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java +++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java @@ -22,10 +22,10 @@ package org.apache.qpid.commands.objects; import javax.management.MBeanServerConnection; -import javax.management.MBeanAttributeInfo; -import javax.management.MBeanInfo; import javax.management.ObjectName; +import org.apache.qpid.management.common.mbeans.ManagedQueue; + public class QueueObject extends ObjectNames { public QueueObject(MBeanServerConnection mbsc) @@ -47,33 +47,12 @@ public class QueueObject extends ObjectNames public int getmessagecount(ObjectName queue) { - int attr_count = 0; - String value; - Integer depth = null; - + Number depth = null; + try { - MBeanInfo bean_info; - bean_info = mbsc.getMBeanInfo(queue); - MBeanAttributeInfo[] attr_info = bean_info.getAttributes(); - if (attr_info == null) - return 0; - else - { - for (MBeanAttributeInfo attr : attr_info) - { - Object toWrite = null; - attr_count++; - toWrite = mbsc.getAttribute(queue, attr.getName()); - if (attr_count == 7) - { - value = toWrite.toString(); - depth = new Integer(value); - } - } - - } - + depth = (Number) mbsc.getAttribute(queue, ManagedQueue.ATTR_MSG_COUNT); + } catch (Exception ex) { -- cgit v1.2.1