use of javax.management.openmbean.OpenMBeanParameterInfo in project jdk8u_jdk by JetBrains.
the class MXBeanIntrospector method getMBeanOperationInfo.
@Override
MBeanOperationInfo getMBeanOperationInfo(String operationName, 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(paramName, paramDescription, openType, descriptor);
} else {
openParameterTypes = false;
pi = new MBeanParameterInfo(paramName, 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;
}
Aggregations