A quick solution is to iterate over the bundles, list the id and the export package header.
g! each (bundles) { echo ($it bundleId) (($it headers) get Export-Package) }
Note that you need to put spaces around the {
and }
! This prints for each bundle, its id and its Export-Package header. You can put this in a cmd:
g! exports= { each (bundles) { echo ($it bundleId) (($it headers) get Export-Package) } }
You can then use it easier with grep
:
g! exports | grep webconsole
12 org.apache.felix.webconsole;version="3.3.0";uses:="javax.servlet,javax.servlet.http,org.osgi.framework",org.apache.felix.webconsole.bundleinfo;version="1.0.0";uses:="org.osgi.framework",org.apache.felix.webconsole.i18n;version="1.0.0";uses:="org.osgi.framework"
true
The official command for exported packages is inspect
g! inspect cap osgi.wiring.package
However, the output is very messy and hard to grep. However, if you know the package name then you can ask (deprecated) Package Admin.
g! r=servicereference org.osgi.service.packageadmin.PackageAdmin
....
g! pa=service $r
org.apache.felix.framework.PackageAdminImpl@2c7b40e3
g! $pa exportedpackages org.osgi.framework
org.osgi.framework; version=1.10.0
org.osgi.framework; version=1.9.0
org.osgi.framework; version=1.10.0
org.osgi.framework; version=1.9.0
g! each ($pa exportedpackages org.osgi.framework) { $it exportingbundle }
0|Active | 0|org.apache.felix.framework (0.1.0.SNAPSHOT)
Unfortunately, the Package Admin methods are overloaded and Gogo picks the first one that matches, otherwise it would be a lot easier :-(
If you have the set of bundles then the bnd
command line can be useful. You can install it here.
You can then do:
$ bnd find -e "com.example*" jars/*.jar
or
$ bnd grep -e "com.example*" jars/*.jar