>From the code below it appears that the new properties instance that you
create is not being passed back. Try passing the properties object as part
of update call

configuration.update(properties);

Chetan Mehrotra


On Thu, Aug 23, 2012 at 3:48 AM, Evan Ruff
<evan.r...@hendersonsawmill.com>wrote:

> Hey guys!
>
> I'm having some problems changing the port of the HttpService using the
> Configuration Admin.
>
> In my activator, I get the ExtHttpService through a service tracker. Once
> I've got the service, I add some Servlets and a Servlet Filter to it. Once
> that's done, go hit the ConfigurationAdmin to try to change the port.
>
> Every time I get the properties, it's null. I change it and do the Update,
> but it has no effect.
>
> Can someone tell me what I'm doing wrong? Here's my method:
>
> private void setHttpConnectorInfo ()
> {
>  try
> {
>  ServiceReference configurationAdminReference =
> bundleContext.getServiceReference( ConfigurationAdmin.class.getName() );
>  if ( configurationAdminReference != null )
> {
>  ConfigurationAdmin confAdmin = ( ConfigurationAdmin )
> bundleContext.getService( configurationAdminReference );
>  Configuration configuration = confAdmin.getConfiguration(
> "org.apache.felix.http", CORE_SERVICE_LOCATION );
>  Dictionary properties = configuration.getProperties();
> if ( properties == null )
>  {
> properties = new Hashtable();
>  }
>
> properties.put( "service.pid", "org.apache.felix.http" );
>  properties.put( "org.osgi.service.http.port", "80" );
> properties.put( "org.apache.felix.http.jettyEnabled", "true" );
>  configuration.update();
> }
>  }
> catch ( Exception ioEx )
>  {
> ioEx.printStackTrace();
>  }
> }
>
> I've been porting my application over to OSGi/Felix and, I have to say,
> it's quite a bear. This is my last outstanding thing!! ALMOST THERE!
>
> Appreciate all your help guys!
>
> Thanks,
>
> E
>

Reply via email to