You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Debraj Manna <su...@gmail.com> on 2016/03/02 12:50:11 UTC

Dynamic Config Loading in Camel Application Bundle in Karaf 3.0.5

I have a simple Camel Application bundle which is to be deployed in Karaf
3.0.5 under Apache Service Mix 6.1. The configuration file is placed in etc/
directory (let's say it is named as wf.cfg). I want to have the dynamic
config change functionality in my application bundle. So that whenever
something is changed in wf.cfg it is immediately available to bundle. For
this I have added the following in my blueprint.xml

<cm:property-placeholder persistent-id="wf"
    update-strategy="reload">
    <cm:default-properties>
        <cm:property name="env" value="local" />
    </cm:default-properties>
</cm:property-placeholder>

<!-- a bean that uses a blueprint property placeholder -->
<bean id="configBean"
class="com.jabong.orchestratorservice.basecomponent.config.ConfigBean">
        <property name="env" value="${env}" />
</bean>


The problem I am facing now is if the update-strategy is set to reload.
Then it seems to be reloading the entire bean.

Can someone let me know is there a way I can reload only the configBean not
the entire bundle? If I can achieve this then may be I can have some static
reference to the config variables inside the configBean which my
application bundle can then make use of?

The full blueprint.xml is placed here
<https://gist.github.com/anonymous/b7482ab89766a57b162d>.

RE: Dynamic Config Loading in Camel Application Bundle in Karaf 3.0.5

Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
I'm not too sure whether this is the right place/thread to discuss about DS vs Blueprint, but IMHO DS offers less possibilities than Blueprint.

Anyway, as far as I know you can't. But you may deal with the ConfigurationAdmin, BundleContext and ManagedService. I've wrapped all this to make it easy (and to rely as less as possible on OSGi specific API) with a couple of beans and a whiteboard interface to deal with config updates. Now it's handy in Blueprint and it deals with config updates without restarting anything :)

I guess you have to do the same. Good luck,
JP

De : David Jencks [mailto:david_jencks@yahoo.com]
Envoyé : mercredi 2 mars 2016 18:20
À : user@karaf.apache.org
Objet : Re: Dynamic Config Loading in Camel Application Bundle in Karaf 3.0.5

It would be a big change, but you might consider switching your application to use declarative services rather than  blueprint.  IMO blueprint is sort of spring shoehorned to sort of vaguely work a little bit in OSGI whereas DS is actually designed from the start to take full advantage of osgi.

david jencks

On Mar 2, 2016, at 3:50 AM, Debraj Manna <su...@gmail.com>> wrote:


I have a simple Camel Application bundle which is to be deployed in Karaf 3.0.5 under Apache Service Mix 6.1. The configuration file is placed in etc/ directory (let's say it is named as wf.cfg). I want to have the dynamic config change functionality in my application bundle. So that whenever something is changed in wf.cfg it is immediately available to bundle. For this I have added the following in my blueprint.xml

<cm:property-placeholder persistent-id="wf"

    update-strategy="reload">

    <cm:default-properties>

        <cm:property name="env" value="local" />

    </cm:default-properties>

</cm:property-placeholder>



<!-- a bean that uses a blueprint property placeholder -->

<bean id="configBean" class="com.jabong.orchestratorservice.basecomponent.config.ConfigBean">

        <property name="env" value="${env}" />

</bean>

The problem I am facing now is if the update-strategy is set to reload. Then it seems to be reloading the entire bean.
Can someone let me know is there a way I can reload only the configBean not the entire bundle? If I can achieve this then may be I can have some static reference to the config variables inside the configBean which my application bundle can then make use of?
The full blueprint.xml is placed here<https://gist.github.com/anonymous/b7482ab89766a57b162d>.





Re: Dynamic Config Loading in Camel Application Bundle in Karaf 3.0.5

Posted by David Jencks <da...@yahoo.com>.
It would be a big change, but you might consider switching your application to use declarative services rather than  blueprint.  IMO blueprint is sort of spring shoehorned to sort of vaguely work a little bit in OSGI whereas DS is actually designed from the start to take full advantage of osgi.

david jencks

> On Mar 2, 2016, at 3:50 AM, Debraj Manna <su...@gmail.com> wrote:
> 
> 
> I have a simple Camel Application bundle which is to be deployed in Karaf 3.0.5 under Apache Service Mix 6.1. The configuration file is placed in etc/ directory (let's say it is named as wf.cfg). I want to have the dynamic config change functionality in my application bundle. So that whenever something is changed in wf.cfg it is immediately available to bundle. For this I have added the following in my blueprint.xml
> 
> <cm:property-placeholder persistent-id="wf"
>     update-strategy="reload">
>     <cm:default-properties>
>         <cm:property name="env" value="local" />
>     </cm:default-properties>
> </cm:property-placeholder>
> 
> <!-- a bean that uses a blueprint property placeholder -->
> <bean id="configBean" class="com.jabong.orchestratorservice.basecomponent.config.ConfigBean">
>         <property name="env" value="${env}" />
> </bean>
> 
> 
> The problem I am facing now is if the update-strategy is set to reload. Then it seems to be reloading the entire bean.
> 
> Can someone let me know is there a way I can reload only the configBean not the entire bundle? If I can achieve this then may be I can have some static reference to the config variables inside the configBean which my application bundle can then make use of?
> 
> The full blueprint.xml is placed here <https://gist.github.com/anonymous/b7482ab89766a57b162d>.
> 
> 
> 
> 
> 
> 
> 


Re: Dynamic Config Loading in Camel Application Bundle in Karaf 3.0.5

Posted by Debraj Manna <su...@gmail.com>.
Thanks. This is what I was looking for.

On Thu, Mar 3, 2016 at 11:41 PM, Łukasz Dywicki <lu...@code-house.org> wrote:

>
> Hey Debraj,
> If you would like to reload just your bean add <cm:managed-properties
> pid=„wf” update-strategy="component-managed" update-method="methodToCall" />
> element inside „configBean” definition. Each update will result in calling
> given method. I don’t remember if it will set properties first. Other
> strategy which you could try is container-managed. For sure both will
> behave as managed service proxy.
>
> Best regards,
> Łukasz
> —
> luke@code-house.org
> Twitter: ldywicki
> Blog: http://dywicki.pl
> Code-House - http://code-house.org
>
>
>
> Wiadomość napisana przez Debraj Manna <su...@gmail.com> w dniu 2
> mar 2016, o godz. 12:50:
>
>
> I have a simple Camel Application bundle which is to be deployed in Karaf
> 3.0.5 under Apache Service Mix 6.1. The configuration file is placed in
> etc/ directory (let's say it is named as wf.cfg). I want to have the
> dynamic config change functionality in my application bundle. So that
> whenever something is changed in wf.cfg it is immediately available to
> bundle. For this I have added the following in my blueprint.xml
>
> <cm:property-placeholder persistent-id="wf"
>     update-strategy="reload">
>     <cm:default-properties>
>         <cm:property name="env" value="local" />
>     </cm:default-properties>
> </cm:property-placeholder>
>
> <!-- a bean that uses a blueprint property placeholder -->
> <bean id="configBean" class="com.jabong.orchestratorservice.basecomponent.config.ConfigBean">
>         <property name="env" value="${env}" />
> </bean>
>
>
> The problem I am facing now is if the update-strategy is set to reload.
> Then it seems to be reloading the entire bean.
>
> Can someone let me know is there a way I can reload only the configBean
> not the entire bundle? If I can achieve this then may be I can have some
> static reference to the config variables inside the configBean which my
> application bundle can then make use of?
>
> The full blueprint.xml is placed here
> <https://gist.github.com/anonymous/b7482ab89766a57b162d>.
>
>
>
>
>
>

Re: Dynamic Config Loading in Camel Application Bundle in Karaf 3.0.5

Posted by Łukasz Dywicki <lu...@code-house.org>.
Hey Debraj,
If you would like to reload just your bean add <cm:managed-properties pid=„wf” update-strategy="component-managed" update-method="methodToCall" /> element inside „configBean” definition. Each update will result in calling given method. I don’t remember if it will set properties first. Other strategy which you could try is container-managed. For sure both will behave as managed service proxy.

Best regards,
Łukasz
—
luke@code-house.org
Twitter: ldywicki
Blog: http://dywicki.pl
Code-House - http://code-house.org



> Wiadomość napisana przez Debraj Manna <su...@gmail.com> w dniu 2 mar 2016, o godz. 12:50:
> 
> 
> I have a simple Camel Application bundle which is to be deployed in Karaf 3.0.5 under Apache Service Mix 6.1. The configuration file is placed in etc/ directory (let's say it is named as wf.cfg). I want to have the dynamic config change functionality in my application bundle. So that whenever something is changed in wf.cfg it is immediately available to bundle. For this I have added the following in my blueprint.xml
> 
> <cm:property-placeholder persistent-id="wf"
>     update-strategy="reload">
>     <cm:default-properties>
>         <cm:property name="env" value="local" />
>     </cm:default-properties>
> </cm:property-placeholder>
> 
> <!-- a bean that uses a blueprint property placeholder -->
> <bean id="configBean" class="com.jabong.orchestratorservice.basecomponent.config.ConfigBean">
>         <property name="env" value="${env}" />
> </bean>
> 
> 
> The problem I am facing now is if the update-strategy is set to reload. Then it seems to be reloading the entire bean.
> 
> Can someone let me know is there a way I can reload only the configBean not the entire bundle? If I can achieve this then may be I can have some static reference to the config variables inside the configBean which my application bundle can then make use of?
> 
> The full blueprint.xml is placed here <https://gist.github.com/anonymous/b7482ab89766a57b162d>.
> 
> 
> 
> 
> 
> 
>