if (params.length != signature.length) {
throw MESSAGES.differentLengths("params", "signature");
}
final ResourceAndRegistration reg = getRootResourceAndRegistration();
PathAddress address = ObjectNameAddressUtil.resolvePathAddress(reg.getResource(), name);
if (address == null) {
throw createInstanceNotFoundException(name);
}
final ImmutableManagementResourceRegistration registration = getMBeanRegistration(address, reg);
String realOperationName = null;
OperationEntry opEntry = registration.getOperationEntry(PathAddress.EMPTY_ADDRESS, operationName);
if (opEntry != null) {
realOperationName = operationName;
} else {
Map<String, OperationEntry> ops = registration.getOperationDescriptions(PathAddress.EMPTY_ADDRESS, false);
for (Map.Entry<String, OperationEntry> entry : ops.entrySet()) {
if (operationName.equals(NameConverter.convertToCamelCase(entry.getKey()))) {
opEntry = entry.getValue();
realOperationName = entry.getKey();
break;
}
}
}
if (opEntry == null) {
ChildAddOperationEntry entry = ChildAddOperationFinder.findAddChildOperation(reg.getRegistration().getSubModel(address), operationName);
if (entry == null) {
throw MESSAGES.noOperationCalled(null, operationName, address);
}
PathElement element = entry.getElement();
if (element.isWildcard()) {
if (params.length == 0) {
throw MESSAGES.wildcardNameParameterRequired();
}
element = PathElement.pathElement(element.getKey(), (String)params[0]);
Object[] newParams = new Object[params.length - 1];
System.arraycopy(params, 1, newParams, 0, newParams.length);
params = newParams;
}
return invoke(entry.getOperationEntry(), ADD, address.append(element), params);
}
return invoke(opEntry, realOperationName, address, params);
}