use of org.apache.felix.mosgi.jmx.agent.mx4j.MBeanDescription in project felix by apache.
the class MBeanIntrospector method createMBeanDescription.
private MBeanDescription createMBeanDescription(MBeanMetaData metadata) {
// This is a non-standard extension
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.TRACE))
logger.trace("Looking for standard MBean description...");
Class mbeanClass = metadata.mbean.getClass();
for (Class cls = mbeanClass; cls != null; cls = cls.getSuperclass()) {
String clsName = cls.getName();
if (clsName.startsWith("java."))
break;
// Use full qualified name only
String descrClassName = clsName + "MBeanDescription";
// Try to load the class
try {
Class descrClass = null;
ClassLoader loader = metadata.classloader;
if (loader != null) {
// only in the classloader of the mbean, not in the whole CLR (since MLets delegates to the CLR)
if (loader.getClass() == MLet.class)
descrClass = ((MLet) loader).loadClass(descrClassName, null);
else
descrClass = loader.loadClass(descrClassName);
} else {
descrClass = Class.forName(descrClassName, false, null);
}
Object descrInstance = descrClass.newInstance();
if (descrInstance instanceof MBeanDescription) {
MBeanDescription description = (MBeanDescription) descrInstance;
if (logger.isEnabledFor(Logger.TRACE))
logger.trace("Found provided standard MBean description: " + description);
return description;
}
} catch (ClassNotFoundException ignored) {
} catch (InstantiationException ignored) {
} catch (IllegalAccessException ignored) {
}
}
MBeanDescription description = DEFAULT_DESCRIPTION;
if (logger.isEnabledFor(Logger.TRACE))
logger.trace("Cannot find standard MBean description, using default: " + description);
return description;
}
use of org.apache.felix.mosgi.jmx.agent.mx4j.MBeanDescription in project felix by apache.
the class MBeanIntrospector method createStandardMBeanInfo.
private MBeanInfo createStandardMBeanInfo(MBeanMetaData metadata) {
// This is a non-standard extension: description for standard MBeans
MBeanDescription description = createMBeanDescription(metadata);
MBeanConstructorInfo[] ctors = createMBeanConstructorInfo(metadata, description);
if (ctors == null)
return null;
MBeanAttributeInfo[] attrs = createMBeanAttributeInfo(metadata, description);
if (attrs == null)
return null;
MBeanOperationInfo[] opers = createMBeanOperationInfo(metadata, description);
if (opers == null)
return null;
MBeanNotificationInfo[] notifs = createMBeanNotificationInfo(metadata);
if (notifs == null)
return null;
return new MBeanInfo(metadata.mbean.getClass().getName(), description.getMBeanDescription(), attrs, ctors, opers, notifs);
}
Aggregations