use of javax.el.MethodExpression in project tomcat by apache.
the class AstIdentifier method getMethodExpression.
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);
}
}
// 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());
}
}
use of javax.el.MethodExpression in project tomcat by apache.
the class TestMethodExpressionImpl method testBug57855b.
@Test(expected = IllegalArgumentException.class)
public void testBug57855b() {
MethodExpression me = factory.createMethodExpression(context, "${beanAA.echo2}", null, new Class[] { String.class });
me.invoke(context, null);
}
use of javax.el.MethodExpression in project tomcat by apache.
the class TestMethodExpressionImpl method testInvokeWithVarArgsAAAB.
@Test
public void testInvokeWithVarArgsAAAB() throws Exception {
MethodExpression me7 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanB,beanB)}", null, null);
Exception e = null;
try {
me7.invoke(context, null);
} catch (Exception e1) {
e = e1;
}
// Expected to fail
assertNotNull(e);
}
use of javax.el.MethodExpression in project tomcat by apache.
the class TestMethodExpressionImpl method testBug52970.
@Test
public void testBug52970() {
MethodExpression me = factory.createMethodExpression(context, "${beanEnum.submit('APPLE')}", null, new Class<?>[] { TesterBeanEnum.class });
me.invoke(context, null);
ValueExpression ve = factory.createValueExpression(context, "#{beanEnum.lastSubmitted}", TesterEnum.class);
TesterEnum actual = (TesterEnum) ve.getValue(context);
assertEquals(TesterEnum.APPLE, actual);
}
use of javax.el.MethodExpression in project tomcat by apache.
the class TestMethodExpressionImpl method testInvokeWithVarArgsAAABBB.
@Test
public void testInvokeWithVarArgsAAABBB() throws Exception {
MethodExpression me9 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanBBB,beanBBB)}", null, null);
Object r9 = me9.invoke(context, null);
assertEquals("ABB[]: Hello AAA from BBB, BBB", r9.toString());
}
Aggregations