Example usage for org.springframework.expression.spel.support StandardEvaluationContext getTypeLocator

List of usage examples for org.springframework.expression.spel.support StandardEvaluationContext getTypeLocator

Introduction

In this page you can find the example usage for org.springframework.expression.spel.support StandardEvaluationContext getTypeLocator.

Prototype

@Override
    public TypeLocator getTypeLocator() 

Source Link

Usage

From source file:org.craftercms.core.util.template.impl.spel.SpELStringTemplateCompiler.java

@PostConstruct
public void init() {
    if (evalContext == null) {
        evalContext = new StandardEvaluationContext();
    }/*from w w  w. j a  va  2  s  . co m*/

    if (evalContext instanceof StandardEvaluationContext) {
        StandardEvaluationContext standardEvalContext = (StandardEvaluationContext) evalContext;
        // PropertyAccessor used when the model is a BeanFactory.
        standardEvalContext.addPropertyAccessor(new BeanFactoryAccessor());
        if (beanFactory != null) {
            if (standardEvalContext.getBeanResolver() == null) {
                standardEvalContext.setBeanResolver(new BeanFactoryResolver(beanFactory));
            }
            if (standardEvalContext.getTypeLocator() == null) {
                standardEvalContext.setTypeLocator(new StandardTypeLocator(beanFactory.getBeanClassLoader()));
            }
            if (standardEvalContext.getTypeConverter() == null) {
                ConversionService conversionService = beanFactory.getConversionService();
                if (conversionService != null) {
                    standardEvalContext.setTypeConverter(new StandardTypeConverter(conversionService));
                }
            }
        }
    }
}