private void introspectMBeanInfo(MBeanMetaData metadata) {
   if (metadata.dynamic) {
     metadata.info = getDynamicMBeanInfo(metadata);
   } else if (metadata.standard) {
     metadata.info = createStandardMBeanInfo(metadata);
   } else {
     // Not a valid MBean, reset the MBeanInfo: this will cause an exception later
     metadata.info = null;
   }
 }
  private void introspectType(MBeanMetaData metadata) {
    // Some information is already provided (StandardMBean)
    if (metadata.standard) {
      introspectStandardMBean(metadata);
      return;
    }

    if (metadata.mbean instanceof DynamicMBean) {
      metadata.dynamic = true;
      return;
    } else {
      metadata.dynamic = false;
      // Continue and see if it's a plain standard MBean
    }

    // We have a plain standard MBean, introspect it
    introspectStandardMBean(metadata);
  }
  private void introspectStandardMBean(MBeanMetaData metadata) {
    if (metadata.management != null) {
      // Be sure the MBean implements the management interface
      if (metadata.management.isInstance(metadata.mbean)) {
        if (metadata.invoker == null) metadata.invoker = createInvoker(metadata);
        return;
      } else {
        // Not compliant, reset the values
        metadata.standard = false;
        metadata.management = null;
        metadata.invoker = null;
        return;
      }
    } else {
      Class cls = metadata.mbean.getClass();
      for (Class c = cls; c != null; c = c.getSuperclass()) {
        Class[] intfs = c.getInterfaces();
        for (int i = 0; i < intfs.length; ++i) {
          Class intf = intfs[i];

          if (implementsMBean(c.getName(), intf.getName())) {
            // OK, found the MBean interface for this class
            metadata.standard = true;
            metadata.management = intf;
            metadata.invoker = createInvoker(metadata);
            return;
          }
        }
      }

      // Management interface not found, it's not compliant, reset the values
      metadata.standard = false;
      metadata.management = null;
      metadata.invoker = null;
    }
  }