use of javax.management.OperationsException 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