Update the map on change .cfg file on Karaf

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Update the map on change .cfg file on Karaf

Dominik Marciniszyn
Hi,
I have defined map based on values from my .cfg file on Karaf. In java code I use ConfigurationAdmin and Configuration to fill the map. I would like to update my map when .cfg file was modified but without restaring bundle. Is it possible to do?

Thank you for any advice,
Dominik Marciniszyn
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Update the map on change .cfg file on Karaf

Guillaume Nodet-2
The standard way to obtain the configuration is to registered a
ManagedService object in the OSGi registry.
ConfigAdmin will call it when published, and whenever the configuration is
changed.  You don't have to restart your bundle.

2017-07-14 10:39 GMT+02:00 Dominik Marciniszyn <
[hidden email]>:

> Hi,
> I have defined map based on values from my .cfg file on Karaf. In java code
> I use ConfigurationAdmin and Configuration to fill the map. I would like to
> update my map when .cfg file was modified but without restaring bundle. Is
> it possible to do?
>
> Thank you for any advice,
> Dominik Marciniszyn
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.
> com/Update-the-map-on-change-cfg-file-on-Karaf-tp4051008.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>



--
------------------------
Guillaume Nodet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Update the map on change .cfg file on Karaf

David Jencks-3
You may find using a DS component with required configuration and configuration via an annotation considerably simpler.

david jencks

> On Jul 14, 2017, at 11:35 PM, Guillaume Nodet <[hidden email]> wrote:
>
> The standard way to obtain the configuration is to registered a
> ManagedService object in the OSGi registry.
> ConfigAdmin will call it when published, and whenever the configuration is
> changed.  You don't have to restart your bundle.
>
> 2017-07-14 10:39 GMT+02:00 Dominik Marciniszyn <
> [hidden email]>:
>
>> Hi,
>> I have defined map based on values from my .cfg file on Karaf. In java code
>> I use ConfigurationAdmin and Configuration to fill the map. I would like to
>> update my map when .cfg file was modified but without restaring bundle. Is
>> it possible to do?
>>
>> Thank you for any advice,
>> Dominik Marciniszyn
>>
>>
>>
>> --
>> View this message in context: http://karaf.922171.n3.nabble.
>> com/Update-the-map-on-change-cfg-file-on-Karaf-tp4051008.html
>> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>>
>
>
>
> --
> ------------------------
> Guillaume Nodet

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Update the map on change .cfg file on Karaf

Dominik Marciniszyn
In reply to this post by Guillaume Nodet-2
Thank you, I've used this method and it works good for one file. But I saw If I would like to handle multiple .cfg files there is a problem. I found an example of using updated callback function. To do this I need to first register service and then I can use this method. But in case of many files I cannot do this. Is there other way to achieve this?
Loading...