I implemented a feature that my osgi is installing bundles that are represented as jars on the filesystem programmatically when starting or when receiving a new one. However, when I receive one, that already has been installed during start-up it crashes due to the conflict. Is there a way (I don't know the ID nor the name) in case of conflict to update instead of install programmatically?
BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
Bundle bundle = context.getBundle("file:/Path.jar");
Hope somebody knows...
What I did in a similar case:
In case you want to allow multiple versions of the same bundle you can check also the version of the bundle before updating or installing. In this case I would do the update if
If you care about the location and it is changed, instead of update(inputstream) use a bundle.uninstall() and bundlecontext.install(...) which reinstalls the bundle.
On the end you should call refresh() to have the correct package wirings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.