0

I am using Apache Felix HTTP Service Jetty 2.2.0 in my project. Based on the documentation I wrote the following code to change the default service port.

ConfigurationAdmin configAdmin = // get ConfigurationAdmin from OSGi service registry
Configuration config = configAdmin.getConfiguration("org.apache.felix.http" ,  null);
Dictionary<String, Object> props = config.getProperties();
if(props == null)
{
  props = new Hashtable<String, Object>();
}
props.put("org.osgi.service.http.port", newport);
config.update(props);

As you can see I get the configuration object, update properties and call the update method.All this works fine but HttpService for some reason doesn't pick up the new configuration. What am I doing wrong? Between I am able to change the port by using the System property approach. But I want to be able to use ConfigurationAdmin to do it. I am running Equinox 3.8 container

nadirsaghar
  • 557
  • 1
  • 4
  • 20

1 Answers1

0

You use the OSGi System property instead of the Felix Http config admin property ... Here is an example:

   "service.pid":                              "org.apache.felix.http", 
   "org.apache.felix.http.enable":             true, 
   "org.osgi.service.http.port":               8080,
   "org.apache.felix.http.debug":              true, 
   "org.apache.felix.https.debug":             true, 
   "org.apache.felix.https.enable":            true, 
   "org.osgi.service.http.port.secure":        8085,
   "org.apache.felix.https.keystore":          "@{resource:example.keystore.ks}", 
   "org.apache.felix.https.keystore.password": "@{.example.keystore}",
Peter Kriens
  • 15,196
  • 1
  • 37
  • 55
  • I have to do it programmatically. My application has a web interface that let's administrators to change the port. The change should be reflected on reboot. In equinox I can use config.ini file to specify these properties but that requires manual entry unless there is a OSGi specified API to update System Properties persistently. – nadirsaghar May 03 '13 at 18:47