[jboss-cvs] JBossAS SVN: r99552 - trunk/system-jmx/src/main/java/org/jboss/system/deployers/managed.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 18 14:09:53 EST 2010
Author: adrian at jboss.org
Date: 2010-01-18 14:09:53 -0500 (Mon, 18 Jan 2010)
New Revision: 99552
Modified:
trunk/system-jmx/src/main/java/org/jboss/system/deployers/managed/ServiceMetaDataICF.java
Log:
Fix the compile
Modified: trunk/system-jmx/src/main/java/org/jboss/system/deployers/managed/ServiceMetaDataICF.java
===================================================================
--- trunk/system-jmx/src/main/java/org/jboss/system/deployers/managed/ServiceMetaDataICF.java 2010-01-18 18:57:28 UTC (rev 99551)
+++ trunk/system-jmx/src/main/java/org/jboss/system/deployers/managed/ServiceMetaDataICF.java 2010-01-18 19:09:53 UTC (rev 99552)
@@ -30,6 +30,7 @@
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -43,7 +44,7 @@
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.spi.values.MetaMapper;
-import org.jboss.system.ServiceConfigurator;
+import org.jboss.mx.util.JMXExceptionDecoder;
import org.jboss.system.ServiceController;
import org.jboss.system.metadata.ServiceAnnotationMetaData;
import org.jboss.system.metadata.ServiceAttributeMetaData;
@@ -213,7 +214,7 @@
try
{
// TODO: cache this somehow
- HashMap<String, MBeanAttributeInfo> attrs = ServiceConfigurator.getAttributeMap(mbeanServer, mbean);
+ HashMap<String, MBeanAttributeInfo> attrs = getAttributeMap(mbeanServer, mbean);
MBeanAttributeInfo mbi = attrs.get(attrName);
ServiceValueContext svc = new ServiceValueContext(mbeanServer, controller, mbi, loader);
value = text.getValue(svc);
@@ -460,4 +461,41 @@
}
return attrName;
}
+
+ /**
+ * Get an attribute map for the MBean
+ *
+ * @param server the server
+ * @param objectName the object name
+ * @return a map of attribute name to attribute info
+ * @throws Exception for any error
+ */
+ private static HashMap<String, MBeanAttributeInfo> getAttributeMap(MBeanServer server, ObjectName objectName) throws Exception
+ {
+ MBeanInfo info;
+ try
+ {
+ info = server.getMBeanInfo(objectName);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ // The MBean is no longer available
+ throw new RuntimeException("Trying to configure nonexistent mbean: " + objectName);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not get mbeanInfo", JMXExceptionDecoder.decode(e));
+ }
+ if (info == null)
+ throw new RuntimeException("MBeanInfo is null for mbean: " + objectName);
+ MBeanAttributeInfo[] attributes = info.getAttributes();
+ HashMap<String, MBeanAttributeInfo> attributeMap = new HashMap<String, MBeanAttributeInfo>();
+ for (int i = 0; i < attributes.length; i++)
+ {
+ MBeanAttributeInfo attr = attributes[i];
+ attributeMap.put(attr.getName(), attr);
+ }
+
+ return attributeMap;
+ }
}
More information about the jboss-cvs-commits
mailing list