Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do the Rewiring Framework after OSGi bundle update

I have a equinox based application. I need to update a bundle and rewire the OSGi bundles corresponding to the updated bundle.

I updated the bundle using,

bundle.update(new FileInputStream(new File(filePath)));

I need to refresh the affected bundles in order the update to be affected.

How can I do this?...

like image 443
Aruna Karunarathna Avatar asked Mar 20 '23 18:03

Aruna Karunarathna


1 Answers

BundleContext bcx = bundle.getBundleContext();
Bundle systemBundle = bcx.getBundle(0);

bundle.update(new FileInputStream(new File(filePath)));

FrameworkWiring frameworkWiring = systemBundle.adapt(FrameworkWiring.class);
frameworkWiring.refreshBundles(null);

Please note that refreshBundles is an asynchron function call. Therefore if you want to catch the event when the bundles are refreshed, you must pass a FrameworkListener as the second parameter.

like image 133
Balazs Zsoldos Avatar answered Apr 06 '23 04:04

Balazs Zsoldos