Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the OSGI bundle that exports a package?

How do I find the bundle that exports a package?

I am using felix and I have a string like "com.test", how do I know which bundle exports that package?

I don't want to use PackageAdmin as it has been deprecated, and I don't really want to get the Export-Package header for each bundle and parse it.

Any ideas?

like image 529
Boomah Avatar asked Aug 11 '12 13:08

Boomah


Video Answer


2 Answers

It sounds like you want to do this programmatically, not at the Gogo shell ... at least I'll assume that from wording of your question.

There is no real way to say "which bundle" exports a given package since there can be many bundles exporting any given package and that package can be in use from many bundles by many bundles. If you have a specific bundle and you want to know which bundle provides package com.test to it, you can get the importing bundle's wiring Bundle.adapt(BundleWiring.class) and then use BundleWiring.getRequiredWires() to get the providers of all of the bundle's dependencies.

From there you just need to find the wire of osgi.wiring.package namespace for the package you want, then the provider of that wire will be a BundleCapability of a BundleRevision of the bundle you are interested in.

like image 111
Richard S. Hall Avatar answered Oct 22 '22 14:10

Richard S. Hall


Have you tried: exports | grep com.test ?

like image 29
Mike Van Avatar answered Oct 22 '22 13:10

Mike Van