use of javax.el.ValueReference in project tomcat by apache.
the class TestValueExpressionImpl method testGetValueReference.
@Test
public void testGetValueReference() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
ValueExpression var = factory.createValueExpression(beanB, TesterBeanB.class);
context.getVariableMapper().setVariable("beanB", var);
ValueExpression ve = factory.createValueExpression(context, "${beanB.name}", String.class);
// First check the basics work
String result = (String) ve.getValue(context);
assertEquals("Tomcat", result);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
assertNotNull(vr);
assertEquals(beanB, vr.getBase());
assertEquals("name", vr.getProperty());
}
use of javax.el.ValueReference in project tomcat by apache.
the class TestValueExpressionImpl method testBug49345.
@Test
public void testBug49345() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
TesterBeanA beanA = new TesterBeanA();
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
beanA.setBean(beanB);
ValueExpression var = factory.createValueExpression(beanA, TesterBeanA.class);
context.getVariableMapper().setVariable("beanA", var);
ValueExpression ve = factory.createValueExpression(context, "${beanA.bean.name}", String.class);
// First check the basics work
String result = (String) ve.getValue(context);
assertEquals("Tomcat", result);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
assertNotNull(vr);
assertEquals(beanB, vr.getBase());
assertEquals("name", vr.getProperty());
}
use of javax.el.ValueReference in project oxCore by GluuFederation.
the class ValueExpressionAnalyzer method getValueReference.
public ValueReference getValueReference(ELContext elContext) {
InterceptingResolver resolver = new InterceptingResolver(elContext.getELResolver());
try {
expression.setValue(decorateELContext(elContext, resolver), null);
} catch (ELException ele) {
return null;
}
ValueReference reference = resolver.getValueReference();
if (reference != null) {
Object base = reference.getBase();
if (base instanceof CompositeComponentExpressionHolder) {
ValueExpression ve = ((CompositeComponentExpressionHolder) base).getExpression((String) reference.getProperty());
if (ve != null) {
this.expression = ve;
reference = getValueReference(elContext);
}
}
}
return reference;
}
use of javax.el.ValueReference in project tomcat by apache.
the class TestValueExpressionImpl method testGetValueReferenceVariable.
@Test
public void testGetValueReferenceVariable() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
ValueExpression var = factory.createValueExpression(beanB, TesterBeanB.class);
context.getVariableMapper().setVariable("beanB", var);
ValueExpression var2 = factory.createValueExpression(context, "${beanB.name}", String.class);
context.getVariableMapper().setVariable("foo", var2);
ValueExpression ve = factory.createValueExpression(context, "${foo}", ValueExpression.class);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
assertNotNull(vr);
assertEquals(beanB, vr.getBase());
assertEquals("name", vr.getProperty());
}
use of javax.el.ValueReference in project tomcat by apache.
the class ValueExpressionImpl method getValueReference.
/**
* @since EL 2.2
*/
@Override
public ValueReference getValueReference(ELContext context) {
EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper);
context.notifyBeforeEvaluation(getExpressionString());
ValueReference result = this.getNode().getValueReference(ctx);
context.notifyAfterEvaluation(getExpressionString());
return result;
}
Aggregations