• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OptimizerFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.mvel2.optimizers.OptimizerFactory的典型用法代码示例。如果您正苦于以下问题:Java OptimizerFactory类的具体用法?Java OptimizerFactory怎么用?Java OptimizerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OptimizerFactory类属于org.mvel2.optimizers包,在下文中一共展示了OptimizerFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: optimize

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
private Object optimize(Object ctx, Object elCtx, VariableResolverFactory variableResolverFactory) {

        if (DynamicOptimizer.isOverloaded()) {
            DynamicOptimizer.enforceTenureLimit();
        }

        AccessorOptimizer ao = OptimizerFactory.getAccessorCompiler("ASM");
        switch (type) {
            case DynamicOptimizer.REGULAR_ACCESSOR:
                _accessor = ao.optimizeAccessor(context, property, ctx, elCtx, variableResolverFactory, false, null);
                return ao.getResultOptPass();
            case DynamicOptimizer.OBJ_CREATION:
                _accessor = ao.optimizeObjectCreation(context, property, ctx, elCtx, variableResolverFactory);
                return _accessor.getValue(ctx, elCtx, variableResolverFactory);
            case DynamicOptimizer.COLLECTION:
                _accessor = ao.optimizeCollection(AbstractParser.getCurrentThreadParserContext(), ctx, null, property, ctx, elCtx, variableResolverFactory);
                return _accessor.getValue(ctx, elCtx, variableResolverFactory);
        }
        return null;
    }
 
开发者ID:codehaus,项目名称:mvel,代码行数:21,代码来源:DynamicGetAccessor.java


示例2: testMVEL226

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testMVEL226() {

        A226 a = new A226();
        Map m = Collections.singletonMap("a", a);
        Map<String, Object> nestMap = Collections.<String, Object>singletonMap("foo", "bar");
        String ex = "a.?map['foo']";
        Serializable s;

        assertNull(MVEL.getProperty(ex, m));

        OptimizerFactory.setDefaultOptimizer("ASM");
        s = MVEL.compileExpression(ex);
        assertNull(MVEL.executeExpression(s, m));
        a.map = nestMap;
        assertEquals("bar", MVEL.executeExpression(s, m));
        a.map = null;

        OptimizerFactory.setDefaultOptimizer(OptimizerFactory.DYNAMIC);

        s = MVEL.compileExpression(ex);
        assertNull(MVEL.executeExpression(s, m));
        a.map = nestMap;
        assertEquals("bar", MVEL.executeExpression(s, m));
    }
 
开发者ID:codehaus,项目名称:mvel,代码行数:25,代码来源:PropertyAccessTests.java


示例3: testJIRA207

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testJIRA207() {
        String ex = "x = 0; y = 0;" +
                "def foo() { x = 1; System.out.println('Word up'); }\n" +
                "def bar() { y = 1;  System.out.println('Peace out'); }\n" +
                "def doMany(fps) {\n" +
                "foreach(f : fps) { System.out.println(f); f(); }\n" +
                "}\n" +
                "doMany([foo,bar]);" +
                "x == 1 && y == 1;";

        Boolean bool;

//        Boolean bool = (Boolean) MVEL.eval(ex, new HashMap());
//        assertTrue(bool);

        OptimizerFactory.setDefaultOptimizer("ASM");
        Serializable s = MVEL.compileExpression(ex);

        bool = (Boolean) MVEL.executeExpression(s, new HashMap());
        assertTrue(bool);

        OptimizerFactory.setDefaultOptimizer("dynamic");
    }
 
开发者ID:codehaus,项目名称:mvel,代码行数:24,代码来源:FunctionsTest.java


示例4: start

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void start() {
    //Create two of the same expressions
    final String expression = "firstname";
    final String expression2 = "lastname";

    //Create a bean to run expressions against
    final Bean bean = new Bean();

    //Use reflection mode
    OptimizerFactory.setDefaultOptimizer(OptimizerFactory.SAFE_REFLECTIVE);

    //Compile the expressions
    Serializable mvelExp1 = MVEL.compileExpression(expression);
    Serializable mvelExp2 = MVEL.compileExpression(expression2);

    //run the threads
    runThreads(bean, mvelExp1, mvelExp2);
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:19,代码来源:MVELThreadTest.java


示例5: testJIRA164

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testJIRA164() {
    Serializable s = MVEL.compileExpression("1 / (var1 + var1) * var1",
            ParserContext.create().stronglyTyped().withInput("var1", double.class));
    Map vars = new HashMap();
    double var1 = 1d;

    vars.put("var1", var1);

    OptimizerFactory.setDefaultOptimizer("reflective");
    assertEquals((1 / (var1 + var1) * var1), MVEL.executeExpression(s, vars));

    s = MVEL.compileExpression("1 / (var1 + var1) * var1", ParserContext.create().withInput("var1", double.class));
    OptimizerFactory.setDefaultOptimizer("ASM");
    assertEquals((1 / (var1 + var1) * var1), MVEL.executeExpression(s, vars));

}
 
开发者ID:codehaus,项目名称:mvel,代码行数:17,代码来源:ArithmeticTests.java


示例6: testJIRA164b

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testJIRA164b() {
    Serializable s = MVEL.compileExpression("1 + 1 / (var1 + var1) * var1",
            ParserContext.create().stronglyTyped().withInput("var1", double.class));
    Map vars = new HashMap();

    double var1 = 1d;
    vars.put("var1", var1);

    OptimizerFactory.setDefaultOptimizer("reflective");
    assertEquals((1 + 1 / (var1 + var1) * var1), MVEL.executeExpression(s, vars));

    s = MVEL.compileExpression("1 + 1 / (var1 + var1) * var1",
            ParserContext.create().withInput("var1", double.class));
    OptimizerFactory.setDefaultOptimizer("ASM");
    assertEquals((1 + 1 / (var1 + var1) * var1), MVEL.executeExpression(s, vars));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:17,代码来源:ArithmeticTests.java


示例7: testJIRA164c

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testJIRA164c() {
    Serializable s = MVEL.compileExpression("1 + 1 / (var1 + var1 + 2 + 3) * var1",
            ParserContext.create().stronglyTyped().withInput("var1", double.class));
    Map vars = new HashMap();

    double var1 = 1d;
    vars.put("var1", var1);

    OptimizerFactory.setDefaultOptimizer("reflective");
    assertEquals((1 + 1 / (var1 + var1 + 2 + 3) * var1), MVEL.executeExpression(s, vars));

    s = MVEL.compileExpression("1 + 1 / (var1 + var1 + 2 + 3) * var1",
            ParserContext.create().withInput("var1", double.class));
    OptimizerFactory.setDefaultOptimizer("ASM");
    assertEquals((1 + 1 / (var1 + var1 + 2 + 3) * var1), MVEL.executeExpression(s, vars));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:17,代码来源:ArithmeticTests.java


示例8: testJIRA164d

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testJIRA164d() {
    Serializable s = MVEL.compileExpression("1 + 1 + 1 / (var1 + var1) * var1",
            ParserContext.create().stronglyTyped().withInput("var1", double.class));
    Map vars = new HashMap();

    double var1 = 1d;
    vars.put("var1", var1);

    OptimizerFactory.setDefaultOptimizer("reflective");
    assertEquals((1 + 1 + 1 / (var1 + var1) * var1), MVEL.executeExpression(s, vars));

    s = MVEL.compileExpression("1 + 1 + 1 / (var1 + var1) * var1",
            ParserContext.create().withInput("var1", double.class));
    OptimizerFactory.setDefaultOptimizer("ASM");
    assertEquals((1 + 1 + 1 / (var1 + var1) * var1), MVEL.executeExpression(s, vars));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:17,代码来源:ArithmeticTests.java


示例9: testJIRA164e

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testJIRA164e() {
    Serializable s = MVEL.compileExpression("10 + 11 + 12 / (var1 + var1 + 51 + 71) * var1 + 13 + 14",
            ParserContext.create().stronglyTyped().withInput("var1", double.class));
    Map vars = new HashMap();

    double var1 = 1d;
    vars.put("var1", var1);

    OptimizerFactory.setDefaultOptimizer("reflective");
    assertEquals((float) (10 + 11 + 12 / (var1 + var1 + 51 + 71) * var1 + 13 + 14),
            ((Double) MVEL.executeExpression(s, vars)).floatValue());

    s = MVEL.compileExpression("10 + 11 + 12 / (var1 + var1 + 51 + 71) * var1 + 13 + 14",
            ParserContext.create().withInput("var1", double.class));
    OptimizerFactory.setDefaultOptimizer("ASM");
    assertEquals((float) (10 + 11 + 12 / (var1 + var1 + 51 + 71) * var1 + 13 + 14),
            ((Double) MVEL.executeExpression(s, vars)).floatValue());
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:19,代码来源:ArithmeticTests.java


示例10: testJIRA164f

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testJIRA164f() {
    Serializable s = MVEL.compileExpression("10 + 11 + 12 / (var1 + 1 + var1 + 51 + 71) * var1 + 13 + 14",
            ParserContext.create().stronglyTyped().withInput("var1", double.class));
    Map vars = new HashMap();

    double var1 = 1d;
    vars.put("var1", var1);

    OptimizerFactory.setDefaultOptimizer("reflective");
    assertEquals((float) (10 + 11 + 12 / (var1 + 1 + var1 + 51 + 71) * var1 + 13 + 14),
            ((Double) MVEL.executeExpression(s, vars)).floatValue());

    s = MVEL.compileExpression("10 + 11 + 12 / (var1 + 1 + var1 + 51 + 71) * var1 + 13 + 14",
            ParserContext.create().withInput("var1", double.class));
    OptimizerFactory.setDefaultOptimizer("ASM");
    assertEquals((float) (10 + 11 + 12 / (var1 + 1 + var1 + 51 + 71) * var1 + 13 + 14),
            ((Double) MVEL.executeExpression(s, vars)).floatValue());
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:19,代码来源:ArithmeticTests.java


示例11: testJIRA164h

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testJIRA164h() {
    Serializable s = MVEL.compileExpression("1 - var1 * (var1 * var1 * (var1 * var1) * var1) * var1",
            ParserContext.create().stronglyTyped().withInput("var1", double.class));
    Map vars = new HashMap();

    double var1 = 2d;
    vars.put("var1", var1);

    OptimizerFactory.setDefaultOptimizer("reflective");
    assertEquals((float) (1 - var1 * (var1 * var1 * (var1 * var1) * var1) * var1),
            ((Double) MVEL.executeExpression(s, vars)).floatValue());

    s = MVEL.compileExpression("1 - var1 * (var1 * var1 * (var1 * var1) * var1) * var1",
            ParserContext.create().withInput("var1", double.class));
    OptimizerFactory.setDefaultOptimizer("ASM");

    assertEquals((float) (1 - var1 * (var1 * var1 * (var1 * var1) * var1) * var1),
            ((Double) MVEL.executeExpression(s, vars)).floatValue());
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:20,代码来源:ArithmeticTests.java


示例12: testThisReferenceMapVirtualObjects1

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testThisReferenceMapVirtualObjects1() {
    // Create our root Map object
    Map<String, String> map = new HashMap<String, String>();
    map.put("foo", "bar");

    VariableResolverFactory factory = new MapVariableResolverFactory(new HashMap<String, Object>());
    factory.createVariable("this", map);

    OptimizerFactory.setDefaultOptimizer("reflective");

    // Run test
    assertEquals(true,
            executeExpression(compileExpression("this.foo == 'bar'"),
                    map,
                    factory));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:17,代码来源:CoreConfidenceTests.java


示例13: testThisReferenceMapVirtualObjects2

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testThisReferenceMapVirtualObjects2() {
    // Create our root Map object
    Map<String, String> map = new HashMap<String, String>();
    map.put("foo",
            "bar");

    VariableResolverFactory factory = new MapVariableResolverFactory(new HashMap<String, Object>());
    factory.createVariable("this",
            map);

    // I think we can all figure this one out.

    if (!Boolean.getBoolean("mvel2.disable.jit")) OptimizerFactory.setDefaultOptimizer("ASM");

    // Run test
    assertEquals(true,
            executeExpression(compileExpression("this.foo == 'bar'"),
                    map,
                    factory));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:21,代码来源:CoreConfidenceTests.java


示例14: testSataticClassImportViaFactoryAndWithModification

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testSataticClassImportViaFactoryAndWithModification() {
    OptimizerFactory.setDefaultOptimizer("ASM");
    MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
    ClassImportResolverFactory classes = new ClassImportResolverFactory();
    classes.addClass(Person.class);

    ResolverTools.appendFactory(mvf,
            classes);

    assertEquals(21,
            executeExpression(
                    compileExpression("p = new Person('tom'); p.age = 20; " +
                            "with( p ) { age = p.age + 1 }; return p.age;",
                            classes.getImportedClasses()),
                    mvf));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:17,代码来源:CoreConfidenceTests.java


示例15: testExecuteCoercionTwice

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testExecuteCoercionTwice() {
    OptimizerFactory.setDefaultOptimizer("reflective");

    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("foo",
            new Foo());
    vars.put("$value",
            new Long(5));

    ExpressionCompiler compiler = new ExpressionCompiler("with (foo) { countTest = $value };");

    ParserContext ctx = new ParserContext();
    ctx.setSourceFile("test.mv");
    ctx.setDebugSymbols(true);

    CompiledExpression compiled = compiler.compile(ctx);

    executeExpression(compiled, null, vars);
    executeExpression(compiled, null, vars);
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:21,代码来源:CoreConfidenceTests.java


示例16: testExecuteCoercionTwice2

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testExecuteCoercionTwice2() {
    OptimizerFactory.setDefaultOptimizer("ASM");

    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("foo",
            new Foo());
    vars.put("$value",
            new Long(5));

    ExpressionCompiler compiler = new ExpressionCompiler("with (foo) { countTest = $value };");

    ParserContext ctx = new ParserContext();
    ctx.setSourceFile("test.mv");
    ctx.setDebugSymbols(true);

    CompiledExpression compiled = compiler.compile(ctx);

    executeExpression(compiled,
            null,
            vars);
    executeExpression(compiled,
            null,
            vars);
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:25,代码来源:CoreConfidenceTests.java


示例17: testMapBindingSemantics2

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testMapBindingSemantics2() {
    OptimizerFactory.setDefaultOptimizer("ASM");
    Map<String, Object> outermap = new HashMap<String, Object>();
    Map<String, Object> innermap = new HashMap<String, Object>();

    innermap.put("test",
            "foo");
    outermap.put("innermap",
            innermap);

    executeSetExpression(compileSetExpression("innermap['test']"),
            outermap,
            "bar");

    assertEquals("bar",
            testCompiledSimple("innermap['test']",
                    outermap,
                    null));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:20,代码来源:CoreConfidenceTests.java


示例18: testDataConverterStrictMode

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testDataConverterStrictMode() throws Exception {
    OptimizerFactory.setDefaultOptimizer("ASM");

    DataConversion.addConversionHandler(Date.class,
            new MVELDateCoercion());

    ParserContext ctx = new ParserContext();
    ctx.addImport("Cheese",
            Cheese.class);
    ctx.setStrongTyping(true);
    ctx.setStrictTypeEnforcement(true);

    Locale.setDefault(Locale.US);

    Cheese expectedCheese = new Cheese();
    expectedCheese.setUseBy(new SimpleDateFormat("dd-MMM-yyyy").parse("10-Jul-1974"));

    ExpressionCompiler compiler = new ExpressionCompiler("c = new Cheese(); c.useBy = '10-Jul-1974'; return c");
    Cheese actualCheese = (Cheese) executeExpression(compiler.compile(ctx),
            createTestMap());
    assertEquals(expectedCheese.getUseBy(),
            actualCheese.getUseBy());
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:24,代码来源:CoreConfidenceTests.java


示例19: testJIRA122

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testJIRA122() {
    Serializable s = compileExpression("System.out.println('>'+java.lang.Character.toLowerCase(name.charAt(0))); java.lang.Character.toLowerCase(name.charAt(0)) == 'a'");

    OptimizerFactory.setDefaultOptimizer("ASM");

    Map map = new HashMap();
    map.put("name",
            "Adam");

    assertEquals(true,
            executeExpression(s,
                    map));
    assertEquals(true,
            executeExpression(s,
                    map));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:17,代码来源:CoreConfidenceTests.java


示例20: testJIRA122b

import org.mvel2.optimizers.OptimizerFactory; //导入依赖的package包/类
public void testJIRA122b() {
    Serializable s = compileExpression("System.out.println('>'+java.lang.Character.toLowerCase(name.charAt(0))); java.lang.Character.toLowerCase(name.charAt(0)) == 'a'");

    OptimizerFactory.setDefaultOptimizer("reflective");

    Map map = new HashMap();
    map.put("name",
            "Adam");

    assertEquals(true,
            executeExpression(s,
                    map));
    assertEquals(true,
            executeExpression(s,
                    map));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:17,代码来源:CoreConfidenceTests.java



注:本文中的org.mvel2.optimizers.OptimizerFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultLibraryRootsComponentDescriptor类代码示例发布时间:2022-05-22
下一篇:
Java IPackageManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap