camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Grzegorz Grzybek (JIRA)" <>
Subject [jira] [Resolved] (CAMEL-7456) Camel PropertiesComponent ignores custom parser in Blueprint
Date Mon, 21 Jul 2014 15:18:38 GMT


Grzegorz Grzybek resolved CAMEL-7456.

       Resolution: Fixed
    Fix Version/s:     (was: Future)

{{BlueprintPropertiesParser}} uses provided (configured on {{PropertiesComponent}}) parser
as delegate (see example with {{JasyptPropertiesParser}}).

The provided use case is rather about making {{propertyPrefix/Suffix}} resolvable against
system/env properties and this is how it was resolved.

> Camel PropertiesComponent ignores custom parser in Blueprint
> ------------------------------------------------------------
>                 Key: CAMEL-7456
>                 URL:
>             Project: Camel
>          Issue Type: Bug
>          Components: osgi
>    Affects Versions: 2.12.3
>            Reporter: Joe Luo
>            Assignee: Grzegorz Grzybek
>            Priority: Minor
>             Fix For: 2.12.5, 2.13.3, 2.14.0
> I have implemented a custom PropertiesParser which allows me to use system property placeholders
in propertyPrefix and propertySuffix.
> In my use case the propertyPrefix is defined as "$\{container.stage}.", where container.stage
is a jvm option defined at container creation. The value is one of dev, test and prod.
> This works fine in Java DSL world (SCR bundle), but custom parser is ignored in Blueprint.
Here is sample of my blueprint xml:
> {code}
>  <cm:property-placeholder id="integration" persistent-id="org.apache.camel.sample.temp"
placeholder-prefix="[[" placeholder-suffix="]]">
>     <cm:default-properties>
>         <cm:property name="example" value="this value is the default"/>
>         <cm:property name="dev.example" value="this value is used in development environment"/>
>         <cm:property name="test.example" value="this value is used in test environment"/>
>         <cm:property name="prod.example" value="this value is used in production environment"/>
>     </cm:default-properties>
> </cm:property-placeholder>
> <bean id="parser" class="org.apache.camel.sample.MyCustomPropertiesParser"/>
> <!-- Load properties for current container stage -->
> <bean id="properties" class="">
>     <property name="propertiesParser" ref="parser"/>
>     <property name="propertyPrefix" value="${container.stage}."/>
>     <property name="fallbackToUnaugmentedProperty" value="true"/>
>     <property name="location" value="blueprint:integration,classpath:properties/"/></bean>
> <camelContext id="temp" xmlns="">
>     <route id="exampleRoute">
>         <from uri="timer:foo?period=5000"/>
>         <transform>
>             <simple>{{example}}</simple>
>         </transform>
>         <to uri="log:something"/>
>     </route>
> </camelContext>
> {code}
> The reason it did not work was because by default, it uses blueprint property resolver
(useBlueprintPropertyResolver="true") to bridge PropertiesComponent to blueprint in order
to support looking up property placeholders from the Blueprint Property Placeholder Service.
Then it always creates a BlueprintPropertiesParser object and set it to PropertiesComponent.

> The customer Property Parser I created was only set into the BlueprintPropertiesParser
object as a delegate Property Parser. Therefore, it was always the method parseUri() from
the BlueprintPropertiesParser object got invoked. The same method from your custom parser
was ignored. 
> For more detail, please take a look at org.apache.camel.blueprint.CamelContextFactoryBean.initPropertyPlaceholder()
> The only workaround is to add the attribute useBlueprintPropertyResolver="false" to <camelContext>
element to disable default blueprint property resolver. However, I will have to change PropertiesComponent's
"location" property to remove blueprint "blueprint:integration" from the comma separated value
> {code}
>  <property name="location" value="classpath:properties/"/> 
> {code}
> Because once I set it to false, I will no longer be able to lookup from blueprint property

This message was sent by Atlassian JIRA

View raw message