Methods Summary |
---|
private static boolean | canUseOpenInfo(java.lang.reflect.Type type)True if this type can be faithfully represented in an
OpenMBean*Info.
Compatibility with JSR 174 means that primitive types must be
represented by an MBean*Info whose getType() is the primitive type
string, e.g. "int". If we used an OpenMBean*Info then this string
would be the wrapped type, e.g. "java.lang.Integer".
Compatibility with JMX 1.2 (including J2SE 5.0) means that arrays
of primitive types cannot use an ArrayType representing an array of
primitives, because that didn't exist in JMX 1.2.
if (type instanceof GenericArrayType) {
return canUseOpenInfo(
((GenericArrayType) type).getGenericComponentType());
} else if (type instanceof Class && ((Class<?>) type).isArray()) {
return canUseOpenInfo(
((Class<?>) type).getComponentType());
}
return (!(type instanceof Class && ((Class<?>) type).isPrimitive()));
|
void | checkMethod(com.sun.jmx.mbeanserver.ConvertingMethod m)
m.checkCallFromOpen();
|
com.sun.jmx.mbeanserver.MBeanAnalyzer | getAnalyzer(java.lang.Class mbeanInterface)
return MBeanAnalyzer.analyzer(mbeanInterface, this);
|
javax.management.Descriptor | getBasicMBeanDescriptor()
return new ImmutableDescriptor("mxbean=true",
"immutableInfo=true");
|
java.lang.reflect.Type[] | getGenericParameterTypes(com.sun.jmx.mbeanserver.ConvertingMethod m)
return m.getGenericParameterTypes();
|
java.lang.reflect.Type | getGenericReturnType(com.sun.jmx.mbeanserver.ConvertingMethod m)
return m.getGenericReturnType();
|
static com.sun.jmx.mbeanserver.MXBeanIntrospector | getInstance()
return instance;
|
javax.management.MBeanAttributeInfo | getMBeanAttributeInfo(java.lang.String attributeName, com.sun.jmx.mbeanserver.ConvertingMethod getter, com.sun.jmx.mbeanserver.ConvertingMethod setter)
final boolean isReadable = (getter != null);
final boolean isWritable = (setter != null);
final boolean isIs = isReadable && getName(getter).startsWith("is");
final String description = attributeName;
final OpenType<?> openType;
final Type originalType;
if (isReadable) {
openType = getter.getOpenReturnType();
originalType = getter.getGenericReturnType();
} else {
openType = setter.getOpenParameterTypes()[0];
originalType = setter.getGenericParameterTypes()[0];
}
Descriptor descriptor = typeDescriptor(openType, originalType);
if (isReadable) {
descriptor = ImmutableDescriptor.union(descriptor,
getter.getDescriptor());
}
if (isWritable) {
descriptor = ImmutableDescriptor.union(descriptor,
setter.getDescriptor());
}
final MBeanAttributeInfo ai;
if (canUseOpenInfo(originalType)) {
ai = new OpenMBeanAttributeInfoSupport(attributeName,
description,
openType,
isReadable,
isWritable,
isIs,
descriptor);
} else {
ai = new MBeanAttributeInfo(attributeName,
originalTypeString(originalType),
description,
isReadable,
isWritable,
isIs,
descriptor);
}
// could also consult annotations for defaultValue,
// minValue, maxValue, legalValues
return ai;
|
javax.management.Descriptor | getMBeanDescriptor(java.lang.Class resourceClass)
/* We already have immutableInfo=true in the Descriptor
* included in the MBeanInfo for the MXBean interface. This
* method is being called for the MXBean *class* to add any
* new items beyond those in the interface Descriptor, which
* currently it does not.
*/
return ImmutableDescriptor.EMPTY_DESCRIPTOR;
|
MBeanInfoMap | getMBeanInfoMap()
return mbeanInfoMap;
|
javax.management.MBeanOperationInfo | getMBeanOperationInfo(java.lang.String operationName, com.sun.jmx.mbeanserver.ConvertingMethod operation)
final Method method = operation.getMethod();
final String description = operationName;
/* Ideally this would be an empty string, but
OMBOperationInfo constructor forbids that. Also, we
could consult an annotation to get a useful
description. */
final int impact = MBeanOperationInfo.UNKNOWN;
final OpenType<?> returnType = operation.getOpenReturnType();
final Type originalReturnType = operation.getGenericReturnType();
final OpenType<?>[] paramTypes = operation.getOpenParameterTypes();
final Type[] originalParamTypes = operation.getGenericParameterTypes();
final MBeanParameterInfo[] params =
new MBeanParameterInfo[paramTypes.length];
boolean openReturnType = canUseOpenInfo(originalReturnType);
boolean openParameterTypes = true;
Annotation[][] annots = method.getParameterAnnotations();
for (int i = 0; i < paramTypes.length; i++) {
final String paramName = "p" + i;
final String paramDescription = paramName;
final OpenType<?> openType = paramTypes[i];
final Type originalType = originalParamTypes[i];
Descriptor descriptor =
typeDescriptor(openType, originalType);
descriptor = ImmutableDescriptor.union(descriptor,
Introspector.descriptorForAnnotations(annots[i]));
final MBeanParameterInfo pi;
if (canUseOpenInfo(originalType)) {
pi = new OpenMBeanParameterInfoSupport("p" + i,
paramDescription,
openType,
descriptor);
} else {
openParameterTypes = false;
pi = new MBeanParameterInfo(
"p" + i,
originalTypeString(originalType),
paramDescription,
descriptor);
}
params[i] = pi;
}
Descriptor descriptor =
typeDescriptor(returnType, originalReturnType);
descriptor = ImmutableDescriptor.union(descriptor,
Introspector.descriptorForElement(method));
final MBeanOperationInfo oi;
if (openReturnType && openParameterTypes) {
/* If the return value and all the parameters can be faithfully
* represented as OpenType then we return an OpenMBeanOperationInfo.
* If any of them is a primitive type, we can't. Compatibility
* with JSR 174 means that we must return an MBean*Info where
* the getType() is the primitive type, not its wrapped type as
* we would get with an OpenMBean*Info. The OpenType is available
* in the Descriptor in either case.
*/
final OpenMBeanParameterInfo[] oparams =
new OpenMBeanParameterInfo[params.length];
System.arraycopy(params, 0, oparams, 0, params.length);
oi = new OpenMBeanOperationInfoSupport(operationName,
description,
oparams,
returnType,
impact,
descriptor);
} else {
oi = new MBeanOperationInfo(operationName,
description,
params,
openReturnType ?
returnType.getClassName() :
originalTypeString(originalReturnType),
impact,
descriptor);
}
return oi;
|
java.lang.String | getName(com.sun.jmx.mbeanserver.ConvertingMethod m)
return m.getName();
|
PerInterfaceMap | getPerInterfaceMap()
return perInterfaceMap;
|
java.lang.String[] | getSignature(com.sun.jmx.mbeanserver.ConvertingMethod m)
return m.getOpenSignature();
|
java.lang.Object | invokeM2(com.sun.jmx.mbeanserver.ConvertingMethod m, java.lang.Object target, java.lang.Object[] args, java.lang.Object cookie)
return m.invokeWithOpenReturn((MXBeanLookup) cookie, target, args);
|
boolean | isMXBean()
return true;
|
com.sun.jmx.mbeanserver.ConvertingMethod | mFrom(java.lang.reflect.Method m)
return ConvertingMethod.from(m);
|
private static java.lang.String | originalTypeString(java.lang.reflect.Type type)
if (type instanceof Class)
return ((Class) type).getName();
else
return type.toString();
|
private static javax.management.Descriptor | typeDescriptor(javax.management.openmbean.OpenType openType, java.lang.reflect.Type originalType)
return new ImmutableDescriptor(
new String[] {"openType",
"originalType"},
new Object[] {openType,
originalTypeString(originalType)});
|
boolean | validParameter(com.sun.jmx.mbeanserver.ConvertingMethod m, java.lang.Object value, int paramNo, java.lang.Object cookie)
if (value == null) {
// Null is a valid value for all OpenTypes, even though
// OpenType.isValue(null) will return false. It can always be
// matched to the corresponding Java type, except when that
// type is primitive.
Type t = m.getGenericParameterTypes()[paramNo];
return (!(t instanceof Class) || !((Class) t).isPrimitive());
} else {
Object v;
try {
v = m.fromOpenParameter((MXBeanLookup) cookie, value, paramNo);
} catch (Exception e) {
// Ignore the exception and let MBeanIntrospector.invokeSetter()
// throw the initial exception.
return true;
}
return isValidParameter(m.getMethod(), v, paramNo);
}
|