Search in sources :

Example 81 with ParserConfiguration

use of org.mule.mvel2.ParserConfiguration in project mule by mulesoft.

the class AbstractVarAssignmentDataTypePropagatorTestCase method compileMelExpression.

private CompiledExpression compileMelExpression(String expression, PrivilegedEvent testEvent, PrivilegedEvent.Builder builder) {
    final ParserConfiguration parserConfiguration = MVELExpressionLanguage.createParserConfiguration(Collections.EMPTY_MAP);
    final MVELExpressionLanguageContext context = createMvelExpressionLanguageContext(testEvent, builder, parserConfiguration);
    CompiledExpression compiledExpression = (CompiledExpression) compileExpression(expression, new ParserContext(parserConfiguration));
    // Expression must be executed, otherwise the variable accessor is not properly configured
    MVEL.executeExpression(compiledExpression, context);
    return compiledExpression;
}
Also used : MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) ParserContext(org.mule.mvel2.ParserContext) CompiledExpression(org.mule.mvel2.compiler.CompiledExpression) ParserConfiguration(org.mule.mvel2.ParserConfiguration)

Example 82 with ParserConfiguration

use of org.mule.mvel2.ParserConfiguration in project mule by mulesoft.

the class AbstractVarExpressionDataTypeResolverTestCase method createMvelExpressionLanguageContext.

protected MVELExpressionLanguageContext createMvelExpressionLanguageContext(PrivilegedEvent testEvent, ParserConfiguration parserConfiguration) {
    final MVELExpressionLanguageContext context = new MVELExpressionLanguageContext(parserConfiguration, muleContext);
    final StaticVariableResolverFactory staticContext = new StaticVariableResolverFactory(parserConfiguration, muleContext);
    final GlobalVariableResolverFactory globalContext = new GlobalVariableResolverFactory(Collections.EMPTY_MAP, Collections.EMPTY_MAP, parserConfiguration, muleContext);
    final DelegateVariableResolverFactory innerDelegate = new DelegateVariableResolverFactory(globalContext, new VariableVariableResolverFactory(parserConfiguration, muleContext, testEvent, PrivilegedEvent.builder(testEvent)));
    final DelegateVariableResolverFactory delegate = new DelegateVariableResolverFactory(staticContext, new MessageVariableResolverFactory(parserConfiguration, muleContext, testEvent, PrivilegedEvent.builder(testEvent), innerDelegate));
    context.setNextFactory(new CachedMapVariableResolverFactory(Collections.EMPTY_MAP, delegate));
    return context;
}
Also used : DelegateVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.DelegateVariableResolverFactory) MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) GlobalVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.GlobalVariableResolverFactory) MessageVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.MessageVariableResolverFactory) CachedMapVariableResolverFactory(org.mule.mvel2.integration.impl.CachedMapVariableResolverFactory) StaticVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.StaticVariableResolverFactory) VariableVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.VariableVariableResolverFactory)

Example 83 with ParserConfiguration

use of org.mule.mvel2.ParserConfiguration in project jbpm by kiegroup.

the class MVELUtils method eval.

public static Object eval(String str, Map<String, Object> vars) {
    ParserConfiguration pconf = new ParserConfiguration();
    pconf.addPackageImport("org.jbpm.services.task");
    // pconf.addPackageImport("org.jbpm.services.task.service");
    pconf.addPackageImport("org.jbpm.services.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);
    if (vars != null) {
        return MVELSafeHelper.getEvaluator().executeExpression(s, vars);
    } else {
        return MVELSafeHelper.getEvaluator().executeExpression(s);
    }
}
Also used : Serializable(java.io.Serializable) ParserContext(org.mvel2.ParserContext) ParserConfiguration(org.mvel2.ParserConfiguration)

Aggregations

ParserConfiguration (org.mvel2.ParserConfiguration)74 ParserContext (org.mvel2.ParserContext)70 HashMap (java.util.HashMap)39 ExecutableStatement (org.mvel2.compiler.ExecutableStatement)32 LinkedHashMap (java.util.LinkedHashMap)29 Map (java.util.Map)23 Serializable (java.io.Serializable)10 MVELExpressionLanguageContext (org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext)7 CompileException (org.mvel2.CompileException)7 ParserConfiguration (org.mule.mvel2.ParserConfiguration)6 MVELDialectRuntimeData (org.drools.core.rule.MVELDialectRuntimeData)5 MapObject (org.mvel2.tests.core.res.MapObject)5 Method (java.lang.reflect.Method)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Before (org.junit.Before)3 CachedMapVariableResolverFactory (org.mule.mvel2.integration.impl.CachedMapVariableResolverFactory)3 MVELExpressionExecutor (org.mule.runtime.core.internal.el.mvel.MVELExpressionExecutor)3 Bar (org.mvel2.tests.core.res.Bar)3