| 122 | } |
| 123 | |
| 124 | @Override |
| 125 | public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) { |
| 126 | Objects.requireNonNull(context); |
| 127 | if (base == null || method == null) { |
| 128 | return null; |
| 129 | } |
| 130 | |
| 131 | ExpressionFactory factory = ELManager.getExpressionFactory(); |
| 132 | |
| 133 | String methodName = factory.coerceToType(method, String.class); |
| 134 | |
| 135 | // Find the matching method |
| 136 | Method matchingMethod = Util.findMethod(context, base.getClass(), base, methodName, paramTypes, params); |
| 137 | |
| 138 | Object[] parameters = |
| 139 | Util.buildParameters(context, matchingMethod.getParameterTypes(), matchingMethod.isVarArgs(), params); |
| 140 | |
| 141 | Object result; |
| 142 | try { |
| 143 | result = matchingMethod.invoke(base, parameters); |
| 144 | } catch (IllegalArgumentException | IllegalAccessException e) { |
| 145 | throw new ELException(e); |
| 146 | } catch (InvocationTargetException e) { |
| 147 | Throwable cause = e.getCause(); |
| 148 | Util.handleThrowable(cause); |
| 149 | throw new ELException(cause); |
| 150 | } |
| 151 | |
| 152 | context.setPropertyResolved(base, method); |
| 153 | return result; |
| 154 | } |
| 155 | |
| 156 | @Override |
| 157 | public boolean isReadOnly(ELContext context, Object base, Object property) { |