本文整理汇总了Java中javax.el.MethodNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java MethodNotFoundException类的具体用法?Java MethodNotFoundException怎么用?Java MethodNotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodNotFoundException类属于javax.el包,在下文中一共展示了MethodNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeTarget
import javax.el.MethodNotFoundException; //导入依赖的package包/类
private final Object invokeTarget(EvaluationContext ctx, Object target,
Object[] paramValues) throws ELException {
if (target instanceof MethodExpression) {
MethodExpression me = (MethodExpression) target;
return me.invoke(ctx.getELContext(), paramValues);
} else if (target == null) {
throw new MethodNotFoundException("Identity '" + this.image
+ "' was null and was unable to invoke");
} else {
throw new ELException(
"Identity '"
+ this.image
+ "' does not reference a MethodExpression instance, returned type: "
+ target.getClass().getName());
}
}
示例2: getMethod
import javax.el.MethodNotFoundException; //导入依赖的package包/类
/**
* Returns a method based on the criteria
* @param base the object that owns the method
* @param property the name of the method
* @param paramTypes the parameter types to use
* @return the method specified
* @throws MethodNotFoundException
*/
public static Method getMethod(Object base, Object property,
Class[] paramTypes) throws MethodNotFoundException {
if (base == null || property == null) {
throw new MethodNotFoundException(MessageFactory.get(
"error.method.notfound", base, property,
paramString(paramTypes)));
}
String methodName = (property instanceof String) ? (String) property
: property.toString();
Method method = null;
try {
method = base.getClass().getMethod(methodName, paramTypes);
} catch (NoSuchMethodException nsme) {
throw new MethodNotFoundException(MessageFactory.get(
"error.method.notfound", base, property,
paramString(paramTypes)));
}
return method;
}
示例3: testEvaluate_lambda
import javax.el.MethodNotFoundException; //导入依赖的package包/类
/**
* ラムダ式のテスト - EL2.xでは非さぽーとのため失敗する
*/
@Test(expected=ExpressionEvaluationException.class)
public void testEvaluate_lambda() {
String expression = "sum=0;list.stream().forEach(x->(sum=sum+x));sum";
Map<String, Object> vars = new HashMap<>();
vars.put("list", Arrays.asList(1, 2, 3, 4, 5, 6));
try {
el.evaluate(expression, vars);
fail();
} catch(Exception e) {
assertThat(e, is(instanceOf(ExpressionEvaluationException.class)));
assertThat(e.getCause(), is(instanceOf(MethodNotFoundException.class)));
throw e;
}
}
示例4: findMethod
import javax.el.MethodNotFoundException; //导入依赖的package包/类
public static Method findMethod(Object base, Object name, Object[] params) {
Method r = null;
if (base != null && name != null) {
Class type = base.getClass();
String methodName = ELSupport.coerceToString(name);
MethodCache m = methodCache.get(type);
// if (m == null || type != m.getType()) {
// m = new MethodCache(type);
// methodCache.set(type, m);
// }
r = m.findMethod(methodName, params);
if (r == null) {
throw new MethodNotFoundException(MessageFactory.get(
"error.method.notfound", base, name,
paramString(paramTypes(params))));
}
} else {
throw new MethodNotFoundException();
}
return r;
}
示例5: getMethod
import javax.el.MethodNotFoundException; //导入依赖的package包/类
/**
* Returns a method based on the criteria
*
* @param base
* the object that owns the method
* @param property
* the name of the method
* @param paramTypes
* the parameter types to use
* @return the method specified
* @throws MethodNotFoundException
*/
public static Method getMethod(Object base, Object property,
Class[] paramTypes) throws MethodNotFoundException {
if (base == null || property == null) {
throw new MethodNotFoundException(MessageFactory.get(
"error.method.notfound", base, property,
paramString(paramTypes)));
}
String methodName = (property instanceof String) ? (String) property
: property.toString();
Method method = null;
try {
method = base.getClass().getMethod(methodName, paramTypes);
} catch (NoSuchMethodException nsme) {
throw new MethodNotFoundException(MessageFactory.get(
"error.method.notfound", base, property,
paramString(paramTypes)));
}
return method;
}
示例6: getMethodExpression
import javax.el.MethodNotFoundException; //导入依赖的package包/类
private final MethodExpression getMethodExpression(EvaluationContext ctx)
throws ELException {
Object obj = null;
// case A: ValueExpression exists, getValue which must
// be a MethodExpression
VariableMapper varMapper = ctx.getVariableMapper();
ValueExpression ve = null;
if (varMapper != null) {
ve = varMapper.resolveVariable(this.image);
if (ve != null) {
obj = ve.getValue(ctx);
}
}
// case B: evaluate the identity against the ELResolver, again, must be
// a MethodExpression to be able to invoke
if (ve == null) {
ctx.setPropertyResolved(false);
obj = ctx.getELResolver().getValue(ctx, null, this.image);
}
// finally provide helpful hints
if (obj instanceof MethodExpression) {
return (MethodExpression) obj;
} else if (obj == null) {
throw new MethodNotFoundException("Identity '" + this.image
+ "' was null and was unable to invoke");
} else {
throw new ELException(
"Identity '"
+ this.image
+ "' does not reference a MethodExpression instance, returned type: "
+ obj.getClass().getName());
}
}
示例7: getMethodExpression
import javax.el.MethodNotFoundException; //导入依赖的package包/类
private final MethodExpression getMethodExpression(EvaluationContext ctx) throws ELException {
Object obj = null;
// case A: ValueExpression exists, getValue which must
// be a MethodExpression
VariableMapper varMapper = ctx.getVariableMapper();
ValueExpression ve = null;
if (varMapper != null) {
ve = varMapper.resolveVariable(this.image);
if (ve != null) {
obj = ve.getValue(ctx);
}
}
// case B: evaluate the identity against the ELResolver, again, must be
// a MethodExpression to be able to invoke
if (ve == null) {
ctx.setPropertyResolved(false);
obj = ctx.getELResolver().getValue(ctx, null, this.image);
}
// finally provide helpful hints
if (obj instanceof MethodExpression) {
return (MethodExpression) obj;
} else if (obj == null) {
throw new MethodNotFoundException("Identity '" + this.image + "' was null and was unable to invoke");
} else {
throw new ELException("Identity '" + this.image
+ "' does not reference a MethodExpression instance, returned type: " + obj.getClass().getName());
}
}
示例8: invoke
import javax.el.MethodNotFoundException; //导入依赖的package包/类
@Override
public Object invoke(final ELContext context, final Object base, final Object method,
final Class<?>[] paramTypes, final Object[] params) {
if (resolveType(base)) {
if (isStrictMode) {
throw new MethodNotFoundException();
}
}
return null;
}
示例9: findMethodOrThrow
import javax.el.MethodNotFoundException; //导入依赖的package包/类
protected Method findMethodOrThrow(final String methodName, final Class<?>[] paramTypes,
final Object[] params, final boolean staticOnly, final MethodDescriptor[] methodDescriptors) {
final Method method = findMethod(methodName, paramTypes, params, staticOnly, methodDescriptors);
if (method == null) {
throw new MethodNotFoundException("Method " + methodName + "for bean class "
+ "not found or accessible");
}
return method;
}
示例10: invoke
import javax.el.MethodNotFoundException; //导入依赖的package包/类
@Override
public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) {
if (method == null || RESTRICTED_METHODS.contains(method.toString())) {
throw new MethodNotFoundException("Cannot find method '" + method + "' in " + base.getClass());
}
return super.invoke(context, base, method, paramTypes, params);
}
示例11: getMethodExpression
import javax.el.MethodNotFoundException; //导入依赖的package包/类
private final MethodExpression getMethodExpression(EvaluationContext ctx)
throws ELException {
Object obj = null;
// case A: ValueExpression exists, getValue which must
// be a MethodExpression
VariableMapper varMapper = ctx.getVariableMapper();
ValueExpression ve = null;
if (varMapper != null) {
ve = varMapper.resolveVariable(this.image);
if (ve != null) {
obj = ve.getValue(ctx);
}
}
// case B: evaluate the identity against the ELResolver, again, must be
// a MethodExpression to be able to invoke
if (ve == null) {
ctx.setPropertyResolved(false);
obj = ctx.getELResolver().getValue(ctx, null, this.image);
}
// finally provide helpful hints
if (obj instanceof MethodExpression) {
return (MethodExpression) obj;
} else if (obj == null) {
throw new MethodNotFoundException("Identity '" + this.image
+ "' was null and was unable to invoke");
} else {
throw new ELException(
"Identity '"
+ this.image
+ "' does not reference a MethodExpression instance, returned type: "
+ obj.getClass().getName());
}
}
示例12: JspMethodNotFoundException
import javax.el.MethodNotFoundException; //导入依赖的package包/类
public JspMethodNotFoundException(String mark, MethodNotFoundException e) {
super(mark + " " + e.getMessage(), e.getCause());
}
示例13: testBug54370a
import javax.el.MethodNotFoundException; //导入依赖的package包/类
@Test(expected=MethodNotFoundException.class)
public void testBug54370a() {
ReflectionUtil.getMethod(BASE, "testA",
new Class[] {null, String.class},
new Object[] {null, ""});
}
示例14: testBug54370b
import javax.el.MethodNotFoundException; //导入依赖的package包/类
@Test(expected=MethodNotFoundException.class)
public void testBug54370b() {
ReflectionUtil.getMethod(BASE, "testB",
new Class[] {null, String.class},
new Object[] {null, ""});
}
示例15: JspMethodNotFoundException
import javax.el.MethodNotFoundException; //导入依赖的package包/类
public JspMethodNotFoundException(String mark, MethodNotFoundException e) {
super(mark + " " + e.getMessage(), e.getCause());
}