javax.servlet.jsp.el.VariableResolver Java Examples

The following examples show how to use javax.servlet.jsp.el.VariableResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExpressionEvaluatorImpl.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public Object evaluate(VariableResolver vResolver) throws ELException {

            ELContext elContext;
            if (vResolver instanceof VariableResolverImpl) {
                elContext = pageContext.getELContext();
            }
            else {
                // The provided variable Resolver is a custom resolver,
                // wrap it with a ELResolver 
                elContext = new ELContextImpl(new ELResolverWrapper(vResolver));
            }
            try {
                return valueExpr.getValue(elContext);
            } catch (javax.el.ELException ex) {
                throw new ELException(ex);
            }
        }
 
Example #2
Source File: ExpressionEvaluatorImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public Object evaluate(String expression,
        @SuppressWarnings("rawtypes") Class expectedType,
        VariableResolver vResolver, FunctionMapper fMapper)
        throws ELException {
    return this.parseExpression(expression, expectedType, fMapper).evaluate(vResolver);
}
 
Example #3
Source File: ExpressionEvaluatorImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public Object evaluate(String expression,
        @SuppressWarnings("rawtypes") // API does not use generics
        Class expectedType,
        VariableResolver vResolver, FunctionMapper fMapper)
        throws ELException {
    return this.parseExpression(expression, expectedType, fMapper).evaluate(vResolver);
}
 
Example #4
Source File: ELEvaluator.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <T> T evaluate (final ELVars vars, String expression, Class<T> returnType) throws ELEvalException {
  VariableResolver variableResolver = new VariableResolver() {

    @Override
    public Object resolveVariable(String name) throws ELException {
      Object value = constants.get(name);
      if (!vars.hasVariable(name)) {
        if (value == null && !constants.containsKey(name)) {
          throw new ELException(Utils.format("Constants/Variable '{}' cannot be resolved", name));
        }
      } else {
        value = vars.getVariable(name);
      }
      return value;
    }
  };
  try {
    return (T) EVALUATOR.evaluate(expression, returnType, variableResolver, functionMapper);
  } catch (ELException e) {
    // Apache evaluator is not using the getCause exception chaining that is available in Java but rather a custom
    // chaining mechanism. This doesn't work well for us as we're effectively swallowing the cause that is not
    // available in log, ...
    Throwable t = e;
    if(e.getRootCause() != null) {
      t = e.getRootCause();
      if(e.getCause() == null) {
        e.initCause(t);
      }
    }
    LOG.debug("Error valuating EL '{}': {}", expression, e.toString(), e);
    throw new ELEvalException(ContainerCommonError.CTRCMN_0100, expression, t.toString(), e);
  }
}
 
Example #5
Source File: ExpressionEvaluatorImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public Object evaluate(String expression,
        @SuppressWarnings("rawtypes") // API does not use generics
        Class expectedType,
        VariableResolver vResolver, FunctionMapper fMapper)
        throws ELException {
    return this.parseExpression(expression, expectedType, fMapper).evaluate(vResolver);
}
 
Example #6
Source File: ExpressionEvaluatorImpl.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public Object evaluate(String expression,
                        Class expectedType,
                        VariableResolver vResolver,
                        FunctionMapper fMapper )
            throws ELException {

    ELContextImpl elContext;
    if (vResolver instanceof VariableResolverImpl) {
        elContext = (ELContextImpl) pageContext.getELContext();
    }
    else {
        // The provided variable Resolver is a custom resolver,
        // wrap it with a ELResolver 
        elContext = new ELContextImpl(new ELResolverWrapper(vResolver));
    }

    javax.el.FunctionMapper fm = new FunctionMapperWrapper(fMapper);
    elContext.setFunctionMapper(fm);
    ExpressionFactory fac = ExpressionFactory.newInstance();
    Object value;
    try {
        ValueExpression expr = fac.createValueExpression(
                             elContext,
                             expression,
                             expectedType);
        value = expr.getValue(elContext);
    } catch (javax.el.ELException ex) {
        throw new ELException(ex);
    }
    return value;
}
 
Example #7
Source File: DummyPageContext.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public VariableResolver getVariableResolver()
{
  throw new UnsupportedOperationException();
}
 
Example #8
Source File: JspContextWrapper.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
@Deprecated
public VariableResolver getVariableResolver() {
    return this;
}
 
Example #9
Source File: PageContextAdaptor.java    From sinavi-jfw with Apache License 2.0 4 votes vote down vote up
@Override
public VariableResolver getVariableResolver() {

    return null;
}
 
Example #10
Source File: FakePageContext.java    From Bootstrap.jsp with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public VariableResolver getVariableResolver() {
	// TODO Auto-generated method stub
	return null;
}
 
Example #11
Source File: FakePageContext.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Override
public VariableResolver getVariableResolver() {
  throw new UnsupportedOperationException();
}
 
Example #12
Source File: ExpressionEvaluator.java    From Benchmark with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Object evaluate(String arg0, Class arg1, VariableResolver arg2, FunctionMapper arg3) throws ELException {
	return null;
}
 
Example #13
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
public VariableResolver getVariableResolver() {
    return new VariableResolverImpl(this);
}
 
Example #14
Source File: JspContextWrapper.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
public VariableResolver getVariableResolver() {
return null;
   }
 
Example #15
Source File: ExpressionEvaluatorImpl.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
ELResolverWrapper(VariableResolver vResolver) {
    this.vResolver = vResolver;
}
 
Example #16
Source File: ELResolverImpl.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public ELResolverImpl(VariableResolver variableResolver) {
    this.variableResolver = variableResolver;
    this.elResolver = ELContextImpl.getDefaultResolver();
}
 
Example #17
Source File: ExpressionImpl.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public Object evaluate(VariableResolver vResolver) throws ELException {
    ELContext ctx = new ELContextImpl(new ELResolverImpl(vResolver));
    return ve.getValue(ctx);
}
 
Example #18
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
@Deprecated
public VariableResolver getVariableResolver() {
    return new VariableResolverImpl(this.getELContext());
}
 
Example #19
Source File: JspContextWrapper.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
@Deprecated
public VariableResolver getVariableResolver() {
    return this;
}
 
Example #20
Source File: ELResolverImpl.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public ELResolverImpl(VariableResolver variableResolver) {
    this.variableResolver = variableResolver;
    this.elResolver = ELContextImpl.getDefaultResolver();
}
 
Example #21
Source File: ExpressionImpl.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public Object evaluate(VariableResolver vResolver) throws ELException {
    ELContext ctx = new ELContextImpl(new ELResolverImpl(vResolver));
    return ve.getValue(ctx);
}
 
Example #22
Source File: PageContextImpl.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
@Deprecated
public VariableResolver getVariableResolver() {
    return new VariableResolverImpl(this.getELContext());
}
 
Example #23
Source File: JspContextWrapper.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
@Deprecated
public VariableResolver getVariableResolver() {
    return this;
}
 
Example #24
Source File: ELResolverImpl.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public ELResolverImpl(VariableResolver variableResolver,
        ExpressionFactory factory) {
    this.variableResolver = variableResolver;
    this.elResolver = ELContextImpl.getDefaultResolver(factory);
}
 
Example #25
Source File: ExpressionImpl.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public Object evaluate(VariableResolver vResolver) throws ELException {
    ELContext ctx =
            new ELContextImpl(new ELResolverImpl(vResolver, factory));
    return ve.getValue(ctx);
}
 
Example #26
Source File: JspContext.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns an instance of a VariableResolver that provides access to the
 * implicit objects specified in the JSP specification using this JspContext
 * as the context object.
 *
 * @deprecated As of JSP 2.1, replaced by {@link ELContext#getELResolver},
 *     which can be obtained by 
 *     <code>jspContext.getELContext().getELResolver()</code>.
 * @return A valid instance of a VariableResolver.
 * @since JSP 2.0
 */
public abstract VariableResolver getVariableResolver();