use of org.springframework.context.expression.BeanFactoryResolver in project camel by apache.
the class JpaRouteSharedEntityManagerTest method getBrokerCount.
private int getBrokerCount() {
LocalEntityManagerFactoryBean entityManagerFactory = applicationContext.getBean("&entityManagerFactory", LocalEntityManagerFactoryBean.class);
//uses Spring EL so we don't need to reference the classes
StandardEvaluationContext context = new StandardEvaluationContext(entityManagerFactory);
context.setBeanResolver(new BeanFactoryResolver(applicationContext));
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("nativeEntityManagerFactory.brokerFactory.openBrokers");
List<?> brokers = expression.getValue(context, List.class);
return brokers.size();
}
use of org.springframework.context.expression.BeanFactoryResolver in project camel by apache.
the class SpelExpression method createEvaluationContext.
private EvaluationContext createEvaluationContext(Exchange exchange) {
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new RootObject(exchange));
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));
}
return evaluationContext;
}
use of org.springframework.context.expression.BeanFactoryResolver in project spring-framework by spring-projects.
the class EvalTag method createEvaluationContext.
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;
}
use of org.springframework.context.expression.BeanFactoryResolver in project spring-framework by spring-projects.
the class CacheOperationExpressionEvaluator method createEvaluationContext.
/**
* Create an {@link EvaluationContext}.
* @param caches the current caches
* @param method the method
* @param args the method arguments
* @param target the target object
* @param targetClass the target class
* @param result the return value (can be {@code null}) or
* {@link #NO_RESULT} if there is no return at this time
* @return the evaluation context
*/
public EvaluationContext createEvaluationContext(Collection<? extends Cache> caches, Method method, Object[] args, Object target, Class<?> targetClass, Object result, BeanFactory beanFactory) {
CacheExpressionRootObject rootObject = new CacheExpressionRootObject(caches, method, args, target, targetClass);
Method targetMethod = getTargetMethod(targetClass, method);
CacheEvaluationContext evaluationContext = new CacheEvaluationContext(rootObject, targetMethod, args, getParameterNameDiscoverer());
if (result == RESULT_UNAVAILABLE) {
evaluationContext.addUnavailableVariable(RESULT_VARIABLE);
} else if (result != NO_RESULT) {
evaluationContext.setVariable(RESULT_VARIABLE, result);
}
if (beanFactory != null) {
evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory));
}
return evaluationContext;
}
use of org.springframework.context.expression.BeanFactoryResolver in project spring-framework by spring-projects.
the class EventExpressionEvaluator method createEvaluationContext.
/**
* Create the suitable {@link EvaluationContext} for the specified event handling
* on the specified method.
*/
public EvaluationContext createEvaluationContext(ApplicationEvent event, Class<?> targetClass, Method method, Object[] args, BeanFactory beanFactory) {
Method targetMethod = getTargetMethod(targetClass, method);
EventExpressionRootObject root = new EventExpressionRootObject(event, args);
MethodBasedEvaluationContext evaluationContext = new MethodBasedEvaluationContext(root, targetMethod, args, getParameterNameDiscoverer());
if (beanFactory != null) {
evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory));
}
return evaluationContext;
}
Aggregations