Hi,

Am 23.08.2012 um 05:46 schrieb Chetan Mehrotra:

> 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);

Correct.

Configuration.getProperties() returns a private copy which you may modify at 
your desire. To write back the changes your have to call the 
Configuration.update(Dictionary) method.

The Configuration.update() method just causes the configuration to be read from 
persistence again, which is not what you want.

Regards
Felix

> 
> Chetan Mehrotra
> 
> 
> On Thu, Aug 23, 2012 at 3:48 AM, Evan Ruff
> <[email protected]>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
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to