How to use camel component properties outside camel context

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use camel component properties outside camel context

stibi
Hello,
I have troubles with properties files in Camel.
I know how to define bean with location property to my properties
file, then I can use it in camel context with {{key.something}}.
I'd expect that it's working in the same way also outside the camel
context, I tried also different syntaxe - ${key.something} - but, this
is not working.

Complete example:

<blueprint>
    <bean id="properties"
class="org.apache.camel.component.properties.PropertiesComponent">
        <property name="location" value="classpath:my.properties"/>
    </bean>
    <bean id="myBean" class="my.Bean">
        <property name="something" value="${key.something}" /> <!--
not working :( -->
    </bean>

    <camelContext>
    </camelContext

</blueprint>


Is there a possibility to use one properties file both inside and
outside camel context?

Thanks!

--
S pozdravem
Martin Stiborský

Jabber: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to use camel component properties outside camel context

Willem.Jiang
Administrator
Hi,  

camel property component supports blueprint property out of box, and you can leverage the OSGi admin service to update the property for you.

here is an example[1] that you may take a look.  

[1]http://fusesource.com/docs/esbent/7.0/esb_deploy_osgi/DeployCamel-OsgiConfigProps.html
--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: willemjiang





On Saturday, October 20, 2012 at 6:54 AM, Martin Stiborský wrote:

> Hello,
> I have troubles with properties files in Camel.
> I know how to define bean with location property to my properties
> file, then I can use it in camel context with {{key.something}}.
> I'd expect that it's working in the same way also outside the camel
> context, I tried also different syntaxe - ${key.something} - but, this
> is not working.
>  
> Complete example:
>  
> <blueprint>
> <bean id="properties"
> class="org.apache.camel.component.properties.PropertiesComponent">
> <property name="location" value="classpath:my.properties"/>
> </bean>
> <bean id="myBean" class="my.Bean">
> <property name="something" value="${key.something}" /> <!--
> not working :( -->
> </bean>
>  
> <camelContext>
> </camelContext
>  
> </blueprint>
>  
>  
> Is there a possibility to use one properties file both inside and
> outside camel context?
>  
> Thanks!
>  
> --  
> S pozdravem
> Martin Stiborský
>  
> Jabber: [hidden email] (mailto:[hidden email])  


Reply | Threaded
Open this post in threaded view
|

Re: How to use camel component properties outside camel context

stibi
Hi Willem,

thanks a lot, it works :)

On Sat, Oct 20, 2012 at 5:59 AM, Willem jiang <[hidden email]> wrote:

> Hi,
>
> camel property component supports blueprint property out of box, and you can leverage the OSGi admin service to update the property for you.
>
> here is an example[1] that you may take a look.
>
> [1]http://fusesource.com/docs/esbent/7.0/esb_deploy_osgi/DeployCamel-OsgiConfigProps.html
> --
> Willem Jiang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
>           http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: willemjiang
>
>
>
>
>
> On Saturday, October 20, 2012 at 6:54 AM, Martin Stiborský wrote:
>
>> Hello,
>> I have troubles with properties files in Camel.
>> I know how to define bean with location property to my properties
>> file, then I can use it in camel context with {{key.something}}.
>> I'd expect that it's working in the same way also outside the camel
>> context, I tried also different syntaxe - ${key.something} - but, this
>> is not working.
>>
>> Complete example:
>>
>> <blueprint>
>> <bean id="properties"
>> class="org.apache.camel.component.properties.PropertiesComponent">
>> <property name="location" value="classpath:my.properties"/>
>> </bean>
>> <bean id="myBean" class="my.Bean">
>> <property name="something" value="${key.something}" /> <!--
>> not working :( -->
>> </bean>
>>
>> <camelContext>
>> </camelContext
>>
>> </blueprint>
>>
>>
>> Is there a possibility to use one properties file both inside and
>> outside camel context?
>>
>> Thanks!
>>
>> --
>> S pozdravem
>> Martin Stiborský
>>
>> Jabber: [hidden email] (mailto:[hidden email])
>
>



--
S pozdravem
Martin Stiborský

Jabber: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to use camel component properties outside camel context

martin11
Hello,

I have the same problem like Martin above, but I still don`t understand how it should be resolved by osgi or blueprint.
I use property file and I want to read these properties inside application context with camel-context and also for spring beans.
How can I read the property file by using <osgix:cm-properties> ?
Would you please explain it in more detail? or just put your configuration?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: How to use camel component properties outside camel context

stibi
Hello Martin, Blueprint configuration admin service is the key.

http://www.liquid-reality.de/display/liquid/2011/09/23/Karaf+Tutorial+Part+2+-+Using+the+Configuration+Admin+Service

I can send you a complete code example, but right now I have just phone
available.

If nobody help you sooner, I'll post more details here later today.
On Nov 16, 2012 3:06 PM, "martin11" <[hidden email]> wrote:

> Hello,
>
> I have the same problem like Martin above, but I still don`t understand how
> it should be resolved by osgi or blueprint.
> I use property file and I want to read these properties inside application
> context with camel-context and also for spring beans.
> How can I read the property file by using <osgix:cm-properties> ?
> Would you please explain it in more detail? or just put your configuration?
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-use-camel-component-properties-outside-camel-context-tp5721318p5722861.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: How to use camel component properties outside camel context

martin11
yes, it would be very helpful to see your blueprint context. Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: How to use camel component properties outside camel context

stibi
Hi!

Here is the promised configuration for Blueprint Admin service.

blueprint.xml:

<blueprint>
...
    <!-- Load in application properties reference -->
    <cm:property-placeholder persistent-id="etb.esb.config">
        <cm:default-properties>
            <cm:property name="foo.conf.value" value="foo"/>
            <cm:property name="bar.conf.value" value="bar"/>
        </cm:default-properties>
    </cm:property-placeholder>
...
</blueprint>

And that's all. Place the "etb.esb.config" file in karaf's etc/ and go use
it.

Usage outside camel context:

<bean id="myBean" class="com.myProject.myBean">
        <property name="myProperty" value="${foo.conf.value}"/>
</bean>

Within Camel context is the usage the same, only format of the config
"placeholders" is a little bi different:
Try "{bar.conf.value}". Hope I"m not wrong here, I don't have such real
example in my project and I can't test it right now.

Also you can use it within Java code easily, if you need code example for
that, I can find you for it. I've used it somewhere.




On Fri, Nov 16, 2012 at 4:41 PM, martin11 <[hidden email]> wrote:

> yes, it would be very helpful to see your blueprint context. Thank you.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-use-camel-component-properties-outside-camel-context-tp5721318p5722880.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
S pozdravem / Best regards
Martin Stiborský

Jabber: [hidden email]
Twitter: http://www.twitter.com/stibi