List of usage examples for org.springframework.expression.spel.support StandardTypeLocator StandardTypeLocator
public StandardTypeLocator(@Nullable ClassLoader classLoader)
From source file:org.craftercms.core.util.template.impl.spel.SpELStringTemplateCompiler.java
@PostConstruct public void init() { if (evalContext == null) { evalContext = new StandardEvaluationContext(); }//from w ww. j a v a2 s . c o 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)); } } } } }
From source file:org.springframework.cloud.function.deployer.ApplicationRunner.java
public ApplicationRunner(ClassLoader classLoader, String source) { this.classLoader = classLoader; this.source = source; this.config = new SpelParserConfiguration(null, this.classLoader); this.typeLocator = new StandardTypeLocator(this.classLoader); }
From source file:org.springframework.cloud.function.deployer.ApplicationRunner.java
public void run(String... args) { ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); try {//from w w w . java 2s . c o m ClassUtils.overrideThreadContextClassLoader(this.classLoader); Class<?> cls = this.classLoader.loadClass(ContextRunner.class.getName()); this.app = new StandardEvaluationContext(cls.getDeclaredConstructor().newInstance()); this.app.setTypeLocator(new StandardTypeLocator(this.classLoader)); runContext(this.source, defaultProperties(UUID.randomUUID().toString()), args); } catch (Exception e) { logger.error("Cannot deploy", e); } finally { ClassUtils.overrideThreadContextClassLoader(contextLoader); } RuntimeException e = getError(); if (e != null) { throw e; } }
From source file:org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.java
/** * Constructs, configures and initializes a new instance of an {@link EvaluationContext}. * * @param beanFactory reference to the Spring {@link BeanFactory}. * @return a new {@link EvaluationContext}. * @see org.springframework.beans.factory.BeanFactory * @see org.springframework.expression.EvaluationContext * @see #getBeanFactory()/*from ww w . j a v a 2s .c o m*/ */ protected EvaluationContext newEvaluationContext(BeanFactory beanFactory) { StandardEvaluationContext evaluationContext = new StandardEvaluationContext(); evaluationContext.addPropertyAccessor(new BeanFactoryAccessor()); evaluationContext.addPropertyAccessor(new EnvironmentAccessor()); evaluationContext.addPropertyAccessor(new MapAccessor()); evaluationContext.setTypeLocator(new StandardTypeLocator(getBeanClassLoader())); configureTypeConverter(evaluationContext, beanFactory); return evaluationContext; }