Examples of SharedVariableSpaceModel


Examples of org.mvel2.util.SharedVariableSpaceModel

    ParserContext ctx = ParserContext.create();
    ctx.addIndexedInput(varNames);
    ctx.setIndexAllocation(true);

    SharedVariableSpaceModel model = VariableSpaceCompiler.compileShared(expr, ctx, values);

    Serializable indexCompile = MVEL.compileExpression(expr, ctx);
    Serializable dynamicCompile = MVEL.compileExpression(expr, ParserContext.create());

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("x", 10);
    map.put("y", 20);
    map.put("z", 30);

    assertEquals(MVEL.executeExpression(dynamicCompile, map),
        MVEL.executeExpression(indexCompile, model.createFactory()));
//
//        for (int x = 0; x < 10; x++) {
//            long tm = System.currentTimeMillis();
//            for (int i = 0; i < 10000; i++) {
//                MVEL.executeExpression(indexCompile, model.createFactory());
View Full Code Here

Examples of org.mvel2.util.SharedVariableSpaceModel

    ctx.setIndexAllocation(true);
    ctx.addIndexedInput(vars);

    String expr = "def myfunc(z) { a + b + z }; myfunc('poop');";

    SharedVariableSpaceModel model = VariableSpaceCompiler.compileShared(expr, ctx, vals);

    Serializable s = MVEL.compileExpression(expr, ctx);

//        VariableResolverFactory locals = new CachingMapVariableResolverFactory(new HashMap<String, Object>());
//        VariableResolverFactory injected = new IndexedVariableResolverFactory(vars, vals, locals);

    assertEquals("foobarpoop", MVEL.executeExpression(s, model.createFactory()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.