}
List<EmsParameter> emsParams = operation.getParameters();
Map<String, Integer> emsParamIndexesByName = new HashMap<String, Integer>();
for (int i = 0, emsParamsSize = emsParams.size(); i < emsParamsSize; i++) {
EmsParameter emsParam = emsParams.get(i);
if (emsParam.getName() != null) {
emsParamIndexesByName.put(emsParam.getName(), i);
}
}
Object[] paramValues = new Object[operation.getParameters().size()];
for (String propName : paramProps.keySet()) {
Integer paramIndex;
if (propName.matches("\\[\\d+\\]")) {
paramIndex = Integer.valueOf(propName.substring(propName.indexOf('[') + 1, propName.indexOf(']')));
if (paramIndex < 0 || paramIndex >= emsParams.size()) {
throw new IllegalStateException("Index [" + paramIndex + "] specified for parameter of operation ["
+ name + "] on MBean [" + emsBean.getBeanName() + "] is invalid. The MBean operation takes "
+ emsParams.size() + " parameters.");
}
} else {
paramIndex = emsParamIndexesByName.get(propName);
if (paramIndex == null) {
throw new IllegalStateException("Name [" + propName + "] specified for parameter of operation ["
+ name + "] on MBean [" + emsBean.getBeanName()
+ "] is invalid. The MBean operation does not take a parameter by that name.");
}
}
EmsParameter emsParam = emsParams.get(paramIndex);
PropertySimple paramProp = paramProps.get(propName);
String emsParamType = emsParam.getType();
Object paramValue = getPropertyValueAsType(paramProp, emsParamType);
paramValues[paramIndex] = paramValue;
}
Object resultObject = operation.invoke(paramValues);