Programatically push configuration into OSGi ConfigurationAdmin

Yesterday I lost half an hour when I struggled to push a configuration into OSGi ConfigurationAdmin. The was in fact called, but the Dictionary of properties was always null. It turns out, I forgot that one has to lookup the not just by service PID, but also by (bundle) location. And since the location was not matching, the configuration was not a valid config for the bundle that implements the ManagedService.
Below is how one correctly configures the ManagedService registered with PID “my.ManagedService.Service.Pid” ( Notice the “?” location wildcard!
String servicePID = "my.ManagedService.Service.Pid";
Configuration configuration = 
	cm.getConfiguration(servicePID, "?");
Dictionary<String, Object> properties = 
if (properties == null) {
	properties = new Hashtable<String, Object>();
properties.put("someKey", "someValue");

One Response to Programatically push configuration into OSGi ConfigurationAdmin »»


  1. Comment by Rüdiger Herrmann | 2013/10/25 at 19:44:03

    Thanks for posting this! It reminded me of a feature in File Install that helps to configure Managed Services


Leave a Reply »»