Search in sources :

Example 1 with SimpleContext

use of de.odysseus.el.util.SimpleContext in project camel by apache.

the class JuelExpression method createContext.

/**
     * Factory method to create the EL context
     */
protected ELContext createContext() {
    ELResolver resolver = new CompositeELResolver() {

        {
            add(new ArrayELResolver(false));
            add(new ListELResolver(false));
            add(new MapELResolver(false));
            add(new ResourceBundleELResolver());
            add(new BeanAndMethodELResolver());
        }
    };
    return new SimpleContext(resolver);
}
Also used : ListELResolver(javax.el.ListELResolver) ELResolver(javax.el.ELResolver) ResourceBundleELResolver(javax.el.ResourceBundleELResolver) MapELResolver(javax.el.MapELResolver) ArrayELResolver(javax.el.ArrayELResolver) CompositeELResolver(javax.el.CompositeELResolver) CompositeELResolver(javax.el.CompositeELResolver) SimpleContext(de.odysseus.el.util.SimpleContext) ListELResolver(javax.el.ListELResolver) ResourceBundleELResolver(javax.el.ResourceBundleELResolver) MapELResolver(javax.el.MapELResolver) ArrayELResolver(javax.el.ArrayELResolver)

Example 2 with SimpleContext

use of de.odysseus.el.util.SimpleContext in project camel by apache.

the class JuelExpression method setVariable.

protected void setVariable(ELContext context, String name, Object value, Class<?> type) {
    ValueExpression valueExpression = getExpressionFactory().createValueExpression(value, type);
    SimpleContext simpleContext = (SimpleContext) context;
    simpleContext.setVariable(name, valueExpression);
}
Also used : SimpleContext(de.odysseus.el.util.SimpleContext) ValueExpression(javax.el.ValueExpression)

Example 3 with SimpleContext

use of de.odysseus.el.util.SimpleContext in project camel by apache.

the class JuelTest method testJuel.

@Test
public void testJuel() throws Exception {
    ExpressionFactory factory = new ExpressionFactoryImpl();
    ELContext context = new SimpleContext();
    ValueExpression valueExpression = factory.createValueExpression(context, "${123 * 2}", Object.class);
    Object value = valueExpression.getValue(context);
    assertEquals("Result is a Long object", 246L, value);
}
Also used : ELContext(javax.el.ELContext) SimpleContext(de.odysseus.el.util.SimpleContext) ExpressionFactory(javax.el.ExpressionFactory) ExpressionFactoryImpl(de.odysseus.el.ExpressionFactoryImpl) ValueExpression(javax.el.ValueExpression) Test(org.junit.Test)

Aggregations

SimpleContext (de.odysseus.el.util.SimpleContext)3 ValueExpression (javax.el.ValueExpression)2 ExpressionFactoryImpl (de.odysseus.el.ExpressionFactoryImpl)1 ArrayELResolver (javax.el.ArrayELResolver)1 CompositeELResolver (javax.el.CompositeELResolver)1 ELContext (javax.el.ELContext)1 ELResolver (javax.el.ELResolver)1 ExpressionFactory (javax.el.ExpressionFactory)1 ListELResolver (javax.el.ListELResolver)1 MapELResolver (javax.el.MapELResolver)1 ResourceBundleELResolver (javax.el.ResourceBundleELResolver)1 Test (org.junit.Test)1