protected Method findMethod(String name, Class<?> clazz, Class<?> returnType, Class<?>[] paramTypes) { Method method = null; try { method = clazz.getMethod(name, paramTypes); } catch (NoSuchMethodException e) { throw new MethodNotFoundException(LocalMessages.get("error.property.method.notfound", name, clazz), e); } method = findAccessibleMethod(method); if (method == null) { throw new MethodNotFoundException(LocalMessages.get("error.property.method.notfound", name, clazz)); } if (!ignoreReturnType && returnType != null && !returnType.isAssignableFrom(method.getReturnType())) { throw new MethodNotFoundException(LocalMessages.get("error.property.method.returntype", method.getReturnType(), name, clazz, returnType)); } return method; }
protected MethodExpression getMethodExpression(Bindings bindings, ELContext context, Class<?> returnType, Class<?>[] paramTypes) { Object value = eval(bindings, context); if (value == null) { throw new MethodNotFoundException(LocalMessages.get("error.identifier.method.notfound", name)); throw new MethodNotFoundException(LocalMessages.get("error.identifier.method.notfound", name)); throw new MethodNotFoundException(LocalMessages.get("error.identifier.method.returntype", method.getReturnType(), name, returnType)); throw new MethodNotFoundException(LocalMessages.get("error.identifier.method.notfound", name)); return (MethodExpression)value; throw new MethodNotFoundException(LocalMessages.get("error.identifier.method.notamethod", name, value.getClass()));
Method target = findMethod(base, name, paramTypes, params.length); if (target == null) { throw new MethodNotFoundException("Cannot find method " + name + " with " + params.length + " parameters in " + base.getClass());
protected Object eval(Bindings bindings, ELContext context, boolean answerNullIfBaseIsNull) { Object base = property.getPrefix().eval(bindings, context); if (base == null) { if (answerNullIfBaseIsNull) { return null; } throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", property.getPrefix())); } Object method = property.getProperty(bindings, context); if (method == null) { throw new PropertyNotFoundException(LocalMessages.get("error.property.method.notfound", "null", base)); } String name = bindings.convert(method, String.class); context.setPropertyResolved(false); Object result = context.getELResolver().invoke(context, base, name, null, params.eval(bindings, context)); if (!context.isPropertyResolved()) { throw new MethodNotFoundException(LocalMessages.get("error.property.method.notfound", name, base.getClass())); } return result; }