felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre De Rop <pierre.de...@gmail.com>
Subject Re: configurationAdmin & update handler
Date Sat, 04 Feb 2012 09:22:10 GMT
Hi Mohica,

I think I have reproduced the issue you describe, and after having checked,
the root cause of the problem is probably the following:

By default, fileinstall listens to  configuration updates, using the
ConfigAdmin interface "org.osgi.service.cm.ConfigurationListener" interface.
So, when you programatically change the configuration pid from your web
interface, using org.osgi.service.cm.Configuration.update() method, then
fileinstall is notified, and then writes back the configuration update in
your "etc/mypid.cfg" file. This behavior has the side effect of re-updating
the configuration pid, that's why your pojo's "updated" callback is invoked

Now, if you set the following fileinstall system propery in your felix
config.properties, the the problem disappears:


You can have a look at the fileinstall online documentation, about this


kind regards;

On Thu, Feb 2, 2012 at 4:42 PM, Mohica Jasha <mohica.jasha@gmail.com> wrote:

> Hi,
> I have the following configuration dependency and its corresponding update
> handler method:
> @ConfigurationDependency(pid = "mypid", propagate = true)
> void updated(Dictionary<String, ?> properties) throws
> ConfigurationException {
>    ....
> }
> If I change the configuration of mypid either by editing the etc/mypid.cfg
> or by editing the configurion through the felix-webconsole everything works
> fine and the above "updated" method will be called EXACTLY ONCE to handle
> the new configuration.
> Let's say the content of etc/mypid.cfg is the following:
> oldParam = oldValue
> I have implemented a webinterface for my service within the same bundle,
> the webinterface through the following operations tries to update the
> configuration of mypid:
> Configuration config = configurationAdmin.getConfiguration("mypid", null);
> Dictionary properties = new Hashtable<String, String>();
> properties.put("felix.fileinstall.filename",
> "file:/Users/mohica/apps/apache-karaf-2.2.5/etc/mypid.cfg");
> properties.put("newParam", "newValue");
> config.update(properties);
> Now the problem is that the "updated" method will be called TWICE:
> First with the following properties:
> {service.pid=mypid, newparam=newValue,
> felix.fileinstall.filename=file:/Users/mohica/apps/apache-karaf-2.2.5/etc/mypid.cfg}
> and the second time with the following properties:
> {service.pid=mypid, newparam=newValue,
> felix.fileinstall.filename=file:/Users/mohica/apps/apache-karaf-2.2.5/etc/mypid.cfg,
> oldparam=oldValue}
> Why is it called twice? Am I doing anything wrong?
> Mohica

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message