[ https://issues.apache.org/jira/browse/CAMEL-10352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15529157#comment-15529157 ]
Grzegorz Grzybek edited comment on CAMEL-10352 at 9/28/16 10:19 AM: -------------------------------------------------------------------- Currently, in Blueprint Camel contexts we can do ({{useBlueprintPropertyResolver="true"}} is default): {code:xml} <cm:property-placeholder persistent-id="my-placeholders" useBlueprintPropertyResolver="true"> <cm:default-properties> <cm:property name="greeting" value="Hello"/> <cm:property name="destination" value="mock:result"/> </cm:default-properties> </cm:property-placeholder> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route> <from uri="direct:start"/> <transform> <simple>{{greeting}} ${body}</simple> </transform> <to uri="{{destination}}"/> </route> </camelContext> {code} useBlueprintPropertyResolver="true" makes PropertiesComponent aware of Aries {{org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder}} instances, like {{<cm:property-placeholder>}} or {{<ext:property-placeholder>}}. There's however another feature of Blueprint property placeholder resolvers: {{org.apache.aries.blueprint.ext.evaluator.PropertyEvaluator}}. This evaluator is used ONLY when postprocessing blueprint CDR (component definition registry) - similar to Spring's BeanFactoryPostprocessors. So if we have something like this in Blueprint XML: {code:xml} <bean id="myBean" class="my.Bean"> <argument value="${x.y.z}"/> </bean> {code} evaluator will be used, because {{${x.y.z}}} is resolved at _component registry postprocessing time_. But it won't be used here: {code:xml} <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route> <from uri="direct:start"/> <transform> <simple>{{x.y.z}}</simple> </transform> <to uri="{{destination}}"/> </route> </camelContext> {code} because even if Camel's PropertiesComponent will delegate to Blueprint (from {{org.apache.camel.blueprint.BlueprintPropertiesParser#parseProperty()}} call to e.g., {{org.apache.aries.blueprint.ext.PropertyPlaceholder#getProperty()}}), Blueprint won't use PropertyEvaluator any more. h2. Possible solution If we add another attribute to {{{http://camel.apache.org/schema/blueprint}camelContext}}, like this (defaults to {{false}}): {code:xml} <camelContext xmlns="http://camel.apache.org/schema/blueprint" useBlueprintPropertyResolver="true" useBlueprintPropertyEvaluator="true"> {code} and enhance {{org.apache.camel.blueprint.BlueprintPropertiesParser#lookupPropertyPlaceholderIds()}} to lookup beans with {{org.apache.aries.blueprint.ext.evaluator.PropertyEvaluator}} class (in addition to {{org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder}}), these additional property resolvers could be used in {{org.apache.camel.blueprint.BlueprintPropertiesParser#parseProperty()}}. So, {{org.apache.camel.blueprint.BlueprintPropertiesParser#parseProperty()}} could use two _for_ loops: * one over _property sources_ (current behavior): {code:xml} for (AbstractPropertyPlaceholder placeholder : placeholders) { ... {code} * new one over _property evaluators_ (new behavior): {code:xml} for (org.apache.aries.blueprint.ext.evaluator.PropertyEvaluator evaluator : evaluators { ... String answer = evaluator.evaluate(key, ...); {code} what do you think? was (Author: gzres): Currently, in Blueprint Camel contexts we can do ({{useBlueprintPropertyResolver="true"}} is default): {code:xml} <cm:property-placeholder persistent-id="my-placeholders" useBlueprintPropertyResolver="true"> <cm:default-properties> <cm:property name="greeting" value="Hello"/> <cm:property name="destination" value="mock:result"/> </cm:default-properties> </cm:property-placeholder> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route> <from uri="direct:start"/> <transform> <simple>{{greeting}} ${body}</simple> </transform> <to uri="{{destination}}"/> </route> </camelContext> {code} useBlueprintPropertyResolver="true" makes PropertiesComponent aware of Aries {{org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder}} instances, like {{<cm:property-placeholder>}} or {{<ext:property-placeholder>}}. There's however another feature of Blueprint property placeholder resolvers: {{org.apache.aries.blueprint.ext.evaluator.PropertyEvaluator}}. This evaluator is used ONLY when postprocessing blueprint CDR (component definition registry) - similar to Spring's BeanFactoryPostprocessors. So if we have something like this in Blueprint XML: {code:xml} <bean id="myBean" class="my.Bean"> <argument value="${x.y.z}"/> </bean> {code} evaluator will be used, because {{${x.y.z}}} is resolved at _component registry postprocessing time_. But it won't be used here: {code:xml} <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route> <from uri="direct:start"/> <transform> <simple>{{x.y.z}}</simple> </transform> <to uri="{{destination}}"/> </route> </camelContext> {code} because even if Camel's PropertiesComponent will delegate to Blueprint (from {{org.apache.camel.blueprint.BlueprintPropertiesParser#parseProperty()}} call to e.g., {{org.apache.aries.blueprint.ext.PropertyPlaceholder#getProperty()}}), Blueprint won't use PropertyEvaluator any more. h2. Possible solution If we add another attribute to {{{http�x3a;//camel.apache.org/schema/blueprint}camelContext}}, like this (defaults to {{false}}): {code:xml} <camelContext xmlns="http://camel.apache.org/schema/blueprint" useBlueprintPropertyResolver="true" useBlueprintPropertyEvaluator="true"> {code} and enhance {{org.apache.camel.blueprint.BlueprintPropertiesParser#lookupPropertyPlaceholderIds()}} to lookup beans with {{org.apache.aries.blueprint.ext.evaluator.PropertyEvaluator}} class (in addition to {{org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder}}), these additional property resolvers could be used in {{org.apache.camel.blueprint.BlueprintPropertiesParser#parseProperty()}}. So, {{org.apache.camel.blueprint.BlueprintPropertiesParser#parseProperty()}} could use two _for_ loops: * one over _property sources_ (current behavior): {code:xml} for (AbstractPropertyPlaceholder placeholder : placeholders) { ... {code} * new one over _property evaluators_ (new behavior): {code:xml} for (org.apache.aries.blueprint.ext.evaluator.PropertyEvaluator evaluator : evaluators { ... String answer = evaluator.evaluate(key, ...); {code} what do you think? > Optionally delegate to Aries PropertyEvaluator services in > BlueprintPropertiesParser > ------------------------------------------------------------------------------------ > > Key: CAMEL-10352 > URL: https://issues.apache.org/jira/browse/CAMEL-10352 > Project: Camel > Issue Type: Improvement > Components: camel-blueprint, osgi > Reporter: Grzegorz Grzybek > Assignee: Luca Burgazzoli > -- This message was sent by Atlassian JIRA (v6.3.4#6332)