Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the dependent bundles in Eclipse at runtime

How can an Eclipse bundle (eg. within activator code) find the dependent Bundle instances at runtime? I would like to find the bundles that Eclipse has choosen to satisfy the dependency requirements, I do not want to interprete the manifest myself.

An example: I would like to find all resources named "marker.txt" in all bundles on which my current bundle depends upon. Also the transitive dependencies. In order to accomplish this I need to be able to find all these bundles to begin with.

like image 708
Bruno Ranschaert Avatar asked Nov 11 '10 10:11

Bruno Ranschaert


2 Answers

There is no easy way to determine the dependency. The best way is to go through the PackageAdmin interface. See the OSGi spec for PackageAdmin and getImportingBundles in particular: http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/ExportedPackage.html#getImportingBundles()

You need to determine for all installed bundles, which one exports one or more packages that your bundle is importing. The easiest way to achieve this is to call PackageAdmin.getExportedPackages(Bundle bundle) with bundles = null. This returns an array of all exported packages. You then need to iterate of this array and call ExportPackage.getImportingBundles().

like image 157
Andreas Kraft Avatar answered Sep 21 '22 16:09

Andreas Kraft


Please see my answer to this question. 4.3 will have a new bundle wiring API that will allow things like this.

like image 38
Holger Hoffstätte Avatar answered Sep 23 '22 16:09

Holger Hoffstätte