static MBeanInfo testCompliance(final Class baseClass,
Class mbeanInterface)
throws NotCompliantMBeanException {
if (baseClass.isInterface())
throw new NotCompliantMBeanException(baseClass.getName() +
" must be a class.");
// ------------------------------
// ------------------------------
if (mbeanInterface == null)
// No interface specified: look for default MBean interface.
mbeanInterface = getStandardMBeanInterface(baseClass);
else if (! mbeanInterface.isAssignableFrom(baseClass)) {
// specified interface not implemented by given class
final String msg =
baseClass.getName() + " does not implement the " +
mbeanInterface.getName() + " interface";
throw new NotCompliantMBeanException(msg);
} else if (! mbeanInterface.isInterface()) {
// Base class X, but XMBean is not an interface
final String msg =
baseClass.getName() + ": " + mbeanInterface.getName() +
" is not an interface";
throw new NotCompliantMBeanException(msg);
}
if (mbeanInterface == null) {
// Error: MBean does not implement javax.management.DynamicMBean
// nor MBean interface
final String baseClassName = baseClass.getName();
final String msg =
baseClassName + " does not implement the " + baseClassName +
"MBean interface or the DynamicMBean interface";
throw new NotCompliantMBeanException(msg);
}
final int mods = mbeanInterface.getModifiers();
if (!Modifier.isPublic(mods))
throw new NotCompliantMBeanException(mbeanInterface.getName() +
" implemented by " +
baseClass.getName() +
" must be public");
return (introspect(baseClass, mbeanInterface));