StringBuffer sb = new StringBuffer();
startFont(sb);
ServiceReference sr = Activator
.getTargetBC_getServiceReference(PackageAdmin.class.getName());
PackageAdmin pkgAdmin
= (PackageAdmin) Activator.getTargetBC_getService(sr);
if(pkgAdmin == null) {
sb.append("No PackageAdmin service found");
} else {
Bundle[] bl = getBundleArray();
Set pkgClosure = new TreeSet(Util.bundleIdComparator);
for(int i = 0; i < targets.length; i++) {
pkgClosure.addAll(Util.getPackageClosure(Activator.desktop.pm,
targets[i],
null));
}
// remove myself
// pkgClosure.remove(b);
if(pkgClosure.size() == 0) {
sb.append("No package dependencies");
} else {
sb.append("<b>Static dependencies via packages</b><br>");
for(Iterator it = pkgClosure.iterator(); it.hasNext();) {
Bundle depB = (Bundle)it.next();
sb.append(" ");
Util.bundleLink(sb, depB);
sb.append("<br>");
}
}
sb.append("<br>");
Set serviceClosure = new TreeSet(Util.bundleIdComparator);
for(int i = 0; i < targets.length; i++) {
serviceClosure.addAll(Util.getServiceClosure(targets[i], null));
}
// remove myself
// serviceClosure.remove(b);
if(serviceClosure.size() == 0) {
sb.append("No service dependencies");
} else {
sb.append("<b>Runtime dependencies via services</b><br>");
for(Iterator it = serviceClosure.iterator(); it.hasNext();) {
Bundle depB = (Bundle)it.next();
sb.append(" ");
Util.bundleLink(sb, depB);
sb.append("<br>");
}
}
sb.append("<br>");
Set fragments = new TreeSet(Util.bundleIdComparator);
for(int i = 0; i < targets.length; i++) {
Bundle[] fragmentBundles = pkgAdmin.getFragments(targets[i]);
if (fragmentBundles != null) {
for (int b = 0; b < fragmentBundles.length; b++) {
fragments.add(fragmentBundles[b]);
}
}
}
if(fragments.size() == 0) {
sb.append("No fragments");
} else {
sb.append("<b>Fragments</b><br>");
for(Iterator it = fragments.iterator(); it.hasNext();) {
Bundle depB = (Bundle)it.next();
sb.append(" ");
Util.bundleLink(sb, depB);
sb.append("<br>");
}
}
sb.append("<br>");
Set hosts = new TreeSet(Util.bundleIdComparator);
for(int i = 0; i < targets.length; i++) {
Bundle[] hostBundles = pkgAdmin.getHosts(targets[i]);
if (hostBundles != null) {
for (int b = 0; b < hostBundles.length; b++) {
hosts.add(hostBundles[b]);
}
}
}
if(hosts.size() == 0) {
sb.append("No host");
} else {
sb.append("<b>Host</b><br>");
for(Iterator it = hosts.iterator(); it.hasNext();) {
Bundle depB = (Bundle)it.next();
sb.append(" ");
Util.bundleLink(sb, depB);
sb.append("<br>");
}
}
sb.append("<br>");
Set required = new TreeSet(Util.bundleIdComparator);
Set requiredBy = new TreeSet(Util.bundleIdComparator);
try { // untested code
RequiredBundle[] requiredBundles = pkgAdmin.getRequiredBundles(null);
if (requiredBundles != null) {
for (int rb = 0; rb < requiredBundles.length; rb++) {
for (int t = 0; t < targets.length; t++) {
Bundle[] requiringBundles = requiredBundles[rb].getRequiringBundles();
if (requiringBundles != null) {