felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1570134 - in /felix/trunk/webconsole-plugins/packageadmin: ./ src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/ src/main/resources/OSGI-INF/l10n/ src/main/resources/res/
Date Thu, 20 Feb 2014 10:35:25 GMT
Author: fmeschbe
Date: Thu Feb 20 10:35:24 2014
New Revision: 1570134

URL: http://svn.apache.org/r1570134
Log:
FELIX-4430 Provide bundles using exported packages along with the version at which the exports
are imported

Modified:
    felix/trunk/webconsole-plugins/packageadmin/pom.xml
    felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/WebConsolePlugin.java
    felix/trunk/webconsole-plugins/packageadmin/src/main/resources/OSGI-INF/l10n/bundle.properties
    felix/trunk/webconsole-plugins/packageadmin/src/main/resources/OSGI-INF/l10n/bundle_de.properties
    felix/trunk/webconsole-plugins/packageadmin/src/main/resources/res/plugin.html
    felix/trunk/webconsole-plugins/packageadmin/src/main/resources/res/plugin.js

Modified: felix/trunk/webconsole-plugins/packageadmin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/packageadmin/pom.xml?rev=1570134&r1=1570133&r2=1570134&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/packageadmin/pom.xml (original)
+++ felix/trunk/webconsole-plugins/packageadmin/pom.xml Thu Feb 20 10:35:24 2014
@@ -96,6 +96,9 @@
                         <Private-Package>
                             org.apache.felix.webconsole.plugins.packageadmin.*
                         </Private-Package>
+                        <Embed-Dependency>
+                            org.apache.felix.utils;inline=org/apache/felix/utils/manifest/*
+                        </Embed-Dependency>
                         <Bundle-Activator>
                             org.apache.felix.webconsole.plugins.packageadmin.internal.Activator
                         </Bundle-Activator>
@@ -121,7 +124,7 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
-            <version>4.0.0</version>
+            <version>4.3.1</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -131,6 +134,12 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.utils</artifactId>
+            <version>1.4.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>
             <version>2.3</version>

Modified: felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/WebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/WebConsolePlugin.java?rev=1570134&r1=1570133&r2=1570134&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/WebConsolePlugin.java
(original)
+++ felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/WebConsolePlugin.java
Thu Feb 20 10:35:24 2014
@@ -39,6 +39,8 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.felix.utils.manifest.Clause;
+import org.apache.felix.utils.manifest.Parser;
 import org.apache.felix.webconsole.SimpleWebConsolePlugin;
 import org.apache.felix.webconsole.WebConsoleUtil;
 import org.json.JSONArray;
@@ -46,6 +48,7 @@ import org.json.JSONException;
 import org.json.JSONObject;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.service.packageadmin.ExportedPackage;
 import org.osgi.service.packageadmin.PackageAdmin;
 
@@ -80,13 +83,13 @@ class WebConsolePlugin extends SimpleWeb
         TEMPLATE = readTemplateFile("/res/plugin.html"); //$NON-NLS-1$
     }
 
-    
+
     public String getCategory()
     {
         return CATEGORY;
     }
 
-    
+
     /**
      * @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(HttpServletRequest,
HttpServletResponse)
      */
@@ -205,11 +208,6 @@ class WebConsolePlugin extends SimpleWeb
                 {
                     ExportedPackage exportedPackage = (ExportedPackage) packageIter.next();
                     final JSONObject json = toJSON(exportedPackage);
-                    Bundle[] importers = exportedPackage.getImportingBundles();
-                    for (int j = 0; importers != null && j < importers.length;
j++)
-                    {
-                        json.append("importers", toJSON(importers[j], new JSONObject()));
//$NON-NLS-1$
-                    }
                     container//
                     .put("name", exportedPackage.getName()) //$NON-NLS-1$
                     .append("entries", json); //$NON-NLS-1$
@@ -227,12 +225,38 @@ class WebConsolePlugin extends SimpleWeb
         return json;
     }
 
+    private static final JSONObject toJSON(final String pkgName, final Bundle[] importers,
final JSONObject json)
+        throws JSONException
+    {
+        for (int i = 0; i < importers.length; i++)
+        {
+            Bundle bundle = importers[i];
+            final JSONObject usingJson = new JSONObject();
+            toJSON(bundle, usingJson);
+            final String ip = (String) bundle.getHeaders().get(Constants.IMPORT_PACKAGE);
+            final Clause[] clauses = Parser.parseHeader(ip);
+            for (int j = 0; j < clauses.length; j++)
+            {
+                Clause clause = clauses[j];
+                if (pkgName.equals(clause.getName()))
+                {
+                    usingJson.put("ver", clause.getAttribute(Constants.VERSION_ATTRIBUTE));
+                    break;
+                }
+            }
+            json.append("importers", usingJson); //$NON-NLS-1$
+        }
+        return json;
+    }
+
     private static final JSONObject toJSON(final ExportedPackage pkg)
         throws JSONException
     {
         final JSONObject ret = new JSONObject();
         ret.put("version", pkg.getVersion()); //$NON-NLS-1$
-        return toJSON(pkg.getExportingBundle(), ret);
+        toJSON(pkg.getExportingBundle(), ret);
+        toJSON(pkg.getName(), pkg.getImportingBundles(), ret);
+        return ret;
     }
 
     private static final JSONObject getPackageInfo(String packageName, PackageAdmin pa,
@@ -304,7 +328,7 @@ class WebConsolePlugin extends SimpleWeb
                     {
                         result.add(part);
                     }
-                } 
+                }
                 else
                 {
                     result.add(part);

Modified: felix/trunk/webconsole-plugins/packageadmin/src/main/resources/OSGI-INF/l10n/bundle.properties
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/packageadmin/src/main/resources/OSGI-INF/l10n/bundle.properties?rev=1570134&r1=1570133&r2=1570134&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/packageadmin/src/main/resources/OSGI-INF/l10n/bundle.properties
(original)
+++ felix/trunk/webconsole-plugins/packageadmin/src/main/resources/OSGI-INF/l10n/bundle.properties
Thu Feb 20 10:35:24 2014
@@ -36,6 +36,7 @@ header.package.ver=Version
 header.exporting.bundle=Exported by
 header.maven.deps=Maven Dependency
 no.exporters.found=No exporting bundle(s) found
+no.uses.found=No importing bundle(s) found
 no.maven.found=No maven information available
 status.initial=Please enter a list of package or class names and click the find button
 status.find={0} result(s) found

Modified: felix/trunk/webconsole-plugins/packageadmin/src/main/resources/OSGI-INF/l10n/bundle_de.properties
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/packageadmin/src/main/resources/OSGI-INF/l10n/bundle_de.properties?rev=1570134&r1=1570133&r2=1570134&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/packageadmin/src/main/resources/OSGI-INF/l10n/bundle_de.properties
(original)
+++ felix/trunk/webconsole-plugins/packageadmin/src/main/resources/OSGI-INF/l10n/bundle_de.properties
Thu Feb 20 10:35:24 2014
@@ -1,4 +1,4 @@
-#Licensed to the Apache Software Foundation (ASF) under one or more
+#Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
 # this work for additional information regarding copyright ownership.
 # The ASF licenses this file to You under the Apache License, Version 2.0
@@ -34,9 +34,10 @@ find.tip=Geben Sie eine Liste von Paket-
 header.package.name=Pakete
 header.package.ver=Version
 header.exporting.bundle=Exportiert von
-header.maven.deps=Maven Abhängigkeit
+header.maven.deps=Maven Abhängigkeit
 no.exporters.found=Keine exportierenden Bundle(s) gefunden
-no.maven.found=Keine Maven-Informationen verfügbar
+no.uses.found=Keine importierenden Bundle(s) gefunden
+no.maven.found=Keine Maven-Informationen verfügbar
 status.initial=Bitte geben Sie eine Liste von Paket- oder Klassen-Namen und klicken Sie auf
die Suche-Taste.
 status.find={0} Ergebnis(se) gefunden
 

Modified: felix/trunk/webconsole-plugins/packageadmin/src/main/resources/res/plugin.html
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/packageadmin/src/main/resources/res/plugin.html?rev=1570134&r1=1570133&r2=1570134&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/packageadmin/src/main/resources/res/plugin.html (original)
+++ felix/trunk/webconsole-plugins/packageadmin/src/main/resources/res/plugin.html Thu Feb
20 10:35:24 2014
@@ -28,6 +28,7 @@ var i18n = {
 			<th>${header.package.name}</th>
 			<th>${header.package.ver}</th>
 			<th>${header.exporting.bundle}</th>
+			<th>${header.importing.bundle}</th>
 			<th>${header.maven.deps}</th>
 		</tr>
 	</thead>
@@ -36,6 +37,7 @@ var i18n = {
 			<td class="pkg">&nbsp;</td>
 			<td class="ver">-</td>
 			<td class="bnd">${no.exporters.found}</td>
+			<td class="use">${no.uses.found}</td>
 			<td class="mvn">${no.maven.found}</td>
 		</tr>
 	</tbody>

Modified: felix/trunk/webconsole-plugins/packageadmin/src/main/resources/res/plugin.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/packageadmin/src/main/resources/res/plugin.js?rev=1570134&r1=1570133&r2=1570134&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/packageadmin/src/main/resources/res/plugin.js (original)
+++ felix/trunk/webconsole-plugins/packageadmin/src/main/resources/res/plugin.js Thu Feb 20
10:35:24 2014
@@ -25,7 +25,26 @@ var dupsTableBody = false;
 var dupsTableTemplate = false;
 var statline = false;
 
-function linkBundle(bnd) { return '<a href="{0}/bundles/{1}">{2} ({3})</a>'.msgFormat(appRoot,
bnd.bid, bnd.bsn, bnd.bid) }
+function linkBundle(bnd) { return '<a href="{0}/bundles/{1}">{2} ({3})</a>'.msgFormat(appRoot,
bnd.bid, bnd.bsn, bnd.bid) }
+function uses(uses) {
+    var result = ""; 
+    if (uses) {
+        resul = "<table>";
+        for(var i in uses) {
+            result += "<tr><td>";
+            result += linkBundle(uses[i]);
+            result += "</td><td>";
+            if (uses[i].ver) {
+                result += uses[i].ver;
+            } else {
+                result += "&mdash;";
+            }
+            result += "</td></tr>";
+        }
+        result += "</table>";
+    }
+    return result;
+}
 
 $(function() {
 	findField = $('#findField');
@@ -63,7 +82,8 @@ $(function() {
 						var tr = findTableTemplate.clone()
 							.find('td.pkg').text(pkg.name).end()
 							.find('td.ver').text(exp.version).end()
-							.find('td.bnd').html(linkBundle(exp)).end()
+							.find('td.bnd').html(linkBundle(exp)).end()
+							.find('td.use').html(uses(exp.importers)).end()
 							.appendTo(findTableBody);
 						if (response.maven && response.maven[exp.bid]) {
 							var mvn = response.maven[exp.bid];
@@ -100,8 +120,7 @@ $(function() {
 						.find('td.ver').text(exp.version).end()
 						.find('td.exp').html(linkBundle(exp)).end();
 					if (exp.importers) {
-						var txt = ''; for(var j in exp.importers) txt += linkBundle(exp.importers[j]) + '<br/>';
-						td.find('td.imp').html( txt );
+						td.find('td.imp').html(uses(exp.importers));
 					}
 					if (i==0) {
 						td.find('td.pkg').attr('rowspan', pkg.entries.length);



Mime
View raw message