Author: pferraro
Date: 2008-12-16 15:31:52 -0500 (Tue, 16 Dec 2008)
New Revision: 2153
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadContext.java
Log:
[MODCLUSTER-29] Support mixed-case mbean attributes
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadContext.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadContext.java 2008-12-16
19:40:32 UTC (rev 2152)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadContext.java 2008-12-16
20:31:52 UTC (rev 2153)
@@ -26,6 +26,7 @@
import java.util.List;
import java.util.Set;
+import javax.management.AttributeNotFoundException;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -71,9 +72,36 @@
for (ObjectName name: this.names)
{
- list.add(targetClass.cast(this.server.getAttribute(name, attribute)));
+ list.add(targetClass.cast(this.getAttribute(name, attribute)));
}
return list;
}
+
+ private Object getAttribute(ObjectName name, String attribute) throws JMException
+ {
+ try
+ {
+ return this.server.getAttribute(name, attribute);
+ }
+ catch (AttributeNotFoundException e)
+ {
+ // MODCLUSTER-29
+ // Try again, reversing case of the first letter of the attribute
+ StringBuilder builder = new StringBuilder(attribute.length());
+ char first = attribute.charAt(0);
+ builder.append(Character.isLowerCase(first) ? Character.toUpperCase(first) :
Character.toLowerCase(first));
+ builder.append(attribute.substring(1));
+
+ try
+ {
+ return this.server.getAttribute(name, builder.toString());
+ }
+ catch (AttributeNotFoundException e2)
+ {
+ // Throw original exception
+ throw e;
+ }
+ }
+ }
}
Show replies by date