Package org.elasticsearch.common.mvel2

Examples of org.elasticsearch.common.mvel2.ParserConfiguration


    private final ParserConfiguration parserConfiguration;

    @Inject public MvelScriptEngineService(Settings settings) {
        super(settings);

        parserConfiguration = new ParserConfiguration();
        parserConfiguration.addPackageImport("java.util");
        parserConfiguration.addPackageImport("org.elasticsearch.common.trove");
        parserConfiguration.addPackageImport("org.elasticsearch.common.joda");
        parserConfiguration.addImport("time", MVEL.getStaticMethod(System.class, "currentTimeMillis", new Class[0]));
        // unboxed version of Math, better performance since conversion from boxed to unboxed my mvel is not needed
View Full Code Here


    @Override public String[] extensions() {
        return new String[]{"mvel"};
    }

    @Override public Object compile(String script) {
        return MVEL.compileExpression(script, new ParserContext(parserConfiguration));
    }
View Full Code Here

        private final MapVariableResolverFactory resolver;

        public MvelExecutableScript(Object script, Map vars) {
            this.script = (ExecutableStatement) script;
            if (vars != null) {
                this.resolver = new MapVariableResolverFactory(vars);
            } else {
                this.resolver = new MapVariableResolverFactory(new HashMap());
            }
        }
View Full Code Here

        public MvelSearchScript(Object script, SearchLookup lookup, Map<String, Object> vars) {
            this.script = (ExecutableStatement) script;
            this.lookup = lookup;
            if (vars != null) {
                this.resolver = new MapVariableResolverFactory(vars);
            } else {
                this.resolver = new MapVariableResolverFactory(new HashMap());
            }
            for (Map.Entry<String, Object> entry : lookup.asMap().entrySet()) {
                resolver.createVariable(entry.getKey(), entry.getValue());
            }
        }
View Full Code Here

        return new MVELExpressionLanguageContext(parserConfiguration, muleContext);
    }

    protected ParserConfiguration createParserConfiguration()
    {
        ParserConfiguration ParserConfiguration = new ParserConfiguration();
        configureParserConfiguration(ParserConfiguration);
        return ParserConfiguration;
    }
View Full Code Here

    protected DateTimeExpressionLanguageFuntion dateTimeFunction;

    @Before
    public void setup() throws InitialisationException
    {
        ParserConfiguration parserConfiguration = new ParserConfiguration();
        expressionExecutor = new MVELExpressionExecutor(parserConfiguration);
        context = new MVELExpressionLanguageContext(parserConfiguration, Mockito.mock(MuleContext.class));
        dateTimeFunction = new DateTimeExpressionLanguageFuntion();
        context.declareFunction("dateTime", dateTimeFunction);
    }
View Full Code Here

    }

    @Before
    public void setupMVEL() throws InitialisationException
    {
        mvel = new MVELExpressionExecutor(new ParserConfiguration());
        context = Mockito.mock(MVELExpressionLanguageContext.class);
        Mockito.when(context.isResolveable(Mockito.anyString())).thenReturn(false);
    }
View Full Code Here

    protected RegexExpressionLanguageFuntion regexFuntion;

    @Before
    public void setup() throws InitialisationException
    {
        ParserConfiguration parserConfiguration = new ParserConfiguration();
        expressionExecutor = new MVELExpressionExecutor(parserConfiguration);
        context = new MVELExpressionLanguageContext(parserConfiguration, Mockito.mock(MuleContext.class));
        regexFuntion = new RegexExpressionLanguageFuntion();
        context.declareFunction("regex", regexFuntion);
    }
View Full Code Here

    protected WildcardExpressionLanguageFuntion wildcardFunction;

    @Before
    public void setup() throws InitialisationException
    {
        ParserConfiguration parserConfiguration = new ParserConfiguration();
        expressionExecutor = new MVELExpressionExecutor(parserConfiguration);
        context = new MVELExpressionLanguageContext(parserConfiguration, Mockito.mock(MuleContext.class));
        wildcardFunction = new WildcardExpressionLanguageFuntion();
        context.declareFunction("wildcard", wildcardFunction);
    }
View Full Code Here

        }
    }

    public Object eval(String str,
                       Map vars) {
      ParserConfiguration pconf = new ParserConfiguration();
      pconf.addPackageImport("org.jbpm.task");
      pconf.addPackageImport("org.jbpm.task.service");
      pconf.addPackageImport("org.jbpm.task.query");
      pconf.addPackageImport("java.util");
      for(String entry : getInputs().keySet()){
        pconf.addImport(entry, getInputs().get(entry));
        }
      ParserContext context = new ParserContext(pconf);
        Serializable s = MVEL.compileExpression(str.trim(), context);
        return MVEL.executeExpression(s, vars);
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.mvel2.ParserConfiguration

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.