Search in sources :

Example 1 with Builder

use of org.springframework.expression.spel.support.SimpleEvaluationContext.Builder in project spring-integration by spring-projects.

the class ExpressionUtils method createEvaluationContext.

/**
 * Create a {@link StandardEvaluationContext} with a {@link MapAccessor} in its
 * property accessor property and the supplied {@link ConversionService} in its
 * conversionService property.
 * @param conversionService the conversion service.
 * @param beanFactory the bean factory.
 * @param simple true if simple.
 * @return the evaluation context.
 */
private static EvaluationContext createEvaluationContext(ConversionService conversionService, BeanFactory beanFactory, boolean simple) {
    if (simple) {
        Builder ecBuilder = SimpleEvaluationContext.forPropertyAccessors(new MapAccessor(), DataBindingPropertyAccessor.forReadOnlyAccess()).withInstanceMethods();
        if (conversionService != null) {
            ecBuilder.withConversionService(conversionService);
        }
        return ecBuilder.build();
    } else {
        StandardEvaluationContext evaluationContext = new StandardEvaluationContext();
        evaluationContext.addPropertyAccessor(new MapAccessor());
        if (conversionService != null) {
            evaluationContext.setTypeConverter(new StandardTypeConverter(conversionService));
        }
        if (beanFactory != null) {
            evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory));
        }
        return evaluationContext;
    }
}
Also used : StandardTypeConverter(org.springframework.expression.spel.support.StandardTypeConverter) BeanFactoryResolver(org.springframework.context.expression.BeanFactoryResolver) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) Builder(org.springframework.expression.spel.support.SimpleEvaluationContext.Builder) MapAccessor(org.springframework.context.expression.MapAccessor)

Aggregations

BeanFactoryResolver (org.springframework.context.expression.BeanFactoryResolver)1 MapAccessor (org.springframework.context.expression.MapAccessor)1 Builder (org.springframework.expression.spel.support.SimpleEvaluationContext.Builder)1 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)1 StandardTypeConverter (org.springframework.expression.spel.support.StandardTypeConverter)1