use of javax.management.Descriptor 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;
}
use of javax.management.Descriptor in project qi4j-sdk by Qi4j.
the class ModelMBeanBuilder method operation.
public ModelMBeanBuilder operation(String name, String description, String returnType, int impact, MBeanParameterInfo... parameters) {
Descriptor stateDesc = new DescriptorSupport();
stateDesc.setField("name", name);
stateDesc.setField("descriptorType", "operation");
stateDesc.setField("class", className);
stateDesc.setField("role", "operation");
stateDesc.setField("targetType", "objectReference");
ModelMBeanOperationInfo operationInfo = new ModelMBeanOperationInfo(name, description, parameters, returnType, impact, stateDesc);
operations.add(operationInfo);
return this;
}
use of javax.management.Descriptor in project qi4j-sdk by Qi4j.
the class ModelMBeanBuilder method newModelMBean.
public RequiredModelMBean newModelMBean() throws MBeanException {
Descriptor mmbDesc = new DescriptorSupport();
mmbDesc.setField("name", objectName.toString());
mmbDesc.setField("descriptorType", "mbean");
mmbDesc.setField("displayName", displayName);
ModelMBeanInfo modelMBeanInfo = new ModelMBeanInfoSupport(className, displayName, attributes.toArray(new ModelMBeanAttributeInfo[attributes.size()]), constructors.toArray(new ModelMBeanConstructorInfo[constructors.size()]), operations.toArray(new ModelMBeanOperationInfo[operations.size()]), notifications.toArray(new ModelMBeanNotificationInfo[notifications.size()]));
modelMBeanInfo.setMBeanDescriptor(mmbDesc);
return new RequiredModelMBean(modelMBeanInfo);
}
use of javax.management.Descriptor in project cxf by apache.
the class ModelMBeanAssembler method addAttributeOperation.
void addAttributeOperation(Method method) {
Descriptor operationDescriptor = supporter.buildAttributeOperationDescriptor(method.getName());
Class<?>[] types = method.getParameterTypes();
String[] paramTypes = new String[types.length];
String[] paramNames = new String[types.length];
String[] paramDescs = new String[types.length];
for (int j = 0; j < types.length; j++) {
paramTypes[j] = types[j].getName();
paramDescs[j] = "";
paramNames[j] = types[j].getName();
}
supporter.addModelMBeanMethod(method.getName(), paramTypes, paramNames, paramDescs, "", method.getReturnType().getName(), operationDescriptor);
}
use of javax.management.Descriptor in project cxf by apache.
the class ModelMBeanInfoSupporter method buildMBeanDescriptor.
public Descriptor buildMBeanDescriptor(ManagedResource mr) {
Descriptor desc = new DescriptorSupport();
if (mr.componentName() != null) {
desc.setField("name", mr.componentName());
}
desc.setField("descriptorType", "mbean");
if (mr.description() != null) {
desc.setField("displayName", mr.description());
}
if (mr.persistLocation() != null) {
desc.setField("persistLocation", mr.persistLocation());
}
if (mr.persistName() != null) {
desc.setField("persistName", mr.persistName());
}
if (mr.log()) {
desc.setField("log", "true");
} else {
desc.setField("log", "false");
}
if (mr.persistPolicy() != null) {
desc.setField("persistPolicy", mr.persistPolicy());
}
if (mr.persistPeriod() >= -1) {
desc.setField("persistPeriod", mr.persistPeriod());
}
if (mr.logFile() != null) {
desc.setField("logFile", mr.logFile());
}
if (mr.currencyTimeLimit() >= -1) {
desc.setField("currencyTimeLimit", mr.currencyTimeLimit());
}
return desc;
}
Aggregations