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?
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.
Have you tried: exports | grep com.test ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With