}
// if invalid OGNL then fail
if (OgnlHelper.isInvalidValidOgnlExpression(method)) {
ExpressionIllegalSyntaxException cause = new ExpressionIllegalSyntaxException(method);
throw ObjectHelper.wrapRuntimeCamelException(new MethodNotFoundException(bean != null ? bean : type, method, cause));
}
if (bean != null) {
BeanInfo info = new BeanInfo(context, bean.getClass());
if (!info.hasMethod(method)) {
throw ObjectHelper.wrapRuntimeCamelException(new MethodNotFoundException(null, bean, method));
}
} else {
BeanInfo info = new BeanInfo(context, type);
// must be a static method as we do not have a bean instance to invoke
if (!info.hasStaticMethod(method)) {
throw ObjectHelper.wrapRuntimeCamelException(new MethodNotFoundException(null, type, method, true));
}
}
}