Thanks very much Neil and Marcel for your answers!

Here are more details about what I do.

FileOutputStream writer = new FileOutputStream(bundlesLocation+"/"+bundleName+"-"+bundleVersion+".jar");
writer.write(outputStream.toByteArray());
writer.close();

Bundle bundle = OsgiUtils.installBundle(context,
"file://"+bundlesLocation+"/"+bundleName+"-"+bundleVersion+".jar",
                new ByteArrayInputStream(outputStream.toByteArray()));
OsgiUtils.startBundle(bundle);

installBundle simply calls the installBundle method on the BundleContext class and startBundle the start one one th Bundle class.

This works fine. The bundle is correctly installed and started and available within the container.

The second step consists in updating this bundle. Here is what I do in this case:

Bundle bundle = OsgiUtils.getBundle(context, bundleName, bundleVersion);
if (bundle!=null) {
        OsgiUtils.updateBundle(context, bundle,
                new ByteArrayInputStream(outputStream.toByteArray()));
}

updateBundle simply calls the update method on the Bundle class after having stopped the bundle and starts then the updated bundle.

It seems that the second steps doesn't work since I haven't the expected processing.

Thanks very much for your help!
Thierry
You are doing the right thing: calling update should work, and you should not 
need to stop it beforehand (or start it afterwards). Could you please show more 
exactly what code you are using and what exception you are getting?

On May 2, 2012, at 10:23 , Thierry Templier wrote:

Hello,

I install bundles using the installBundle method if the BundleContext class. It 
works fine and after having started them, they are
available within the Felix container. I want then to update them using the 
update method of the Bundle interface and it
unfortunately doesn't work.

I read the OSGi specification and it says that we need to stop the bundle 
before updating it and start it again then. But I have
the same behovior. Calling the update method seems to work but the bundle isn't 
actually updated.

What is the correct way to manage bundles using th OSGi API.

Thanks for your help.
Thierry

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




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



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

Reply via email to