public static Object callStaticMethod(OgnlContext context, String className, String methodName, Object[] args) throws OgnlException { try { Class targetClass = classForName(context, className); if (targetClass == null) throw new ClassNotFoundException("Unable to resolve class with name " + className); MethodAccessor ma = getMethodAccessor(targetClass); return ma.callStaticMethod(context, targetClass, methodName, args); } catch (ClassNotFoundException ex) { throw new MethodFailedException(className, methodName, ex); } }
private Object callMethodWithDebugInfo(Map context, Object object, String methodName, Object[] objects) throws MethodFailedException { try { return super.callMethod(context, object, methodName, objects); } catch(MethodFailedException e) { if (LOG.isDebugEnabled()) { if (!(e.getReason() instanceof NoSuchMethodException)) { // the method exists on the target object, but something went wrong String s = "Error calling method through OGNL: object: [#0] method: [#1] args: [#2]"; LOG.debug(s, e.getReason(), object.toString(), methodName, Arrays.toString(objects)); } } throw e; } }
public void setValue(String name, String key, String[] values) { try { OgnlContext ctx = contexts.get(name); Ognl.setValue(key, ctx, ctx.getRoot(), values.length == 1 ? values[0] : values); contexts.put(ctx.getRoot(), ctx); } catch (MethodFailedException e) { // setter threw an exception Throwable cause = e.getCause(); if (cause.getClass().isAnnotationPresent(ValidationException.class)) { throw new ConversionError(cause.getLocalizedMessage()); } else { throw new InvalidParameterException("unable to parse expression '" + key + '\'', e); } } catch (NoSuchPropertyException ex) { // TODO optimization: be able to ignore or not logger.debug("cant find property for expression {} ignoring", key); logger.trace("Reason:", ex); } catch (OgnlException e) { // TODO it fails when parameter name is not a valid java // identifier... ignoring by now logger.debug("unable to parse expression '{}'. Ignoring.", key); logger.trace("Reason:", e); } }
} catch (MethodFailedException e) { if (e.getReason() instanceof NoSuchMethodException) { try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1) + "()"; } catch (MethodFailedException e1) { if (e1.getReason() instanceof NoSuchMethodException) { if (unknownHandlerManager.hasUnknownHandlers()) { try { } catch (MethodFailedException e) { Throwable t = e.getCause();
public static Object callStaticMethod(OgnlContext context, String className, String methodName, Object[] args) throws OgnlException { try { Class targetClass = classForName(context, className); if (targetClass == null) throw new ClassNotFoundException("Unable to resolve class with name " + className); MethodAccessor ma = getMethodAccessor(targetClass); return ma.callStaticMethod(context, targetClass, methodName, args); } catch (ClassNotFoundException ex) { throw new MethodFailedException(className, methodName, ex); } }
private Object callStaticMethodWithDebugInfo(Map context, Class aClass, String methodName, Object[] objects) throws MethodFailedException { try { return super.callStaticMethod(context, aClass, methodName, objects); } catch(MethodFailedException e) { if (LOG.isDebugEnabled()) { if (!(e.getReason() instanceof NoSuchMethodException)) { // the method exists on the target class, but something went wrong String s = "Error calling method through OGNL, class: [#0] method: [#1] args: [#2]"; LOG.debug(s, e.getReason(), aClass.getName(), methodName, Arrays.toString(objects)); } } throw e; } } }
public static final Object callStaticMethod( OgnlContext context, String className, String methodName, Object[] args ) throws OgnlException, MethodFailedException { try { Object result; Class targetClass = classForName(context, className); MethodAccessor ma = getMethodAccessor(targetClass); return ma.callStaticMethod(context, targetClass, methodName, args); } catch (ClassNotFoundException ex) { throw new MethodFailedException(className, methodName, ex); } }
private InvalidExpressionException invalidExpressionException(OgnlException e) { Throwable cause = e; String message = e.getMessage(); if (e.getReason() != null) { message = e.getReason().getMessage(); cause = e.getReason(); } if (message == null) { message = ""; } if (e instanceof MethodFailedException) { MethodFailedException ex = ((MethodFailedException) e); Throwable realReason = ex.getReason(); if (realReason != null) { if (realReason instanceof NullPointerException) { message = "NullPointerException"; } else { message = realReason.getClass().getName() + ": " + message; } } message = message.replaceAll("java\\.lang\\.", ""); } return new InvalidExpressionException(message, cause); }
throw new MethodFailedException(source, methodName, reason);
private InvalidExpressionException invalidExpressionException(OgnlException e) { Throwable cause = e; String message = e.getMessage(); if (e.getReason() != null) { message = e.getReason().getMessage(); cause = e.getReason(); } if (message == null) { message = ""; } if (e instanceof MethodFailedException) { MethodFailedException ex = ((MethodFailedException) e); Throwable realReason = ex.getReason(); if (realReason != null) { if (realReason instanceof NullPointerException) { message = "NullPointerException"; } else { message = realReason.getClass().getName() + ": " + message; } } message = message.replaceAll("java\\.lang\\.", ""); } return new InvalidExpressionException(message, cause); }
objectArrayPool.recycle(actualArgs); throw new MethodFailedException( source, methodName, reason );
throw new MethodFailedException(source, methodName, reason);
invalidMethods.put(mc, Boolean.TRUE); } else if (reason != null) { throw new MethodFailedException(o, name, e.getReason());
throw new MethodFailedException(className, "new", reason);
throw new MethodFailedException( className, "new", reason );
throw new MethodFailedException(className, "new", reason);