Search in sources :

Example 1 with MBeanDescription

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;
}
Also used : MBeanDescription(org.apache.felix.mosgi.jmx.agent.mx4j.MBeanDescription) MLet(javax.management.loading.MLet) Logger(org.apache.felix.mosgi.jmx.agent.mx4j.log.Logger)

Example 2 with MBeanDescription

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);
}
Also used : MBeanConstructorInfo(javax.management.MBeanConstructorInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) MBeanDescription(org.apache.felix.mosgi.jmx.agent.mx4j.MBeanDescription) MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo)

Aggregations

MBeanDescription (org.apache.felix.mosgi.jmx.agent.mx4j.MBeanDescription)2 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)1 MBeanInfo (javax.management.MBeanInfo)1 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)1 MBeanOperationInfo (javax.management.MBeanOperationInfo)1 MLet (javax.management.loading.MLet)1 Logger (org.apache.felix.mosgi.jmx.agent.mx4j.log.Logger)1