I am implementing a GUI (swing) Application comprising three bundles, let say bundleA, bundleB, and bundleC. I install all these three bundles in/using a separate installer bundle using BundleContext.installBundle(String location) method.
The problem starts when I use another bundle named "UpgradeBundle" to update one of the three already installed bundles. To be more precise I call BundleC.update(null) method followed by the call to FrameworkWiring.refreshBundles(BundlesForRefresh, null) method, as I read that bundle update requires call to FrameworkWiring.refreshBundles. However the call to FrameworkWiring.refreshBundles results in launching a new GUI application with updated bundle (instead of updating it in already running application instance), while already running application keeps on running with old bundle. Any idea why this is happening?
If you need more elaboration on the problem, please let me know, and I will try to explain the problem further.
P.S. I am using Equinox OSGi framework.
Refresh will stop all bundles that have references to any previous versions of updated bundles. I guess your application is not properly shutting down the existing instance when the stop method is called. The start method then creates a new one.
To prevent the app from not shutting down when updating you have to carefully design your system to ensure that there are no class loader references from your app to updated bundles. Services, with their focus on interfaces, are an excellent way to achieve this. However, in the end there will be many cases where also your app needs to shutdown to refresh its references.