Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting CamelContext parameters from java bean

I have an issue with Spring and Camel.

I'm sorry I can't paste real code ... So, I'm trying to get properties defined in the camel Context with a placeholder. But the properties are Empty.

<bean id="mySuperClass"
        class="com.lol.rofl.MySuperClass">
</bean>
<camelContext id="blablabla" xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="myProp"
        location="classpath:camel/contexts/myprops.properties" />
....
Some fantastique code that use the properties and works.
....
</camelContext>

the .java :

public class MySuperClass implements CamelContextAware
{

    public void getCCProperties()
    {
           final Map<String, String> camelContextProperties = camelContext.getProperties();
            crawlerOutputDirectory = camelContextProperties.get("my.super.pro");
    }
}

I just think I'm not trying the right way, thanks for you help


SOLUTION

Properties in placeHolders can be found this way :

camelContext.resolvePropertyPlaceholders("{{" + propertyName + "}}");

ex : camelContext.resolvePropertyPlaceholders("{{output.directory}}");

like image 666
ogdabou Avatar asked Jun 25 '26 00:06

ogdabou


1 Answers

Read the javadoc of the methods, getProperties on CamelContext is not for property placeholder. Use resolvePropertyPlaceholders for property placeholder

javadoc for CamelContext: http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/CamelContext.html

like image 130
Claus Ibsen Avatar answered Jun 28 '26 15:06

Claus Ibsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!