Find an OSGI package that exports a package?

How to find a package that exports a package?

I use felix and I have a line like com.test, how do I know which package exports this package?

I do not want to use PackageAdmin because it is deprecated, and I really do not want to get the Export-Package header for each package and parse it.

Any ideas?

+7
source share
3 answers

It sounds like you want to do this programmatically, not in the Gogo shell ... at least I will take this from the wording of your question.

There is no real way to say “which package” a given package is exporting, as there can be many packages exporting a given package, and this package can be used in many packages by many packages. If you have a specific package and want to know which package the com.test package com.test , you can get the binding wiring when importing Bundle.adapt(BundleWiring.class) and then use BundleWiring.getRequiredWires() to get the providers of all the dependencies package.

From there you need to find the wire from the osgi.wiring.package namespace for the package you need, then the provider of this wire will be the BundleCapability BundleRevision the package you are interested in.

+11
source

Recent versions of the Apache Felix OSGi console include a dependency plugin that lists the packages (s) that export this package or class. There are several screenshots at http://www.6dlabs.com/blog/dklco/2012-05-04/new-cq-55-dependency-finder (which mention CQ5, but the plugin does not depend on this).

This is useful at the administrator level, and if you need to find it in the code, you can look at this plugin source code, see https://issues.apache.org/jira/browse/FELIX-3045

+3
source

Have you tried: export | grep com.test?

+2
source

All Articles