Package org.apache.commons.jexl

Examples of org.apache.commons.jexl.JexlContext


   * (java.lang.String)
   */
  public boolean resolveBooleanExpression(Map<String ,Object> vars, String elExpression)
      throws Exception {
    Expression expression = ExpressionFactory.createExpression(elExpression);
    JexlContext jexlCtx = JexlHelper.createContext();
    jexlCtx.setVars(vars);
    Object obj = expression.evaluate(jexlCtx);
    return (Boolean) obj;
  }
View Full Code Here


            log.debug("Evaluating expression: " + expression);
        }

        Expression expr = ExpressionFactory.createExpression(expression);

        JexlContext ctx = JexlHelper.createContext();
        ctx.setVars(vars);

        Object result = expr.evaluate(ctx);
        if (debug) {
            log.debug("Result: " + result);
        }
View Full Code Here

            log.debug("Evaluating expression: " + expression);
        }

        Expression expr = ExpressionFactory.createExpression(expression);

        JexlContext ctx = JexlHelper.createContext();
        ctx.setVars(vars);

        Object result = expr.evaluate(ctx);
        if (debug) {
            log.debug("Result: " + result);
        }
View Full Code Here

            public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
                if (method.getAnnotation(Callback.class) != null) {
                    try {
                        Expression e = ExpressionFactory.createExpression(
                                method.getAnnotation(Callback.class).condition());
                        JexlContext jc = JexlHelper.createContext();
                        jc.getVars().put("this", obj);
                        Object r = e.evaluate(jc);
                        if (!(r instanceof Boolean)) {
                            throw new RuntimeException("Expression did not returned a boolean value but: " + r);
                        }
                        Boolean oldVal = req.getCallbacks().get(method);
View Full Code Here

        JMeterVariables vars = jmctx.getVariables();

        try
        {
            Script script = ScriptFactory.createScript(exp);
            JexlContext jc = JexlHelper.createContext();
            @SuppressWarnings("unchecked")
            final Map<String, Object> jexlVars = jc.getVars();
            jexlVars.put("log", log); //$NON-NLS-1$
            jexlVars.put("ctx", jmctx); //$NON-NLS-1$
            jexlVars.put("vars", vars); //$NON-NLS-1$
            jexlVars.put("props", JMeterUtils.getJMeterProperties()); //$NON-NLS-1$
            // Previously mis-spelt as theadName
View Full Code Here

            log.debug("Evaluating expression: " + expression);
        }

        Expression expr = ExpressionFactory.createExpression(expression);

        JexlContext ctx = JexlHelper.createContext();
        ctx.setVars(vars);

        Object result = expr.evaluate(ctx);
        if (debug) {
            log.debug("Result: " + result);
        }
View Full Code Here

               
                if (action instanceof TemplateAction) {
                  TemplateAction templateAction = (TemplateAction) action;
                  String templateName = templateAction.getTemplateName();
                    if (templateAction.isEvaluate()) {
                        JexlContext jc = JexlHelper.createContext();
                        jc.getVars().put("handler", handler);

                        templateName = "" + templateAction.getExpression().evaluate(jc);
                    }

          processTemplate(request, response, templateName, handler);
                    return true;
                }
               
                if (action instanceof DispatcherAction) {
                    request.setAttribute("handler", handler);
                    DispatcherAction location = (DispatcherAction) action;
          request.getRequestDispatcher(location.getLocation()).forward(request, response);
                    return true;
                }
               
                if (action instanceof RedirectAction) {
                    RedirectAction redirectAction = (RedirectAction) action;
                    String location = redirectAction.getLocation();
                    if (redirectAction.isEvaluate()) {
                        JexlContext jc = JexlHelper.createContext();
                        jc.getVars().put("handler", handler);

                        location = "" + redirectAction.getExpression().evaluate(jc);
                    }
                    response.sendRedirect(location);
                    return true;
View Full Code Here

        JMeterVariables vars = jmctx.getVariables();

        try
        {
            Script script = ScriptFactory.createScript(exp);
            JexlContext jc = JexlHelper.createContext();
            @SuppressWarnings("unchecked")
            final Map<String, Object> jexlVars = jc.getVars();
            jexlVars.put("log", log); //$NON-NLS-1$
            jexlVars.put("ctx", jmctx); //$NON-NLS-1$
            jexlVars.put("vars", vars); //$NON-NLS-1$
            jexlVars.put("props", JMeterUtils.getJMeterProperties()); //$NON-NLS-1$
            // Previously mis-spelt as theadName
View Full Code Here

        JMeterVariables vars = jmctx.getVariables();

        try
        {
            Script script = ScriptFactory.createScript(exp);
            JexlContext jc = JexlHelper.createContext();
            final Map jexlVars = jc.getVars();
            jexlVars.put("log", log); //$NON-NLS-1$
            jexlVars.put("ctx", jmctx); //$NON-NLS-1$
            jexlVars.put("vars", vars); //$NON-NLS-1$
            jexlVars.put("props", JMeterUtils.getJMeterProperties()); //$NON-NLS-1$
            // Previously mis-spelt as theadName
View Full Code Here

     {
         Parser parser = new Parser(new StringReader(";"));

         SimpleNode sn = parser.parse(new StringReader("foo = 1;"));

         JexlContext jc = JexlHelper.createContext();

         sn.interpret(jc);
     }
View Full Code Here

TOP

Related Classes of org.apache.commons.jexl.JexlContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.