You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by Dominik Marciniszyn <ma...@gmail.com> on 2017/07/14 08:39:11 UTC

Update the map on change .cfg file on Karaf

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.

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

Posted by David Jencks <da...@yahoo.com.INVALID>.
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 <gn...@apache.org> 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 <
> marciniszyn.dominik@gmail.com>:
> 
>> 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


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

Posted by Dominik Marciniszyn <ma...@gmail.com>.
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?



--
View this message in context: http://karaf.922171.n3.nabble.com/Update-the-map-on-change-cfg-file-on-Karaf-tp4051008p4051024.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

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

Posted by Guillaume Nodet <gn...@apache.org>.
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 <
marciniszyn.dominik@gmail.com>:

> 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