Methods Summary |
---|
private void | checkBasic(java.lang.Class c)
if (!isInstantiableJavaClass(c))
{
throw new NotCompliantMBeanException();
}
|
private void | checkCompliance()
if (!(mIsStandard || mIsDynamic) || // (A U B)' = A' ^ B'
(mIsStandard && mIsDynamic))
{
throw new NotCompliantMBeanException();
}
|
private void | checkMBeanType(java.lang.Class c)
/*
* StandardMBean Checks :-
* 1. It is neither primitive type, nor an interface nor an
* abstract class.
* 2. Implements <className>MBean interface. If not,
* 3. A nearest superclass (can omit java.lang.Object) is a
* standard mbean.
*
* DynamicMBean Checks :-
* 1. It is neither primitive type, nor an interface nor an
* abstract class.
* 2. It implements DynamicMBean interface. If not,
* 3. Any of its superclasses implements DynamicMBean interface.
*/
boolean isStandard = isStandard(c);
boolean isDynamic = isDynamic(c);
if (!(isStandard || isDynamic)) // (A U B)' = A' ^ B'
{
Class superClass = c.getSuperclass();
//Can omit java.lang.Object.
if ((superClass != null) &&
(superClass != java.lang.Object.class))
{
checkMBeanType(superClass);
}
}
/**
* Need to check both conditions even though it is either or.
* A class that is both standard & dynamic is not compliant
* and will be raised in checkCompliance()
*/
if (isStandard)
{
mIsStandard = true;
setStandardMBeanInterface(c);
}
if (isDynamic)
{
mIsDynamic = true;
setDynamicMBeanInterface();
}
|
private final java.lang.String | convertToCamelCase(java.lang.String str)
String camelCase = "";
char c = str.charAt(0);
camelCase += Character.toUpperCase(c);
if (str.length() > 1)
{
camelCase += str.substring(1);
}
return camelCase;
|
private java.lang.String | deriveStandardMBeanIntfClassName(java.lang.Class c)If class name is foo.bar, this method returns barMBean
String className = truncateClassName(c);
return (className + "MBean");
|
private java.lang.Class | getImplementedMBeanClass(java.lang.Class c, java.lang.String intfName)
Class implementedMBean = null;
Class[] interfaces = c.getInterfaces();
/* No need to check for null as c.getInterfaces() javadoc claims to
* return an array of 0 length if the class does not implement any
* interfaces or if the class is a primitive type.
*/
for (int i = 0; i < interfaces.length; i++)
{
String className = truncateClassName(interfaces[i]);
if (className.equals(intfName))
{
implementedMBean = interfaces[i];
break;
}
}
return implementedMBean;
|
public java.lang.Class | getMBeanInterfaceClass()
return mMBeanInterfaceClass;
|
private boolean | isDynamic(java.lang.Class c)
boolean isDynamic = false;
Class[] interfaces = c.getInterfaces();
/* No need to check for null as c.getInterfaces() javadoc claims to
* return an array of 0 length if the class does not implement any
* interfaces or if the class is a primitive type.
*/
int length = interfaces.length;
for (int i = 0; i < length; i++)
{
if (interfaces[i] == javax.management.DynamicMBean.class)
{
isDynamic = true;
break;
}
}
return isDynamic;
|
public boolean | isDynamicMBean()
return mIsDynamic;
|
private boolean | isInstantiableJavaClass(java.lang.Class c)
boolean isInstantiable = false;
if (!c.isPrimitive() && !c.isArray())
{
int modifiers = c.getModifiers();
boolean isInterface = Modifier.isInterface(modifiers);
boolean isAbstract = Modifier.isAbstract(modifiers);
isInstantiable = !(isInterface || isAbstract);
}
return isInstantiable;
|
private boolean | isStandard(java.lang.Class c)
boolean isStandard = false;
/**
* Note that mbean impl & mbean interface can be in different
* packages.
*/
String className = deriveStandardMBeanIntfClassName(c);
if (getImplementedMBeanClass(c, className) != null)
{
isStandard = true;
}
return isStandard;
|
public boolean | isStandardMBean()
return mIsStandard;
|
public boolean | isSupported(java.lang.String methodName, java.lang.Class[] signature)
boolean isSupported = false;
try
{
Method m = mMBeanInterfaceClass.getMethod(methodName, signature);
isSupported = (m != null);
}
catch (Exception e)
{
}
return isSupported;
|
private void | setDynamicMBeanInterface()
mMBeanInterfaceClass = javax.management.DynamicMBean.class;
|
private void | setStandardMBeanInterface(java.lang.Class c)
String className = deriveStandardMBeanIntfClassName(c);
mMBeanInterfaceClass = getImplementedMBeanClass(c, className);
|
private java.lang.String | truncateClassName(java.lang.Class c)If class name is foo.bar, this method returns bar
String className = c.getName();
int lastDot = className.lastIndexOf('.");
className = className.substring(lastDot + 1);
return className;
|