javax.servlet.jsp.el.VariableResolver#javax.servlet.jsp.el.ELException源码实例Demo

下面列出了javax.servlet.jsp.el.VariableResolver#javax.servlet.jsp.el.ELException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public Expression parseExpression(String expression,
        @SuppressWarnings("rawtypes") Class expectedType,
        FunctionMapper fMapper) throws ELException {
    try {
        ELContextImpl ctx =
            new ELContextImpl(ELContextImpl.getDefaultResolver(factory));
        if (fMapper != null) {
            ctx.setFunctionMapper(new FunctionMapperImpl(fMapper));
        }
        ValueExpression ve = this.factory.createValueExpression(ctx, expression, expectedType);
        return new ExpressionImpl(ve, factory);
    } catch (javax.el.ELException e) {
        throw new ELParseException(e.getMessage());
    }
}
 
源代码2 项目: Tomcat7.0.67   文件: ExpressionEvaluatorImpl.java
@Override
public Expression parseExpression(String expression,
        @SuppressWarnings("rawtypes") // API does not use generics
        Class expectedType,
        FunctionMapper fMapper) throws ELException {
    try {
        ELContextImpl ctx =
            new ELContextImpl(ELContextImpl.getDefaultResolver());
        if (fMapper != null) {
            ctx.setFunctionMapper(new FunctionMapperImpl(fMapper));
        }
        ValueExpression ve = this.factory.createValueExpression(ctx, expression, expectedType);
        return new ExpressionImpl(ve);
    } catch (javax.el.ELException e) {
        throw new ELParseException(e.getMessage());
    }
}
 
源代码3 项目: tomcatsrc   文件: ExpressionEvaluatorImpl.java
@Override
public Expression parseExpression(String expression,
        @SuppressWarnings("rawtypes") // API does not use generics
        Class expectedType,
        FunctionMapper fMapper) throws ELException {
    try {
        ELContextImpl ctx =
            new ELContextImpl(ELContextImpl.getDefaultResolver());
        if (fMapper != null) {
            ctx.setFunctionMapper(new FunctionMapperImpl(fMapper));
        }
        ValueExpression ve = this.factory.createValueExpression(ctx, expression, expectedType);
        return new ExpressionImpl(ve);
    } catch (javax.el.ELException e) {
        throw new ELParseException(e.getMessage());
    }
}
 
源代码4 项目: packagedrone   文件: ExpressionEvaluatorImpl.java
public Expression parseExpression(String expression,
                                  Class expectedType,
                                  FunctionMapper fMapper )
        throws ELException {

    ExpressionFactory fac = ExpressionFactory.newInstance();
    javax.el.ValueExpression expr;
    ELContextImpl elContext = new ELContextImpl(null);
    javax.el.FunctionMapper fm = new FunctionMapperWrapper(fMapper);
    elContext.setFunctionMapper(fm);
    try {
        expr = fac.createValueExpression(
                       elContext,
                       expression, expectedType);
    } catch (javax.el.ELException ex) {
        throw new ELException(ex);
    }
    return new ExpressionImpl(expr, pageContext);
}
 
源代码5 项目: packagedrone   文件: ExpressionEvaluatorImpl.java
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);
            }
        }
 
源代码6 项目: Tomcat8-Source-Read   文件: JspContextWrapper.java
/**
 * VariableResolver interface
 */
@Override
@Deprecated
public Object resolveVariable(String pName) throws ELException {
    ELContext ctx = this.getELContext();
    return ctx.getELResolver().getValue(ctx, null, pName);
}
 
@Override
public Object evaluate(String expression,
        @SuppressWarnings("rawtypes") Class expectedType,
        VariableResolver vResolver, FunctionMapper fMapper)
        throws ELException {
    return this.parseExpression(expression, expectedType, fMapper).evaluate(vResolver);
}
 
源代码8 项目: Tomcat7.0.67   文件: JspContextWrapper.java
/**
 * VariableResolver interface
 */
@Override
@Deprecated
public Object resolveVariable(String pName) throws ELException {
    ELContext ctx = this.getELContext();
    return ctx.getELResolver().getValue(ctx, null, pName);
}
 
源代码9 项目: Tomcat7.0.67   文件: ExpressionEvaluatorImpl.java
@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);
}
 
源代码10 项目: tomcatsrc   文件: JspContextWrapper.java
/**
 * VariableResolver interface
 */
@Override
@Deprecated
public Object resolveVariable(String pName) throws ELException {
    ELContext ctx = this.getELContext();
    return ctx.getELResolver().getValue(ctx, null, pName);
}
 
源代码11 项目: tomcatsrc   文件: ExpressionEvaluatorImpl.java
@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);
}
 
源代码12 项目: packagedrone   文件: ExpressionEvaluatorImpl.java
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;
}
 
源代码13 项目: packagedrone   文件: ExpressionEvaluatorImpl.java
public Object getValue(ELContext context,
                       Object base,
                       Object property)
        throws javax.el.ELException {
    if (base == null) {
        context.setPropertyResolved(true);
        try {
            return vResolver.resolveVariable(property.toString());
        } catch (ELException ex) {
            throw new javax.el.ELException(ex);
        }
    }
    return null;
}
 
源代码14 项目: datacollector   文件: ELEvaluator.java
public static void parseEL(String el) throws ELEvalException {
  try {
    EVALUATOR.parseExpressionString(el);
  } catch (ELException e) {
    LOG.debug("Error parsering EL '{}': {}", el, e.toString(), e);
    throw new ELEvalException(ContainerCommonError.CTRCMN_0101, el, e.toString(), e);
  }
}
 
源代码15 项目: datacollector   文件: ELEvaluator.java
@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);
  }
}
 
源代码16 项目: datacollector   文件: UpgraderAction.java
private String evaluate (final Map<String, Object> configs, String expression) throws
    ELEvalException {
  try {
    CONFIGS_TL.set(configs);
    return (String) EVALUATOR.evaluate(
        expression,
        String.class,
        name -> null,
        (prefix, name) -> (prefix.equals("") && name.equals("value")) ? CONFIG_VALUE_FUNCTION : null
    );
  } 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(Errors.YAML_UPGRADER_12.getMessage(), getName(), expression, t.toString(), e);
    throw new ELEvalException(Errors.YAML_UPGRADER_12, getName(), expression, t.toString());
  } finally {
    CONFIGS_TL.remove();
  }
}
 
源代码17 项目: Tomcat8-Source-Read   文件: VariableResolverImpl.java
@Override
public Object resolveVariable(String pName) throws ELException {
    return this.ctx.getELResolver().getValue(this.ctx, null, pName);
}
 
源代码18 项目: Tomcat8-Source-Read   文件: ExpressionImpl.java
@Override
public Object evaluate(VariableResolver vResolver) throws ELException {
    ELContext ctx =
            new ELContextImpl(new ELResolverImpl(vResolver, factory));
    return ve.getValue(ctx);
}
 
源代码19 项目: Tomcat7.0.67   文件: PageContextImpl.java
private void doHandlePageException(Throwable t) throws IOException,
        ServletException {

    if (errorPageURL != null && !errorPageURL.equals("")) {

        /*
         * Set request attributes. Do not set the
         * javax.servlet.error.exception attribute here (instead, set in the
         * generated servlet code for the error page) in order to prevent
         * the ErrorReportValve, which is invoked as part of forwarding the
         * request to the error page, from throwing it if the response has
         * not been committed (the response will have been committed if the
         * error page is a JSP page).
         */
        request.setAttribute(PageContext.EXCEPTION, t);
        request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,
                Integer.valueOf(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
        request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI,
                ((HttpServletRequest) request).getRequestURI());
        request.setAttribute(RequestDispatcher.ERROR_SERVLET_NAME,
                config.getServletName());
        try {
            forward(errorPageURL);
        } catch (IllegalStateException ise) {
            include(errorPageURL);
        }

        // The error page could be inside an include.

        Object newException =
                request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);

        // t==null means the attribute was not set.
        if ((newException != null) && (newException == t)) {
            request.removeAttribute(RequestDispatcher.ERROR_EXCEPTION);
        }

        // now clear the error code - to prevent double handling.
        request.removeAttribute(RequestDispatcher.ERROR_STATUS_CODE);
        request.removeAttribute(RequestDispatcher.ERROR_REQUEST_URI);
        request.removeAttribute(RequestDispatcher.ERROR_SERVLET_NAME);
        request.removeAttribute(PageContext.EXCEPTION);

    } else {
        // Otherwise throw the exception wrapped inside a ServletException.
        // Set the exception as the root cause in the ServletException
        // to get a stack trace for the real problem
        if (t instanceof IOException)
            throw (IOException) t;
        if (t instanceof ServletException)
            throw (ServletException) t;
        if (t instanceof RuntimeException)
            throw (RuntimeException) t;

        Throwable rootCause = null;
        if (t instanceof JspException) {
            rootCause = ((JspException) t).getCause();
        } else if (t instanceof ELException) {
            rootCause = ((ELException) t).getCause();
        }

        if (rootCause != null) {
            throw new ServletException(t.getClass().getName() + ": "
                    + t.getMessage(), rootCause);
        }

        throw new ServletException(t);
    }
}
 
源代码20 项目: Tomcat7.0.67   文件: VariableResolverImpl.java
@Override
public Object resolveVariable(String pName) throws ELException {
    return this.ctx.getELResolver().getValue(this.ctx, null, pName);
}
 
源代码21 项目: Tomcat7.0.67   文件: ExpressionImpl.java
@Override
public Object evaluate(VariableResolver vResolver) throws ELException {
    ELContext ctx = new ELContextImpl(new ELResolverImpl(vResolver));
    return ve.getValue(ctx);
}
 
源代码22 项目: tomcatsrc   文件: PageContextImpl.java
private void doHandlePageException(Throwable t) throws IOException,
        ServletException {

    if (errorPageURL != null && !errorPageURL.equals("")) {

        /*
         * Set request attributes. Do not set the
         * javax.servlet.error.exception attribute here (instead, set in the
         * generated servlet code for the error page) in order to prevent
         * the ErrorReportValve, which is invoked as part of forwarding the
         * request to the error page, from throwing it if the response has
         * not been committed (the response will have been committed if the
         * error page is a JSP page).
         */
        request.setAttribute(PageContext.EXCEPTION, t);
        request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,
                Integer.valueOf(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
        request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI,
                ((HttpServletRequest) request).getRequestURI());
        request.setAttribute(RequestDispatcher.ERROR_SERVLET_NAME,
                config.getServletName());
        try {
            forward(errorPageURL);
        } catch (IllegalStateException ise) {
            include(errorPageURL);
        }

        // The error page could be inside an include.

        Object newException =
                request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);

        // t==null means the attribute was not set.
        if ((newException != null) && (newException == t)) {
            request.removeAttribute(RequestDispatcher.ERROR_EXCEPTION);
        }

        // now clear the error code - to prevent double handling.
        request.removeAttribute(RequestDispatcher.ERROR_STATUS_CODE);
        request.removeAttribute(RequestDispatcher.ERROR_REQUEST_URI);
        request.removeAttribute(RequestDispatcher.ERROR_SERVLET_NAME);
        request.removeAttribute(PageContext.EXCEPTION);

    } else {
        // Otherwise throw the exception wrapped inside a ServletException.
        // Set the exception as the root cause in the ServletException
        // to get a stack trace for the real problem
        if (t instanceof IOException)
            throw (IOException) t;
        if (t instanceof ServletException)
            throw (ServletException) t;
        if (t instanceof RuntimeException)
            throw (RuntimeException) t;

        Throwable rootCause = null;
        if (t instanceof JspException) {
            rootCause = ((JspException) t).getCause();
        } else if (t instanceof ELException) {
            rootCause = ((ELException) t).getCause();
        }

        if (rootCause != null) {
            throw new ServletException(t.getClass().getName() + ": "
                    + t.getMessage(), rootCause);
        }

        throw new ServletException(t);
    }
}
 
源代码23 项目: tomcatsrc   文件: VariableResolverImpl.java
@Override
public Object resolveVariable(String pName) throws ELException {
    return this.ctx.getELResolver().getValue(this.ctx, null, pName);
}
 
源代码24 项目: tomcatsrc   文件: ExpressionImpl.java
@Override
public Object evaluate(VariableResolver vResolver) throws ELException {
    ELContext ctx = new ELContextImpl(new ELResolverImpl(vResolver));
    return ve.getValue(ctx);
}
 
源代码25 项目: packagedrone   文件: ExpressionEvaluatorImpl.java
public Class getType(ELContext context,
                     Object base,
                     Object property)
        throws javax.el.ELException {
    return null;
}
 
源代码26 项目: packagedrone   文件: ExpressionEvaluatorImpl.java
public void setValue(ELContext context,
                     Object base,
                     Object property,
                     Object value)
        throws javax.el.ELException {
}
 
源代码27 项目: packagedrone   文件: ExpressionEvaluatorImpl.java
public boolean isReadOnly(ELContext context,
                          Object base,
                          Object property)
        throws javax.el.ELException {
    return false;
}
 
源代码28 项目: Benchmark   文件: ExpressionEvaluator.java
@Override
public Object evaluate(String arg0, Class arg1, VariableResolver arg2, FunctionMapper arg3) throws ELException {
	return null;
}
 
源代码29 项目: Benchmark   文件: ExpressionEvaluator.java
@Override
public Expression parseExpression(String arg0, Class arg1, FunctionMapper arg2) throws ELException {
	return null;
}