Refine search
private EvaluationContext createEvaluationContext(PageContext pageContext) { StandardEvaluationContext context = new StandardEvaluationContext(); context.addPropertyAccessor(new JspPropertyAccessor(pageContext)); context.addPropertyAccessor(new MapAccessor()); context.addPropertyAccessor(new EnvironmentAccessor()); context.setBeanResolver(new BeanFactoryResolver(getRequestContext().getWebApplicationContext())); ConversionService conversionService = getConversionService(pageContext); if (conversionService != null) { context.setTypeConverter(new StandardTypeConverter(conversionService)); } return context; }
/** * Get the {@link EvaluationContext} to use to evaluate the configured {@link Expression} */ protected EvaluationContext getEvaluationContext(MethodInvocation methodInvocation, Object... args) { final StandardEvaluationContext evaluationContext = new StandardEvaluationContext(); evaluationContext.setBeanResolver(new BeanFactoryResolver(this.beanFactory)); evaluationContext.setVariable("invocation", methodInvocation); evaluationContext.setVariable("args", args); evaluationContext.setVariable("key", keyCallbackObject); evaluationContext.addMethodResolver(this.methodResolver); return evaluationContext; }
static Object getValue(SpelExpressionParser parser, BeanFactory beanFactory, String entryValue) { Object value; String rawValue = entryValue; if (rawValue != null) { rawValue = rawValue.trim(); } if (rawValue != null && rawValue.startsWith("#{") && entryValue.endsWith("}")) { // assume it's spel StandardEvaluationContext context = new StandardEvaluationContext(); context.setBeanResolver(new BeanFactoryResolver(beanFactory)); Expression expression = parser.parseExpression(entryValue, new TemplateParserContext()); value = expression.getValue(context); } else { value = entryValue; } return value; }
public void setApplicationContext(ApplicationContext applicationContext) { br = new BeanFactoryResolver(applicationContext); } }
@Init public void init() { if (null == beanFactory) { log.error("Spring context not found, can't use spring expression factory"); return; } SpelParserConfiguration c = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, this.getClass().getClassLoader()); spelParser = new SpelExpressionParser(c); evalContext = new StandardEvaluationContext(); envProperty = new EnvPropertyAccessor(env); evalContext.getPropertyAccessors().add(0, envProperty); evalContext.getPropertyAccessors().add(0, new MapPropertyAccessor()); evalContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); }
/** * Specify a BeanFactory in order to enable resolution via <code>@beanName</code> in the expression. */ @Override public void setBeanFactory(final @Nullable BeanFactory beanFactory) { if (beanFactory != null) { this.beanFactory = beanFactory; this.typeConverter.setBeanFactory(beanFactory); if (this.evaluationContext != null && this.evaluationContext.getBeanResolver() == null) { this.evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); } } }
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); this.evaluationContext.addPropertyAccessor(new MapAccessor()); }
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; this.evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); }
/** * {@inheritDoc} */ @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { super.setBeanFactory(beanFactory); this.evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); if (beanFactory instanceof ConfigurableBeanFactory) { ConfigurableBeanFactory configurableBeanFactory = (ConfigurableBeanFactory) beanFactory; this.evaluationContext.setTypeLocator(new StandardTypeLocator(configurableBeanFactory.getBeanClassLoader())); Optional.ofNullable(configurableBeanFactory.getConversionService()) .ifPresent(conversionService -> this.evaluationContext.setTypeConverter(new StandardTypeConverter(conversionService))); } }
private EvaluationContext createEvaluationContext(Exchange exchange) { StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new RootObject(exchange)); if (beanResolver != null) { evaluationContext.setBeanResolver(beanResolver); } else if (exchange.getContext() instanceof SpringCamelContext) { // Support references (like @foo) in expressions to beans defined in the Registry/ApplicationContext ApplicationContext applicationContext = ((SpringCamelContext) exchange.getContext()).getApplicationContext(); evaluationContext.setBeanResolver(new BeanFactoryResolver(applicationContext)); } else { evaluationContext.setBeanResolver(new RegistryBeanResolver(exchange.getContext().getRegistry())); } return evaluationContext; }
public void setApplicationContext(ApplicationContext applicationContext) { br = new BeanFactoryResolver(applicationContext); } }
@Override public void setBeanFactory(final BeanFactory beanFactory) { if (beanFactory != null) { this.beanFactory = beanFactory; this.typeConverter.setBeanFactory(beanFactory); if (this.evaluationContext != null && this.evaluationContext.getBeanResolver() == null) { this.evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); } } }
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); this.evaluationContext.addPropertyAccessor(new MapAccessor()); }
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); }
sec = new StandardEvaluationContext(evalContext); sec.addPropertyAccessor(new BeanExpressionContextAccessor()); sec.addPropertyAccessor(new BeanFactoryAccessor()); sec.addPropertyAccessor(new MapAccessor()); sec.addPropertyAccessor(new EnvironmentAccessor()); sec.setBeanResolver(new BeanFactoryResolver(evalContext.getBeanFactory())); sec.setTypeLocator(new StandardTypeLocator(evalContext.getBeanFactory().getBeanClassLoader())); ConversionService conversionService = evalContext.getBeanFactory().getConversionService();
private String evaluateSpel(String in) { StandardEvaluationContext evalContext = new StandardEvaluationContext(); evalContext.setBeanResolver(new ThisBeanResolver(new BeanFactoryResolver(fact))); SpelExpressionParser parser = new SpelExpressionParser(); Expression expr = parser.parseExpression(in, new TemplateParserContext()); return expr.getValue(evalContext).toString(); }
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.beanResolver = new BeanFactoryResolver(applicationContext.getAutowireCapableBeanFactory()); } }
/** * Specify a BeanFactory in order to enable resolution via <code>@beanName</code> in the expression. */ @Override public void setBeanFactory(final @Nullable BeanFactory beanFactory) { if (beanFactory != null) { this.beanFactory = beanFactory; this.typeConverter.setBeanFactory(beanFactory); if (this.evaluationContext != null && this.evaluationContext.getBeanResolver() == null) { this.evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); } } }
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); }
private EvaluationContext createEvaluationContext(PageContext pageContext) { StandardEvaluationContext context = new StandardEvaluationContext(); context.addPropertyAccessor(new JspPropertyAccessor(pageContext)); context.addPropertyAccessor(new MapAccessor()); context.addPropertyAccessor(new EnvironmentAccessor()); context.setBeanResolver(new BeanFactoryResolver(getRequestContext().getWebApplicationContext())); ConversionService conversionService = getConversionService(pageContext); if (conversionService != null) { context.setTypeConverter(new StandardTypeConverter(conversionService)); } return context; }