List<Class> paramTypes = Collections.emptyList();
if (0 < params.getLength()) {
paramTypes = new ArrayList<Class>();
List<Parameter> paramList = new ArrayList<Parameter>();
Parameter toAdd = null;
ExpressionFactory ef = context.getApplication().getExpressionFactory();
ELContext elContext = context.getELContext();
ValueExpression ve = null;
for (int i_param = 0; i_param < params.getLength(); i_param++) {
Node param = params.item(i_param);
NodeList valueList = (NodeList)
xpath.evaluate(".//ns1:value/text()", param, XPathConstants.NODESET);
if (null == valueList || 1 != valueList.getLength()) {
throw new XPathExpressionException("Within <parameter> exactly one <value> child is allowed");
}
String valueStr = valueList.item(0).getNodeValue().trim();
String classStr = null;
NodeList classList = (NodeList)
xpath.evaluate(".//ns1:class/text()", param, XPathConstants.NODESET);
if (null != classList && 1 < classList.getLength()) {
throw new XPathExpressionException("Within <parameter> at most one <class> child is allowed");
}
if (null != classList && 1 == classList.getLength()) {
classStr = classList.item(0).getNodeValue().trim();
}
Class clazz = String.class;
if (null != classStr) {
try {
clazz = ReflectionUtil.forName(classStr);
} catch (ClassNotFoundException e) {
clazz = Object.class;
}
}
ve = ef.createValueExpression(elContext, valueStr, clazz);
toAdd = new ParameterImpl(classStr, ve);
paramList.add(toAdd);
paramTypes.add(clazz);
}
methodCallBuilder.parameters(paramList);