return 1;
}
String bname = (String) opts.get("bundle");
Bundle[] bl = getBundles(new String[] { bname }, true);
Bundle bundle = bl[0];
if (bundle == null) {
out.println("ERROR! No matching bundle for '" + bname + "'");
return 1;
}
bl = getBundles(null, false, false, false);
// Package
Vector pkgClosure = new Vector();
// This is O(n2) at least, possibly O(n3). Should be improved
for(int b = 0; b < bl.length; b++) {
ExportedPackage[] pkgs = packageAdmin.getExportedPackages(bl[b]);
if (pkgs == null) continue;
for(int p = 0; p < pkgs.length; p++) {
Bundle[] bl2 = pkgs[p].getImportingBundles();
if (bl2 == null) continue;
for(int ib = 0; ib < bl2.length; ib++) {
if(bl2[ib].getBundleId() == bundle.getBundleId() && !pkgClosure.contains(bl[b])) {
pkgClosure.add(bl[b]);
}
}
}
}
pkgClosure.remove(bundle);
if (pkgClosure.size() == 0) {
out.println("No package dependencies");
} else {
out.println("Static dependencies via packages:");
Bundle[] bundles = (Bundle[]) pkgClosure.toArray(new Bundle[pkgClosure.size()]);
printBundles(out, bundles, false, true);
}
// Service
Vector serviceClosure = new Vector();
ServiceReference[] srl = bundle.getServicesInUse();
for (int i = 0; srl != null && i < srl.length; i++) {
if (!serviceClosure.contains(srl[i].getBundle())) {
serviceClosure.add(srl[i].getBundle());
}
}