Hi Tom, Am Montag, den 11.02.2008, 10:07 +0100 schrieb Tom Remoleur: > Hi everyone, > > I'm using felix configuration admin implementation since long time now and > it's works great,
Thanks ;-) > but I've got some big problems with the OSGI > configuration admin specification : > When a update() is called on a configuration, the configuration admin > service, first, will store the configuration and after, will schedule the > call of the updated function on the ManagedService This is how I understand the Configuration Admin Service specification, yes. > > My problems are here : > -If during the execution of ManagedService.updated(), the new > configuration can't be applied, the only way to restore previous > configuration that I've found is to recall update function on the > configuration with previous dictionnary. > But this solution need my ManagedService to have a dependance with the > configuration admin service and so break the white board pattern, > furthermore, even if I raise a ConfigurationException, a > ConfigurationEvent.CM_UPDATED is fired and can create some bugs in my > application. The easy solution to this problem might be for the ManagedService to just not update according to the new configuration and throw a ConfigurationException. This however will not be stable across restarts of the ManagedService itself. So the next best thing might be that the ManagedService persists the valid configuration and only updates this persistent cache if the provided configuration is valid. You may do this by accessing bundle private data through BundleContext.getDataFile(String path). So you keep your own copy of a valid configuration, yet enable being updated through the Configuration Admin Service. > > -My second problem is when a suthdown or a crash occurs after the > configuration is save but before that the ManagedService.updated() > function was called, if the configuration was good, no problems, but if > the new configuration has problems, I can't restore the previous > configuration after my application restart. If you keep a copy of your good configuration in the bundle's private data area, you always have a good starting point. Even in the case of a crash, because your ManagedService will only accept any properties and overwrite the local cache, if the configuration is valid. > The solution that I've found is to add a function in my PersistanceManager > to really store the configuration on disk, and I call this function when > the ManagedService.updated() function succesfully execute. But to do this > I need a dependance with my persistanceManager and it's not really clean. I agree, that this is not the best of all solutions and in fact is quite fragile and locks you into using the Felix Config Admin service. Hope this helps. Regards Felix --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

