sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r631742 - /incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java
Date Wed, 27 Feb 2008 21:55:11 GMT
Author: fmeschbe
Date: Wed Feb 27 13:55:09 2008
New Revision: 631742

URL: http://svn.apache.org/viewvc?rev=631742&view=rev
Log:
For each bundle B list the bundles importing packages from B

Modified:
    incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java

Modified: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java?rev=631742&r1=631741&r2=631742&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java
(original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java
Wed Feb 27 13:55:09 2008
@@ -159,6 +159,8 @@
             return;
         }
 
+        Map<String, Bundle> usingBundles = new TreeMap<String, Bundle>();
+        
         ExportedPackage[] exports = packageAdmin.getExportedPackages(bundle);
         if (exports != null && exports.length > 0) {
             // do alphabetical sort
@@ -171,6 +173,12 @@
             StringBuffer val = new StringBuffer();
             for (ExportedPackage export : exports) {
                 printExport(val, export.getName(), export.getVersion());
+                Bundle[] ubList = export.getImportingBundles();
+                if (ubList != null) {
+                    for (Bundle ub : ubList) {
+                        usingBundles.put(ub.getSymbolicName(), ub);
+                    }
+                }
             }
             keyVal(props, "Exported Packages", val.toString());
         } else {
@@ -212,6 +220,15 @@
 
             keyVal(props, "Imported Packages", val.toString());
         }
+        
+        if (!usingBundles.isEmpty()) {
+            StringBuffer val = new StringBuffer();
+            for (Bundle usingBundle : usingBundles.values()) {
+                val.append(getBundleDescriptor(usingBundle));
+                val.append("<br />");
+            }
+            keyVal(props, "Importing Bundles", val.toString());
+        }
     }
 
     private void listImportExportsUnresolved(JSONArray props, Bundle bundle) {
@@ -370,7 +387,6 @@
         }
 
         val.append("<br />");
-
     }
 
     private void printImport(StringBuffer val, String name, Version version,
@@ -385,23 +401,7 @@
         val.append(" from ");
 
         if (export != null) {
-            if (export.getExportingBundle().getSymbolicName() != null) {
-                // list the bundle name if not null
-                val.append(export.getExportingBundle().getSymbolicName());
-                val.append(" (").append(
-                    export.getExportingBundle().getBundleId());
-                val.append(")");
-            } else if (export.getExportingBundle().getLocation() != null) {
-                // otherwise try the location
-                val.append(export.getExportingBundle().getLocation());
-                val.append(" (").append(
-                    export.getExportingBundle().getBundleId());
-                val.append(")");
-            } else {
-                // fallback to just the bundle id
-                // only append the bundle
-                val.append(export.getExportingBundle().getBundleId());
-            }
+            val.append(getBundleDescriptor(export.getExportingBundle()));
 
             if (bootDel) {
                 val.append(" -- Overwritten by Boot Delegation</span>");
@@ -456,4 +456,23 @@
             new R4Attribute[] { version });
     }
 
+    private String getBundleDescriptor(Bundle bundle) {
+        StringBuffer val = new StringBuffer();
+        if (bundle.getSymbolicName() != null) {
+            // list the bundle name if not null
+            val.append(bundle.getSymbolicName());
+            val.append(" (").append(bundle.getBundleId());
+            val.append(")");
+        } else if (bundle.getLocation() != null) {
+            // otherwise try the location
+            val.append(bundle.getLocation());
+            val.append(" (").append(bundle.getBundleId());
+            val.append(")");
+        } else {
+            // fallback to just the bundle id
+            // only append the bundle
+            val.append(bundle.getBundleId());
+        }
+        return val.toString();
+    }
 }



Mime
View raw message