[ 
https://issues.apache.org/jira/browse/CAMEL-12683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16556083#comment-16556083
 ] 

Zoran Regvart commented on CAMEL-12683:
---------------------------------------

Camel already has support for 
[SpEL|https://github.com/apache/camel/blob/master/components/camel-spring/src/main/docs/spel-language.adoc]
 and you can access methods of objects found in registry using the [bean method 
language|https://github.com/apache/camel/blob/master/camel-core/src/main/docs/bean-language.adoc].
 [~christianr] can you explain what would this add that those two already 
supported features do not?

> When lookup the registry, Camel should support more complex expressions like 
> 'myBean.property'
> ----------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-12683
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12683
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-spring
>    Affects Versions: 2.21.1
>            Reporter: Christian Ribeaud
>            Priority: Major
>
> Currently, only simple *Spring* beans lookup is supported, like {{#myBean}}. 
> Deeper lookup is currently not supported. As a workaround, you could specify 
> several *Spring* beans which then maps to the properties of the original bean.
> Following code snipped would, for instance, make possible more complex 
> queries:
> {code:java}
> public class MyApplicationContextRegistry extends ApplicationContextRegistry {
>     private final BeanResolver beanResolver;
>     private final PropertyAccessor propertyAccessor;
>     private final BeanExpressionContext beanExpressionContext;
>     MyApplicationContextRegistry(ApplicationContext applicationContext) {
>         super(applicationContext);
>         beanResolver = new BeanFactoryResolver(applicationContext);
>         propertyAccessor = new BeanExpressionContextAccessor();
>         beanExpressionContext = createExpressionContext(applicationContext);
>     }
>     @Override
>     public Object lookupByName(final String name) {
>         assert name != null : "Unspecified name";
>         final ExpressionParser parser = new SpelExpressionParser();
>         Expression expression = parser.parseExpression(name);
>         Object expressionValue = 
> expression.getValue(createEvaluationContext(), beanExpressionContext);
>         return expressionValue;
>     }
>     private static BeanExpressionContext 
> createExpressionContext(ApplicationContext applicationContext) {
>         assert applicationContext instanceof ConfigurableApplicationContext : 
> String.format("MUST be an instance of '%s'.", 
> ConfigurableApplicationContext.class.getName());
>         ConfigurableBeanFactory configurableBeanFactory = 
> ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
>         return new BeanExpressionContext(configurableBeanFactory, null);
>     }
>     private EvaluationContext createEvaluationContext() {
>         StandardEvaluationContext context = new StandardEvaluationContext();
>         context.setBeanResolver(beanResolver);
>         context.addPropertyAccessor(propertyAccessor);
>         return context;
>     }
> }
> {code}
> And this code uses _out-of-the-box_ *Spring* functionalities (I think...).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to