resource = getResourceOrThis();
info = getMBeanInfo();
}
MBeanOperationInfo[] opers = info.getOperations();
if (opers == null || opers.length == 0) throw new ReflectionException(new NoSuchMethodException("No operations defined for this MBean"));
for (int i = 0; i < opers.length; ++i)
{
MBeanOperationInfo oper = opers[i];
if (oper == null) continue;
if (method.equals(oper.getName()))
{
MBeanParameterInfo[] parameters = oper.getSignature();
if (params.length != parameters.length) continue;
String[] signature = new String[parameters.length];
for (int j = 0; j < signature.length; ++j)
{
MBeanParameterInfo param = parameters[j];
if (param == null)
signature[j] = null;
else
signature[j] = param.getType();
}
if (Utils.arrayEquals(params, signature))
{
// Found the right operation
try
{
Class[] classes = Utils.loadClasses(resource.getClass().getClassLoader(), signature);
return invoke(resource, method, classes, arguments);
}
catch (ClassNotFoundException x)
{
throw new ReflectionException(x);
}
catch (InvalidAttributeValueException x)
{
throw new ReflectionException(x);
}
}
}
}
throw new ReflectionException(new NoSuchMethodException("Operation " + method + " with signature " + Arrays.asList(params) + " is not defined for this MBean"));
}