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

Java MapVariableResolverFactory类代码示例

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

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



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

示例1: main

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public static void main(String[] args) {
    Foo foo = new Foo();
    foo.setName("test");
    Map context = new HashMap();
    String expression = "foo.name == 'test'";
    VariableResolverFactory functionFactory = new MapVariableResolverFactory(context);
    context.put("foo",foo);
    Boolean result = (Boolean) MVEL.eval(expression,functionFactory);
    System.out.println(result);


    Serializable compileExpression = MVEL.compileExpression(expression);
    result = (Boolean) MVEL.executeExpression(compileExpression, context, functionFactory);
    System.out.print(result);

}
 
开发者ID:brucefengnju,项目名称:eldemo,代码行数:17,代码来源:RunMvel.java


示例2: runMvel

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public static void runMvel(int xmax, int ymax, int zmax) {
    Map context = new HashMap();
    String expression = "x + y*2 - z";
    Serializable compileExpression = MVEL.compileExpression(expression);
    Integer result = 0;
    Date start = new Date();
    for (int xval = 0; xval < xmax; xval++) {
        for (int yval = 0; yval < ymax; yval++) {
            for (int zval = 0; zval <= zmax; zval++) {
                context.put("x", xval);
                context.put("y", yval);
                context.put("z", zval);
                VariableResolverFactory functionFactory = new MapVariableResolverFactory(context);
                Integer cal = (Integer) MVEL.executeExpression(compileExpression, context, functionFactory);
                result += cal;
            }
        }
    }
    Date end = new Date();
    System.out.println("MVEL:time is : " + (end.getTime() - start.getTime()) + ",result is " + result);

}
 
开发者ID:brucefengnju,项目名称:eldemo,代码行数:23,代码来源:RunPerform.java


示例3: initGlobalContext

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public static void initGlobalContext(Configuration configuration) {
    if(configuration.getGlobalContext()!=null && configuration.getGlobalResolver()==null) {
        synchronized (Configuration.class) {
            if(configuration.getGlobalResolver()==null) {
                MavenLoader.prefetch(configuration.getArtifacts());
                GlobalContext globalContext = configuration.getGlobalContext();
                MapVariableResolverFactory globalResolver = new MapVariableResolverFactory(new HashMap<String, Object>());
                globalResolver.createVariable(VARIABLE_RESOLVER, globalResolver);
                MavenLoader.loadArtifact(globalContext.getArtifacts(), globalResolver);
                Utils.executeExpression(globalContext.getInit(), globalResolver);
                Utils.registerDisposeExpression(globalContext.getDispose(), globalResolver);
                initTimers(globalContext, globalResolver);
                configuration.setGlobalResolver(globalResolver);
            }
        }
    }
}
 
开发者ID:igor-suhorukov,项目名称:aspectj-scripting,代码行数:18,代码来源:ContextUtils.java


示例4: initTimers

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
private static void initTimers(GlobalContext globalContext, MapVariableResolverFactory globalResolver) {
    TimerTask[] timerTasks = globalContext.getTimerTasks();
    if(timerTasks!=null && timerTasks.length>0){
        Timer timer = new Timer();
        globalResolver.createVariable(VARIABLE_GLOBAL_TIMER, timer);
        for(TimerTask timerTask: timerTasks){
            MvelTimerTask mvelTimerTask = new MvelTimerTask(timerTask.getJobExpression(), globalResolver);
            if(timerTask.getFirstTime()!=null && timerTask.getPeriod()!=null){
                timer.schedule(mvelTimerTask, timerTask.getFirstTime(), timerTask.getPeriod());
            } else if(timerTask.getFirstTime()!=null && timerTask.getPeriod()==null){
                timer.schedule(mvelTimerTask, timerTask.getFirstTime());
            } else if(timerTask.getDelay()!=null && timerTask.getPeriod()!=null){
                timer.schedule(mvelTimerTask, timerTask.getDelay(), timerTask.getPeriod());
            } else if(timerTask.getDelay()!=null){
                timer.schedule(mvelTimerTask, timerTask.getDelay());
            }
        }
    }
}
 
开发者ID:igor-suhorukov,项目名称:aspectj-scripting,代码行数:20,代码来源:ContextUtils.java


示例5: mvelScheduler

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
@org.junit.Test
public void mvelScheduler() throws Exception{
    Timer timer = new Timer();
    MapVariableResolverFactory variableResolverFactory = new MapVariableResolverFactory();
    ClassRef[] classRefs = {new ClassRef("org.github.suhorukov.SigarCollect", "SigarCollect")};
    ResourceRef[] resourceRefs = new ResourceRef[0];
    Artifact[] artifacts = {new Artifact("com.github.igor-suhorukov:jvm-metrics:1.1", classRefs, resourceRefs)};
    MavenLoader.loadArtifact(artifacts, variableResolverFactory);
    String mvelScript = "java.lang.String metrics = new SigarCollect().getJsonFullInfo();" +
                        "org.aspectj.aspect.ExecuteTimerTaskTest.setJsonResult(metrics);";
    timer.schedule(new MvelTimerTask(mvelScript, variableResolverFactory), TIMER_DELAY);
    Thread.sleep(TIMER_DELAY*5);
    HashMap metrics = new GsonBuilder().create().fromJson(jsonResult, HashMap.class);
    assertNotNull(jsonResult);
    assertTrue(metrics.containsKey("ProcCpu"));
    assertTrue(metrics.containsKey("Pid"));
    assertTrue(metrics.containsKey("Mem"));
}
 
开发者ID:igor-suhorukov,项目名称:aspectj-scripting,代码行数:19,代码来源:ExecuteTimerTaskTest.java


示例6: testThisReferenceMapVirtualObjects1

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的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


示例7: testThisReferenceMapVirtualObjects2

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的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


示例8: testSataticClassImportViaFactoryAndWithModification

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的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


示例9: testTestIntToLong

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public void testTestIntToLong() {
    //System.out.println( int.class.isAssignableFrom( Integer.class ) );
    //Number n = new Integer ( 3 )

    String s = "1+(long)a";

    ParserContext pc = new ParserContext();
    pc.addInput("a", Integer.class);

    ExpressionCompiler compiler = new ExpressionCompiler(s, pc);
    CompiledExpression expr = compiler.compile();

    Map vars = new HashMap();
    vars.put("a", 1);

    Object r = ((ExecutableStatement) expr).getValue(null, new MapVariableResolverFactory(vars));
    assertEquals(new Long(2), r);
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:19,代码来源:CoreConfidenceTests.java


示例10: testMVEL190

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public void testMVEL190() {
    ParserContext context = new ParserContext();
    context.addImport(Ship.class);
    context.addImport(MapObject.class);

    context.addInput("obj", MapObject.class);

    Object compiled = MVEL.compileExpression(
            "((Ship) obj).getName()", context);

    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("obj", new Ship());

    VariableResolverFactory varsResolver
            = new MapVariableResolverFactory(vars);

    System.out.println(
            executeExpression(compiled, varsResolver));

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


示例11: testBreakpoints

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public void testBreakpoints() {
    ExpressionCompiler compiler = new ExpressionCompiler("a = 5;\nb = 5;\n\nif (a == b) {\n\nSystem.out.println('Good');\nreturn a + b;\n}\n");
    System.out.println("-------\n" + compiler.getExpression() + "\n-------\n");

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

    CompiledExpression compiled = compiler.compile(ctx);

    MVELRuntime.registerBreakpoint("test.mv", 7);

    Debugger testDebugger = new Debugger() {
        public int onBreak(Frame frame) {
            System.out.println("Breakpoint [source:" + frame.getSourceName() + "; line:" + frame.getLineNumber() + "]");

            return 0;
        }
    };

    MVELRuntime.setThreadDebugger(testDebugger);

    assertEquals(10, MVEL.executeDebugger(compiled, null, new MapVariableResolverFactory(createTestMap())));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:25,代码来源:DebuggerTests.java


示例12: isDefinedAt

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public boolean isDefinedAt(IBatisRoutingFact routingFact) {
    Validate.notNull(routingFact);
    String namespace = StringUtils.substringBeforeLast(routingFact.getAction(), ".");
    boolean matches = StringUtils.equals(namespace, getTypePattern());
    if (matches) {
        try {
            Map<String, Object> vrs = new HashMap<String, Object>();
            vrs.putAll(getFunctionMap());
            vrs.put("$ROOT", routingFact.getArgument()); // add top object reference for expression
            VariableResolverFactory vrfactory = new MapVariableResolverFactory(vrs);
            if (MVEL.evalToBoolean(getAttributePattern(), routingFact.getArgument(), vrfactory)) {
                return true;
            }
        } catch (Throwable t) {
            logger
                    .info(
                            "failed to evaluate attribute expression:'{}' with context object:'{}'\n{}",
                            new Object[] { getAttributePattern(), routingFact.getArgument(), t });
        }
    }
    return false;
}
 
开发者ID:alibaba,项目名称:cobarclient,代码行数:23,代码来源:IBatisNamespaceShardingRule.java


示例13: isDefinedAt

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public boolean isDefinedAt(IBatisRoutingFact routingFact) {
    Validate.notNull(routingFact);
    boolean matches = StringUtils.equals(getTypePattern(), routingFact.getAction());
    if (matches) {
        try {
            Map<String, Object> vrs = new HashMap<String, Object>();
            vrs.putAll(getFunctionMap());
            vrs.put("$ROOT", routingFact.getArgument()); // add top object reference for expression
            VariableResolverFactory vrfactory = new MapVariableResolverFactory(vrs);
            if (MVEL.evalToBoolean(getAttributePattern(), routingFact.getArgument(), vrfactory)) {
                return true;
            }
        } catch (Throwable t) {
            logger
                    .info(
                            "failed to evaluate attribute expression:'{}' with context object:'{}'\n{}",
                            new Object[] { getAttributePattern(), routingFact.getArgument(), t });
        }
    }

    return false;
}
 
开发者ID:alibaba,项目名称:cobarclient,代码行数:23,代码来源:IBatisSqlActionShardingRule.java


示例14: execute

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public Integer execute(String columnValue, Map<String, Object> extension) {
    Map<String, Object> vrs = new HashMap<String, Object>();
    //, Map<String, ElFunction<?,?>> functionMap
    //vrs.putAll(functionMap);// 拓展函数
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("value", columnValue);
    vrs.put("$ROOT", params);
    VariableResolverFactory vrfactory = new MapVariableResolverFactory(vrs);
    return MVEL.eval(expression, params, vrfactory, Integer.class);
}
 
开发者ID:tongbanjie,项目名称:baymax,代码行数:11,代码来源:ELFunction.java


示例15: createProcessVariableResolver

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
private VariableResolverFactory createProcessVariableResolver(JoinPoint pjp) {
    VariableResolverFactory variableResolverFactory = new MapVariableResolverFactory();
    Utils.fillResolveParams(aspect.getProcess().getResultParams(), variableResolverFactory);
    variableResolverFactory.createVariable(JOIN_POINT_VARIABLE, pjp);
    variableResolverFactory.createVariable(ContextUtils.VARIABLE_RESOLVER, variableResolverFactory);
    variableResolverFactory.setNextFactory(resolverFactory);
    return variableResolverFactory;
}
 
开发者ID:igor-suhorukov,项目名称:aspectj-scripting,代码行数:9,代码来源:BaseAspectLifecycle.java


示例16: getReducedValueAccelerated

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolverFactory ctxFactory = new MapVariableResolverFactory(new HashMap<String, Object>(0), factory);
    for (initializer.getValue(ctx, thisValue, ctxFactory); (Boolean) condition.getValue(ctx, thisValue, ctxFactory); after.getValue(ctx, thisValue, ctxFactory)) {
        compiledBlock.getValue(ctx, thisValue, ctxFactory);
    }
    return null;
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:8,代码来源:ForNode.java


示例17: getReducedValue

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
    for (initializer.getValue(ctx, thisValue, factory = new MapVariableResolverFactory(new HashMap<String, Object>(0), factory)); (Boolean) condition.getValue(ctx, thisValue, factory); after.getValue(ctx, thisValue, factory)) {
        compiledBlock.getValue(ctx, thisValue, factory);
    }

    return null;
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:8,代码来源:ForNode.java


示例18: getReducedValueAccelerated

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolverFactory ctxFactory = new MapVariableResolverFactory(new HashMap(0), factory);
    while ((Boolean) condition.getValue(ctx, thisValue, factory)) {
        compiledBlock.getValue(ctx, thisValue, ctxFactory);
    }

    return null;
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:9,代码来源:WhileNode.java


示例19: getReducedValue

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolverFactory ctxFactory = new MapVariableResolverFactory(new HashMap(0), factory);

    while ((Boolean) condition.getValue(ctx, thisValue, factory)) {
        compiledBlock.getValue(ctx, thisValue, ctxFactory);
    }
    return null;
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:9,代码来源:WhileNode.java


示例20: getReducedValueAccelerated

import org.mvel2.integration.impl.MapVariableResolverFactory; //导入依赖的package包/类
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolverFactory ctxFactory = new MapVariableResolverFactory(new HashMap(0), factory);

    do {
        compiledBlock.getValue(ctx, thisValue, ctxFactory);
    }
    while ((Boolean) condition.getValue(ctx, thisValue, factory));

    return null;
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:11,代码来源:DoNode.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java MetricsReporter类代码示例发布时间:2022-05-22
下一篇:
Java RpcStatusProto类代码示例发布时间: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