Search in sources :

Example 41 with ParserConfiguration

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

the class DateTimeExpressionLanguageFunctionTestCase method setup.

@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);
}
Also used : MVELExpressionExecutor(org.mule.runtime.core.internal.el.mvel.MVELExpressionExecutor) MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) ParserConfiguration(org.mule.mvel2.ParserConfiguration) Before(org.junit.Before)

Example 42 with ParserConfiguration

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

the class RegexExpressionLanguageFunctionTestCase method setup.

@Before
public void setup() throws InitialisationException {
    ParserConfiguration parserConfiguration = new ParserConfiguration();
    expressionExecutor = new MVELExpressionExecutor(parserConfiguration);
    muleContext = mock(MuleContext.class);
    context = new MVELExpressionLanguageContext(parserConfiguration, muleContext);
    regexFuntion = new RegexExpressionLanguageFuntion();
    context.declareFunction("regex", regexFuntion);
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) MVELExpressionExecutor(org.mule.runtime.core.internal.el.mvel.MVELExpressionExecutor) MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) ParserConfiguration(org.mule.mvel2.ParserConfiguration) Before(org.junit.Before)

Example 43 with ParserConfiguration

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

the class WildcardExpressionLanguageFunctionTestCase method setup.

@Before
public void setup() throws InitialisationException {
    ParserConfiguration parserConfiguration = new ParserConfiguration();
    expressionExecutor = new MVELExpressionExecutor(parserConfiguration);
    muleContext = mock(MuleContext.class);
    context = new MVELExpressionLanguageContext(parserConfiguration, muleContext);
    wildcardFunction = new WildcardExpressionLanguageFuntion();
    context.declareFunction("wildcard", wildcardFunction);
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) MVELExpressionExecutor(org.mule.runtime.core.internal.el.mvel.MVELExpressionExecutor) MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) ParserConfiguration(org.mule.mvel2.ParserConfiguration) Before(org.junit.Before)

Example 44 with ParserConfiguration

use of org.mule.mvel2.ParserConfiguration in project stargate-core by tuplejump.

the class AggregateFunction method getParserConfiguration.

private ParserConfiguration getParserConfiguration() {
    ParserConfiguration parserConfig = new ParserConfiguration();
    parserConfig.addPackageImport("java.util");
    parserConfig.addPackageImport("org.apache.commons.lang3");
    parserConfig.addPackageImport("org.joda.time");
    parserConfig.addImport(Math.class);
    if (imports != null) {
        for (String imported : imports) parserConfig.addPackageImport(imported);
    }
    return parserConfig;
}
Also used : ParserConfiguration(org.mvel2.ParserConfiguration)

Example 45 with ParserConfiguration

use of org.mule.mvel2.ParserConfiguration in project mvel by mikebrock.

the class ASTNode method optimize.

private Object optimize(Object ctx, Object thisValue, VariableResolverFactory factory) {
    if ((fields & DEOP) != 0) {
        fields ^= DEOP;
    }
    AccessorOptimizer optimizer;
    Object retVal = null;
    if ((fields & NOJIT) != 0 || factory != null && factory.isResolveable(nameCache)) {
        optimizer = getAccessorCompiler(SAFE_REFLECTIVE);
    } else {
        optimizer = getDefaultAccessorCompiler();
    }
    ParserContext pCtx;
    if ((fields & PCTX_STORED) != 0) {
        pCtx = (ParserContext) literal;
    } else {
        pCtx = new ParserContext(new ParserConfiguration(getInjectedImports(factory), null));
    }
    try {
        pCtx.optimizationNotify();
        setAccessor(optimizer.optimizeAccessor(pCtx, expr, start, offset, ctx, thisValue, factory, true, egressType));
    } catch (OptimizationNotSupported ne) {
        setAccessor((optimizer = getAccessorCompiler(SAFE_REFLECTIVE)).optimizeAccessor(pCtx, expr, start, offset, ctx, thisValue, factory, true, null));
    }
    if (accessor == null) {
        return get(expr, start, offset, ctx, factory, thisValue);
    }
    if (retVal == null) {
        retVal = optimizer.getResultOptPass();
    }
    if (egressType == null) {
        egressType = optimizer.getEgressType();
    }
    return retVal;
}
Also used : AccessorOptimizer(org.mvel2.optimizers.AccessorOptimizer) ParserContext(org.mvel2.ParserContext) OptimizationNotSupported(org.mvel2.optimizers.OptimizationNotSupported) 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