Am Mittwoch, den 13.02.2008, 11:58 +0100 schrieb Yesica Diaz:
> Hi,
> 
> The HTTP bundle can be configured by both CM or System properties. I've 
> a problem when I configure HTTP bundle by CM. This simple example (see 
> below) shows when I get the HTTP bundle properties but I get an 
> exception because the properties are null.

Yes this is expected (and defined such) for newly created Configuration
objects. You must first call Configuration.update(Dictionary) to set
some configuration data.

>  I use Knopflerfish framework. 
> The PID Factory is correct? On other hand, if I don`t use CM, where the 
> system properties are modified? Does props.xargs file contain these 
> system properties? Thanks you.

These questions are Knopflerfish specific and should probably be asked
there .. (and yes, I don't know ;-) )


Some more comments interspersed below :

> 
> ---
>     public void start(BundleContext context) throws Exception {
>         System.out.println("example starting");
>         ServiceReference configAdminReference = 
> context.getServiceReference(ConfigurationAdmin.class.getName());
>         ConfigurationAdmin confAdmin = (ConfigurationAdmin) 
> context.getService(configAdminReference);
>         if (confAdmin == null)
>             System.out.println("Configuration Admin Service not found");
>         else {
>             System.out.println("Configuration Admin Servide found");
>             Configuration config = 
> confAdmin.createFactoryConfiguration("org.knopflerfish.bundle.http.factory.HttpServer");

               // config is new here, so create some data
               Dictionary props = new Hashtable();
               props.put("something", "some-value"); // etc. as
appropriate
               config.update(props); // store the new configuration
               // this last call also updates any ManagedServiceFactory
with the new config

               // this is not neeed, it just would reload the config
data from
               // the persistent store if such configuration would be
existing
>             config.update();
         
>             System.out.println(config.getPid());
>             System.out.println(config.getFactoryPid());
>             System.out.println(config.getBundleLocation());       

               // should now (after updating with props) not be null any
more
>             Dictionary table = (Dictionary)config.getProperties();

               // this stores the same data back, why do you do this ?
>             config.update(table)
>             if (table == null)
>                 System.out.println("properties es null");               
>             
> System.out.println(config.getProperties().get("port.http"));           
>         }
>     }
> ---
> 
> Best regards,
> 

Regards
Felix


_______________________________________________
OSGi Developer Mail List
[email protected]
https://www2.osgi.org/mailman/listinfo/osgi-dev

Reply via email to