[jboss-cvs] JBossAS SVN: r99678 - branches/vfs3-int/system-jmx/src/main/java/org/jboss/system/deployers/managed.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 20 15:55:09 EST 2010
Author: johnbailey
Date: 2010-01-20 15:55:09 -0500 (Wed, 20 Jan 2010)
New Revision: 99678
Modified:
branches/vfs3-int/system-jmx/src/main/java/org/jboss/system/deployers/managed/ServiceMetaDataICF.java
Log:
[JBAS-7342] - Merging another changes from trunk -r 99317:99666
Modified: branches/vfs3-int/system-jmx/src/main/java/org/jboss/system/deployers/managed/ServiceMetaDataICF.java
===================================================================
--- branches/vfs3-int/system-jmx/src/main/java/org/jboss/system/deployers/managed/ServiceMetaDataICF.java 2010-01-20 20:46:46 UTC (rev 99677)
+++ branches/vfs3-int/system-jmx/src/main/java/org/jboss/system/deployers/managed/ServiceMetaDataICF.java 2010-01-20 20:55:09 UTC (rev 99678)
@@ -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