public EvaluationContext getEvaluationContext()
   {

      if (_evaluationContext == null) {

         // we need a ConfigurableBeanFactory to build the BeanExpressionContext
         ConfigurableBeanFactory beanFactory = null;

         // the WebApplicationContext MAY implement ConfigurableBeanFactory
         if (applicationContext instanceof ConfigurableBeanFactory) {
            beanFactory = (ConfigurableBeanFactory) applicationContext;
         }

         // the AutowireCapableBeanFactory usually implements ConfigurableListableBeanFactory
         if (beanFactory == null && applicationContext != null
                  && applicationContext.getAutowireCapableBeanFactory() instanceof ConfigurableBeanFactory) {
            beanFactory = (ConfigurableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
         }

         // we cannot continue without a ConfigurableBeanFactory
         if (beanFactory == null) {
            throw new IllegalStateException("Unable to find a ConfigurableBeanFactory");
         }

         BeanExpressionContext beanEvaluationContext = new BeanExpressionContext(beanFactory, null);

         StandardEvaluationContext sec = new StandardEvaluationContext();
         sec.setRootObject(beanEvaluationContext);
         sec.addPropertyAccessor(new BeanExpressionContextAccessor());
         sec.addPropertyAccessor(new BeanFactoryAccessor());
         sec.addPropertyAccessor(new MapAccessor());
         sec.setBeanResolver(new BeanFactoryResolver(beanEvaluationContext.getBeanFactory()));
         sec.setTypeLocator(new StandardTypeLocator(beanEvaluationContext.getBeanFactory().getBeanClassLoader()));
         ConversionService conversionService = beanEvaluationContext.getBeanFactory().getConversionService();
         if (conversionService != null) {
            sec.setTypeConverter(new StandardTypeConverter(conversionService));
         }

         _evaluationContext = sec;
      }

      return _evaluationContext;

   }
public EvaluationContext getEvaluationContext()
   {

      if (_evaluationContext == null) {

         
         ConfigurableBeanFactory beanFactory = null;

         
         if (applicationContext instanceof ConfigurableBeanFactory) {
            beanFactory = (ConfigurableBeanFactory) applicationContext;
         }

         
         if (beanFactory == null && applicationContext != null
                  && applicationContext.getAutowireCapableBeanFactory() instanceof ConfigurableBeanFactory) {
            beanFactory = (ConfigurableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
         }

         
         if (beanFactory == null) {
            throw new IllegalStateException("Unable to find a ConfigurableBeanFactory");
         }

         BeanExpressionContext beanEvaluationContext = new BeanExpressionContext(beanFactory, null);

         StandardEvaluationContext sec = new StandardEvaluationContext();
         sec.setRootObject(beanEvaluationContext);
         sec.addPropertyAccessor(new BeanExpressionContextAccessor());
         sec.addPropertyAccessor(new BeanFactoryAccessor());
         sec.addPropertyAccessor(new MapAccessor());
         sec.setBeanResolver(new BeanFactoryResolver(beanEvaluationContext.getBeanFactory()));
         sec.setTypeLocator(new StandardTypeLocator(beanEvaluationContext.getBeanFactory().getBeanClassLoader()));
         ConversionService conversionService = beanEvaluationContext.getBeanFactory().getConversionService();
         if (conversionService != null) {
            sec.setTypeConverter(new StandardTypeConverter(conversionService));
         }

         _evaluationContext = sec;
      }

      return _evaluationContext;

   }
public EvaluationContext getEvaluationContext ( ) { if ( _evaluationContext == null ) { // we need a ConfigurableBeanFactory to build the BeanExpressionContext ConfigurableBeanFactory beanFactory = null ; // the WebApplicationContext MAY implement ConfigurableBeanFactory if ( applicationContext instanceof ConfigurableBeanFactory ) { beanFactory = ( ConfigurableBeanFactory ) applicationContext ; } // the AutowireCapableBeanFactory usually implements ConfigurableListableBeanFactory if ( beanFactory == null && applicationContext != null && applicationContext . getAutowireCapableBeanFactory ( ) instanceof ConfigurableBeanFactory ) { beanFactory = ( ConfigurableBeanFactory ) applicationContext . getAutowireCapableBeanFactory ( ) ; } // we cannot continue without a ConfigurableBeanFactory if ( beanFactory == null ) { throw new IllegalStateException ( "Unable to find a ConfigurableBeanFactory" ) ; } BeanExpressionContext beanEvaluationContext = new BeanExpressionContext ( beanFactory , null ) ; StandardEvaluationContext sec = new StandardEvaluationContext ( ) ; sec . setRootObject ( beanEvaluationContext ) ; sec . addPropertyAccessor ( new BeanExpressionContextAccessor ( ) ) ; sec . addPropertyAccessor ( new BeanFactoryAccessor ( ) ) ; sec . addPropertyAccessor ( new MapAccessor ( ) ) ; sec . setBeanResolver ( new BeanFactoryResolver ( beanEvaluationContext . getBeanFactory ( ) ) ) ; sec . setTypeLocator ( new StandardTypeLocator ( beanEvaluationContext . getBeanFactory ( ) . getBeanClassLoader ( ) ) ) ; ConversionService conversionService = beanEvaluationContext . getBeanFactory ( ) . getConversionService ( ) ; if ( conversionService != null ) { sec . setTypeConverter ( new StandardTypeConverter ( conversionService ) ) ; } _evaluationContext = sec ; } return _evaluationContext ; }
Lazily creates a StandardEvaluationContext. The code has been inspired by
{@link StandardBeanExpressionResolver#evaluate(String, BeanExpressionContext)}
Lazily creates a StandardEvaluationContext . The code has been inspired by {