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;
}
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;
}
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);
}
}
Aggregations