Java 类javax.el.StandardELContext 实例源码

项目:fauxjsp    文件:TestEL.java   
@Test
public void testBasicEL(){

    JspPage page = new JspPage("testpath", new CodeLocation("testpath", 1, 1));
    ExpressionFactory expressionFactory = ExpressionFactory.newInstance();
    StandardELContext elContext = new StandardELContext(expressionFactory);
    elContext.getVariableMapper().setVariable("page", expressionFactory.createValueExpression(page, JspPage.class));

    ValueExpression expr = expressionFactory.createValueExpression(elContext, "${page.name}", String.class);
    Object result = expr.getValue(elContext);
    assertEquals("testpath", result );
}
项目:fauxjsp    文件:TestEL.java   
@Test
public void testELWithString(){

    JspPage page = new JspPage("testpath", new CodeLocation("testpath", 1, 1));
    ExpressionFactory expressionFactory = ExpressionFactory.newInstance();
    StandardELContext elContext = new StandardELContext(expressionFactory);
    elContext.getVariableMapper().setVariable("page", expressionFactory.createValueExpression(page, JspPage.class));

    ValueExpression expr = expressionFactory.createValueExpression(elContext, "The page name is ${page.name}", String.class);
    Object result = expr.getValue(elContext);
    assertEquals("The page name is testpath", result    );
}
项目:fauxjsp    文件:ELFactoryServlet3Impl.java   
@Override
public ELContext newElContext() {
    ELContext context = new StandardELContext(newExpressionFactory());
    setupFunctions(context);
    return context;
}
项目:protobuf-el    文件:ELContextEx.java   
private void init() {
  final StandardELContext context = new StandardELContext(factory);
  functionMapper = context.getFunctionMapper();
  variableMapper = context.getVariableMapper();
}