use of javax.management.MBeanParameterInfo in project spf4j by zolyfarkas.
the class ExportedValuesMBean method createBeanInfo.
private MBeanInfo createBeanInfo() {
MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[exportedValues.size()];
int i = 0;
for (ExportedValue<?> val : exportedValues.values()) {
attrs[i++] = createAttributeInfo(val);
}
MBeanOperationInfo[] operations = new MBeanOperationInfo[exportedOperations.size()];
i = 0;
for (ExportedOperation op : exportedOperations.values()) {
MBeanParameterInfo[] paramInfos = op.getParameterInfos();
String description = op.getDescription();
if (description == null || description.isEmpty()) {
description = op.getName();
}
OpenType<?> openType = op.getReturnOpenType();
operations[i++] = new MBeanOperationInfo(op.getName(), description, paramInfos, op.getReturnType().getName(), 0, openType == null ? null : new ImmutableDescriptor(new String[] { "openType", "originalType" }, new Object[] { openType, op.getReturnType().getName() }));
}
return new MBeanInfo(objectName.toString(), "spf4j exported", attrs, null, operations, null);
}
use of javax.management.MBeanParameterInfo in project neo4j-documentation by neo4j.
the class JmxBeanDocumenter method operationRow.
private void operationRow(PrintStream out, MBeanOperationInfo operInfo, boolean nonHtml) {
String type = getType(operInfo.getReturnType());
Descriptor descriptor = operInfo.getDescriptor();
type = getCompositeType(type, descriptor, nonHtml);
out.printf("|%s|%s|%s|", operInfo.getName(), operInfo.getDescription().replace('\n', ' '), type);
MBeanParameterInfo[] params = operInfo.getSignature();
if (params.length > 0) {
for (int i = 0; i < params.length; i++) {
MBeanParameterInfo param = params[i];
out.print(param.getType());
if (i != (params.length - 1)) {
out.print(",");
}
}
} else {
out.print("(no parameters)");
}
out.println();
}
use of javax.management.MBeanParameterInfo in project spring-framework by spring-projects.
the class AbstractMetadataAssemblerTests method testOperationParameterMetadata.
@Test
public void testOperationParameterMetadata() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
ModelMBeanOperationInfo oper = info.getOperation("add");
MBeanParameterInfo[] params = oper.getSignature();
assertThat(params.length).as("Invalid number of params").isEqualTo(2);
assertThat(params[0].getName()).as("Incorrect name for x param").isEqualTo("x");
assertThat(params[0].getType()).as("Incorrect type for x param").isEqualTo(int.class.getName());
assertThat(params[1].getName()).as("Incorrect name for y param").isEqualTo("y");
assertThat(params[1].getType()).as("Incorrect type for y param").isEqualTo(int.class.getName());
}
use of javax.management.MBeanParameterInfo in project spring-framework by spring-projects.
the class MetadataMBeanInfoAssembler method getOperationParameters.
/**
* Reads {@code MBeanParameterInfo} from the {@code ManagedOperationParameter}
* attributes attached to a method. Returns an empty array of {@code MBeanParameterInfo}
* if no attributes are found.
*/
@Override
protected MBeanParameterInfo[] getOperationParameters(Method method, String beanKey) {
ManagedOperationParameter[] params = obtainAttributeSource().getManagedOperationParameters(method);
if (ObjectUtils.isEmpty(params)) {
return super.getOperationParameters(method, beanKey);
}
MBeanParameterInfo[] parameterInfo = new MBeanParameterInfo[params.length];
Class<?>[] methodParameters = method.getParameterTypes();
for (int i = 0; i < params.length; i++) {
ManagedOperationParameter param = params[i];
parameterInfo[i] = new MBeanParameterInfo(param.getName(), methodParameters[i].getName(), param.getDescription());
}
return parameterInfo;
}
use of javax.management.MBeanParameterInfo in project tomcat by apache.
the class JMXProxyServlet method invokeOperationInternal.
/**
* Invokes an operation on an MBean.
*
* @param onameStr The name of the MBean.
* @param operation The name of the operation to invoke.
* @param parameters An array of Strings containing the parameters to the
* operation. They will be converted to the appropriate types to
* call the requested operation.
* @return The value returned by the requested operation.
*/
// parameters can't be null if signature.length > 0
@SuppressWarnings("null")
private Object invokeOperationInternal(String onameStr, String operation, String[] parameters) throws OperationsException, MBeanException, ReflectionException {
ObjectName oname = new ObjectName(onameStr);
int paramCount = null == parameters ? 0 : parameters.length;
MBeanOperationInfo methodInfo = registry.getMethodInfo(oname, operation, paramCount);
if (null == methodInfo) {
// getMethodInfo returns null for both "object not found" and "operation not found"
MBeanInfo info = null;
try {
info = registry.getMBeanServer().getMBeanInfo(oname);
} catch (InstanceNotFoundException infe) {
throw infe;
} catch (Exception e) {
throw new IllegalArgumentException(sm.getString("jmxProxyServlet.noBeanFound", onameStr), e);
}
throw new IllegalArgumentException(sm.getString("jmxProxyServlet.noOperationOnBean", operation, Integer.valueOf(paramCount), onameStr, info.getClassName()));
}
MBeanParameterInfo[] signature = methodInfo.getSignature();
String[] signatureTypes = new String[signature.length];
Object[] values = new Object[signature.length];
for (int i = 0; i < signature.length; i++) {
MBeanParameterInfo pi = signature[i];
signatureTypes[i] = pi.getType();
values[i] = registry.convertValue(pi.getType(), parameters[i]);
}
return mBeanServer.invoke(oname, operation, values, signatureTypes);
}
Aggregations