camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Possible to use nested properties with both spring and camel property placeholders?
Date Fri, 04 Nov 2016 03:22:54 GMT
It looks like you are using the Spring and Camel Properties component together.
Camel support the {{}} syntax out of box , so you just need to find a way to let the spring
bean too support :)  

--  
Willem Jiang


Blog: http://willemjiang.blogspot.com (English)  
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On November 3, 2016 at 9:20:25 PM, jimi.hullegard@svensktnaringsliv.se (jimi.hullegard@svensktnaringsliv.se)
wrote:
> Hi,
>  
> I have a Camel project that uses Spring XML, with various settings in a separate settings.properties
 
> file. And these settings are used both in plain Spring XML (like arguments to java beans)
 
> and in Camel specific configuration (like endpoint URI).
>  
> Here is the part of my camel-context.xml that configures this:
>  
>  
> > />
>  
>  
>  
>  
>  
>  
>  
> #{settingsFileLocation}
>  
>  
>  
>  
>  
>  
>  
>  
>  
> #{settingsFileLocation}
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
> And my settings.properties looks like something like this:
>  
> mainDirectory=/opt/main
> inputDirectory=/opt/main/input
> tempDirectory=/opt/main/temp
> outputDirectory=/opt/main/output
> otherDirectory=/opt/main/other
> etc...
>  
> Also, there are one main settings.properties file, and then one environment-specific
 
> file, that overrides some properties.
>  
> Now, since there are several properties for directories under the main directory, instead
 
> of having to specify "/opt/main" for each one, I would like to re-use the property mainDirectory
 
> somehow. Not only would it reduce the manual workload if I would decide to move this
folder  
> to a different path, it would mean that I would only have to define inputDirectory, tempDirectory
 
> etc in the main settings.properties, and only need to define the mainDirectory property
 
> in the environment specific settings.properties.
>  
> But... I can't figure out how to achieve this. If I use this syntax:
>  
> mainDirectory=/opt/main
> inputDirectory={{mainDirectory}}/input
>  
>  
> Then the {{mainDirectory}} isn't replaced when inputDirectory is used when setting  
> up a spring bean
>  
> And if I use this syntax:
>  
> mainDirectory=/opt/main
> inputDirectory=#{mainDirectory}/input
>  
> Then I get:
>  
> Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos
 
> 0): Property or field 'mainDirectory' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'
 
> - maybe not public?
>  
> Does it exist any solution to this problem? I use Camel 2.17.
>  
> Regards
> /Jimi
>  


Mime
View raw message