You have to implement the actual ManagedService interface for this to work. It does not currently work with DS components. AFAIK the OSGi R7 spec fixes this.
Regards Julian On Tuesday, September 19, 2017, Thomas Driessen < thomas.driessen...@gmail.com> wrote: > Hi, > > I'm trying to implement a service that shall store a configuration in a > file each time it is updated. > > My current setup looks like this: > > *Managed Service:* > > @Component(configurationPid="system") > public class SomeManagedService{ > ... > } > > * ConfigurationPlugin/ConfigurationListener* > > @Component > public class ConfigToFileService implements ConfigurationPlugin, > ConfigurationListener{ > @Override > public void configurationEvent(ConfigurationEvent event) { > System.out.println("Listener Event Received!"); > } > > @Override > public void modifyConfiguration(ServiceReference<?> reference, > Dictionary<String, Object> properties) { > System.out.println("Plugin Event Received!"); > } > } > > *Console Command:* > > @Component(service = ConfigurationConsoleUI.class, > immediate = true, enabled = true, > property = { > CommandProcessor.COMMAND_SCOPE + "=config", > CommandProcessor.COMMAND_FUNCTION + "=updateConfig"}) > public class ConfigurationConsoleUI { > > @Reference > private ConfigurationAdmin configAdmin; > > public void updateConfig() { > try { > Configuration configuration = > configAdmin.getConfiguration("system", > "?"); > configuration.update(configuration.getProperties()); > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > > When I call "updateConfig" the ConfigurationListener method of > my ConfigToFileService is called, but the ConfiurationPlugin method is not. > My expectation would have been that first the ConfigurationPlugin method > is called and then the ConfigurationListener method. > > Do I have to do anything else to get the ConfigurationPlugin method to be > called by ConfigurationAdmin? > > Any advice is appreciated. > > Kind regards, > Thomas >
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev