felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1187509 - in /felix/trunk/webconsole-plugins/packageadmin/src: main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/ test/java/org/apache/felix/webconsole/plugins/packageadmin/internal/
Date Fri, 21 Oct 2011 19:09:10 GMT
Author: fmeschbe
Date: Fri Oct 21 19:09:09 2011
New Revision: 1187509

URL: http://svn.apache.org/viewvc?rev=1187509&view=rev
Log:
Reformat according to Apache Felix conventions

Modified:
    felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/Activator.java
    felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/DependencyFinderPlugin.java
    felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/PackageAdminPlugin.java
    felix/trunk/webconsole-plugins/packageadmin/src/test/java/org/apache/felix/webconsole/plugins/packageadmin/internal/DependencyFinderPluginTest.java

Modified: felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/Activator.java?rev=1187509&r1=1187508&r2=1187509&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/Activator.java
(original)
+++ felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/Activator.java
Fri Oct 21 19:09:09 2011
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -24,7 +24,8 @@ import java.util.Hashtable;
 import org.osgi.framework.*;
 import org.osgi.util.tracker.ServiceTracker;
 
-public class Activator implements BundleActivator {
+public class Activator implements BundleActivator
+{
 
     private ServiceTracker pkgAdminTracker;
 
@@ -32,46 +33,49 @@ public class Activator implements Bundle
 
     private ServiceRegistration depFinderPlugin;
 
-    public void start(final BundleContext context) throws Exception {
-        this.pkgAdminTracker = new ServiceTracker(context,
-            "org.osgi.service.packageadmin.PackageAdmin", null);
+    public void start(final BundleContext context) throws Exception
+    {
+        this.pkgAdminTracker = new ServiceTracker(context, "org.osgi.service.packageadmin.PackageAdmin",
null);
         this.pkgAdminTracker.open();
 
         registerPackageAdminPlugin(context);
         registerDependencyFinderPlugin(context);
     }
 
-    private void registerPackageAdminPlugin(final BundleContext context) {
-        final PackageAdminPlugin plugin = new PackageAdminPlugin(context,
-            pkgAdminTracker);
+    private void registerPackageAdminPlugin(final BundleContext context)
+    {
+        final PackageAdminPlugin plugin = new PackageAdminPlugin(context, pkgAdminTracker);
         final Dictionary<String, Object> props = new Hashtable<String, Object>();
         props.put("felix.webconsole.label", PackageAdminPlugin.LABEL);
         props.put("felix.webconsole.title", PackageAdminPlugin.TITLE);
-        props.put("felix.webconsole.configprinter.modes", new String[] {"zip", "txt"});
-        this.pkgAdminPlugin = context.registerService("javax.servlet.Servlet",
-            plugin, props);
+        props.put("felix.webconsole.configprinter.modes", new String[]
+            { "zip", "txt" });
+        this.pkgAdminPlugin = context.registerService("javax.servlet.Servlet", plugin, props);
     }
 
-    private void registerDependencyFinderPlugin(final BundleContext context) {
-        final DependencyFinderPlugin plugin = new DependencyFinderPlugin(context,
-            pkgAdminTracker);
+    private void registerDependencyFinderPlugin(final BundleContext context)
+    {
+        final DependencyFinderPlugin plugin = new DependencyFinderPlugin(context, pkgAdminTracker);
         final Dictionary<String, Object> props = new Hashtable<String, Object>();
         props.put("felix.webconsole.label", DependencyFinderPlugin.LABEL);
         props.put("felix.webconsole.title", DependencyFinderPlugin.TITLE);
-        this.depFinderPlugin = context.registerService("javax.servlet.Servlet",
-            plugin, props);
+        this.depFinderPlugin = context.registerService("javax.servlet.Servlet", plugin, props);
     }
 
-    public void stop(final BundleContext context) throws Exception {
-        if ( this.pkgAdminPlugin != null ) {
+    public void stop(final BundleContext context) throws Exception
+    {
+        if (this.pkgAdminPlugin != null)
+        {
             this.pkgAdminPlugin.unregister();
             this.pkgAdminPlugin = null;
         }
-        if ( this.depFinderPlugin != null ) {
+        if (this.depFinderPlugin != null)
+        {
             this.depFinderPlugin.unregister();
             this.depFinderPlugin = null;
         }
-        if ( this.pkgAdminTracker != null ) {
+        if (this.pkgAdminTracker != null)
+        {
             this.pkgAdminTracker.close();
             this.pkgAdminTracker = null;
         }

Modified: felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/DependencyFinderPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/DependencyFinderPlugin.java?rev=1187509&r1=1187508&r2=1187509&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/DependencyFinderPlugin.java
(original)
+++ felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/DependencyFinderPlugin.java
Fri Oct 21 19:09:09 2011
@@ -38,7 +38,8 @@ import org.osgi.service.packageadmin.Pac
 import org.osgi.util.tracker.ServiceTracker;
 
 @SuppressWarnings("serial")
-public class DependencyFinderPlugin extends HttpServlet {
+public class DependencyFinderPlugin extends HttpServlet
+{
 
     static final String LABEL = "depfinder";
 
@@ -47,20 +48,21 @@ public class DependencyFinderPlugin exte
     private static final String PARAM_FIND = "plugin.find";
 
     private static final String PARAM_SUBMIT = "plugin.submit";
-    
+
     private static final String INDENT = "    ";
-    
+
     private final BundleContext bundleContext;
 
     private final ServiceTracker pkgAdminTracker;
 
-    DependencyFinderPlugin(final BundleContext bundleContext,
-            final ServiceTracker pkgAdminTracker) {
+    DependencyFinderPlugin(final BundleContext bundleContext, final ServiceTracker pkgAdminTracker)
+    {
         this.bundleContext = bundleContext;
         this.pkgAdminTracker = pkgAdminTracker;
     }
-    
-    private void drawForm(final PrintWriter pw, String findField) {
+
+    private void drawForm(final PrintWriter pw, String findField)
+    {
         titleHtml(pw, "Dependency Finder", "Enter a list of package or class names");
         pw.println("<tr class='content'>");
         pw.println("<td class='content'>Packages/Classes</td>");
@@ -68,60 +70,66 @@ public class DependencyFinderPlugin exte
         pw.print("<form method='get'>");
         pw.println("<textarea rows='10' cols='80' name='" + PARAM_FIND + "'>" + (findField
!= null ? findField : "")
             + "</textarea>");
-        pw.println("&nbsp;&nbsp;<input type='submit' name='" + PARAM_SUBMIT
-            + "' value='Find' class='submit'>");
+        pw.println("&nbsp;&nbsp;<input type='submit' name='" + PARAM_SUBMIT +
"' value='Find' class='submit'>");
         pw.print("</form>");
         pw.print("</td>");
         pw.println("</tr>");
     }
 
-    private void endTable(final PrintWriter pw) {
+    private void endTable(final PrintWriter pw)
+    {
         pw.println("</table>");
     }
 
-    private void startTable(final PrintWriter pw) {
+    private void startTable(final PrintWriter pw)
+    {
         pw.println("<table class='content' cellpadding='0' cellspacing='0' width='100%'>");
     }
-    
-    private void titleHtml(PrintWriter pw, String title, String description) {
+
+    private void titleHtml(PrintWriter pw, String title, String description)
+    {
         pw.println("<tr class='content'>");
-        pw.println("<th colspan='3'class='content container'>" + title
-            + "</th>");
+        pw.println("<th colspan='3'class='content container'>" + title + "</th>");
         pw.println("</tr>");
 
-        if (description != null) {
+        if (description != null)
+        {
             pw.println("<tr class='content'>");
-            pw.println("<td colspan='3'class='content'>" + description
-                + "</th>");
+            pw.println("<td colspan='3'class='content'>" + description + "</th>");
             pw.println("</tr>");
         }
     }
-    
-    private void printStatLine(final PrintWriter pw, final String format,
-            final Object... args) {
+
+    private void printStatLine(final PrintWriter pw, final String format, final Object...
args)
+    {
         final String message = String.format(format, args);
         pw.printf("<p class=\"statline\">%s</p>%n", message);
     }
-    
+
     @Override
-    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException
+    {
         final PrintWriter pw = resp.getWriter();
-        
+
         final PackageAdmin pa = (PackageAdmin) this.pkgAdminTracker.getService();
-        if (pa == null) {
+        if (pa == null)
+        {
             printStatLine(pw, "PackageAdmin Service not registered");
             return;
         }
-        
+
         startTable(pw);
         String findField = req.getParameter(PARAM_FIND);
-        if (findField != null) {
+        if (findField != null)
+        {
             SortedSet<String> packageNames = getPackageNames(findField);
-            if (!packageNames.isEmpty()) {
+            if (!packageNames.isEmpty())
+            {
                 Set<Bundle> exportingBundles = new LinkedHashSet<Bundle>();
-                
+
                 titleHtml(pw, "Packages", "Here are the packages you entered and by which
bundle they are exported.");
-                for (String packageName : packageNames) {
+                for (String packageName : packageNames)
+                {
                     pw.println("<tr class='content'>");
                     pw.print("<td class='content'>");
                     pw.print(packageName);
@@ -130,33 +138,43 @@ public class DependencyFinderPlugin exte
                     pw.print("<td class='content' colspan='2'>");
                     ExportedPackage[] exports = pa.getExportedPackages(packageName);
                     ExportedPackage export = pa.getExportedPackage(packageName);
-                    if (export == null) {
+                    if (export == null)
+                    {
                         pw.print("<span style='color: red;'>NOT EXPORTED</span>");
-                    } else {
+                    }
+                    else
+                    {
                         Bundle exportingBundle = export.getExportingBundle();
-                        pw.printf("<a href='/system/console/bundles/%s' style='text-decoration:
none; color: #555;'>%s (%s)</a>", exportingBundle.getBundleId(), exportingBundle.getSymbolicName(),
exportingBundle.getBundleId());
-                        if (exports.length > 1) {
+                        pw.printf(
+                            "<a href='/system/console/bundles/%s' style='text-decoration:
none; color: #555;'>%s (%s)</a>",
+                            exportingBundle.getBundleId(), exportingBundle.getSymbolicName(),
+                            exportingBundle.getBundleId());
+                        if (exports.length > 1)
+                        {
                             pw.printf(" and %s others.", exports.length - 1);
                         }
                         exportingBundles.add(exportingBundle);
-                        
+
                     }
                     pw.print("</td>");
-                    
+
                     pw.println("</tr>");
                 }
-                
+
                 titleHtml(pw, "Maven Dependencies", "Here are the bundles listed above as
Maven dependencies");
                 pw.println("<tr class='content'>");
                 pw.print("<td class='content' colspan='3'>");
                 pw.println("<pre>");
-                for (Bundle bundle : exportingBundles) {
+                for (Bundle bundle : exportingBundles)
+                {
                     Enumeration<?> entries = bundle.findEntries("META-INF/maven", "pom.properties",
true);
-                    if (entries != null) {
+                    if (entries != null)
+                    {
                         URL u = (URL) entries.nextElement();
                         java.util.Properties props = new java.util.Properties();
                         InputStream is = null;
-                        try {
+                        try
+                        {
                             is = u.openStream();
                             props.load(u.openStream());
 
@@ -166,9 +184,14 @@ public class DependencyFinderPlugin exte
                             indent(pw, 3, String.format("<version>%s</version>",
props.get("version")));
                             indent(pw, 3, "<scope>provided</scope>");
                             indent(pw, 2, "</dependency>");
-                        } catch (IOException e) {
-                        } finally {
-                            if (is != null) {
+                        }
+                        catch (IOException e)
+                        {
+                        }
+                        finally
+                        {
+                            if (is != null)
+                            {
                                 is.close();
                             }
                         }
@@ -182,26 +205,35 @@ public class DependencyFinderPlugin exte
         drawForm(pw, findField);
         endTable(pw);
     }
-    
-    private void indent(PrintWriter pw, int count, String string) {
-        for (int i = 0; i < count; i++) {
+
+    private void indent(PrintWriter pw, int count, String string)
+    {
+        for (int i = 0; i < count; i++)
+        {
             pw.print(INDENT);
         }
         pw.println(string.replace("<", "&lt;").replace(">", "&gt;"));
     }
 
-    static SortedSet<String> getPackageNames(String findField) {
+    static SortedSet<String> getPackageNames(String findField)
+    {
         String[] parts = findField.split("\\s");
         SortedSet<String> result = new TreeSet<String>();
-        for (String part : parts) {
+        for (String part : parts)
+        {
             part = part.trim();
-            if (part.length() > 0) {
+            if (part.length() > 0)
+            {
                 int idx = part.lastIndexOf('.');
-                if (idx != -1) {
+                if (idx != -1)
+                {
                     char firstCharAfterLastDot = part.charAt(idx + 1);
-                    if (Character.isUpperCase(firstCharAfterLastDot)) {
+                    if (Character.isUpperCase(firstCharAfterLastDot))
+                    {
                         result.add(part.substring(0, idx));
-                    } else {
+                    }
+                    else
+                    {
                         result.add(part);
                     }
                 }

Modified: felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/PackageAdminPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/PackageAdminPlugin.java?rev=1187509&r1=1187508&r2=1187509&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/PackageAdminPlugin.java
(original)
+++ felix/trunk/webconsole-plugins/packageadmin/src/main/java/org/apache/felix/webconsole/plugins/packageadmin/internal/PackageAdminPlugin.java
Fri Oct 21 19:09:09 2011
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -33,7 +33,8 @@ import org.osgi.service.packageadmin.Pac
 import org.osgi.util.tracker.ServiceTracker;
 
 @SuppressWarnings("serial")
-public class PackageAdminPlugin extends GenericServlet {
+public class PackageAdminPlugin extends GenericServlet
+{
 
     static final String LABEL = "pkgadmin";
 
@@ -45,47 +46,52 @@ public class PackageAdminPlugin extends 
 
     private final ServiceTracker pkgAdminTracker;
 
-    PackageAdminPlugin(final BundleContext bundleContext,
-            final ServiceTracker pkgAdminTracker) {
+    PackageAdminPlugin(final BundleContext bundleContext, final ServiceTracker pkgAdminTracker)
+    {
         this.bundleContext = bundleContext;
         this.pkgAdminTracker = pkgAdminTracker;
     }
 
-    public void service(ServletRequest req, ServletResponse res)
-            throws IOException {
+    public void service(ServletRequest req, ServletResponse res) throws IOException
+    {
 
         final PrintWriter pw = ((HttpServletResponse) res).getWriter();
 
         final PackageAdmin pa = (PackageAdmin) this.pkgAdminTracker.getService();
-        if (pa == null) {
+        if (pa == null)
+        {
             printStatLine(pw, "PackageAdmin Service not registered");
             return;
         }
 
-        try {
+        try
+        {
             Map<String, Set<ExportedPackage>> exports = collectExportedPackages(pa);
-            printStatLine(pw,
-                "PackageAdmin service reports %d exported packages",
-                exports.size());
+            printStatLine(pw, "PackageAdmin service reports %d exported packages", exports.size());
             dumpDuplicates(pw, exports);
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             pw.println("failure ...." + e);
             e.printStackTrace(pw);
         }
     }
 
-    private Map<String, Set<ExportedPackage>> collectExportedPackages(
-            final PackageAdmin pa) {
+    private Map<String, Set<ExportedPackage>> collectExportedPackages(final PackageAdmin
pa)
+    {
         Map<String, Set<ExportedPackage>> exports = new TreeMap<String, Set<ExportedPackage>>();
 
-        for (Bundle bundle : this.bundleContext.getBundles()) {
+        for (Bundle bundle : this.bundleContext.getBundles())
+        {
             final ExportedPackage[] bundleExports = pa.getExportedPackages(bundle);
-            if (bundleExports != null) {
-                for (ExportedPackage exportedPackage : bundleExports) {
+            if (bundleExports != null)
+            {
+                for (ExportedPackage exportedPackage : bundleExports)
+                {
                     Set<ExportedPackage> exportSet = exports.get(exportedPackage.getName());
-                    if (exportSet == null) {
-                        exportSet = new TreeSet<ExportedPackage>(
-                            EXPORT_PACKAGE_COMPARATOR);
+                    if (exportSet == null)
+                    {
+                        exportSet = new TreeSet<ExportedPackage>(EXPORT_PACKAGE_COMPARATOR);
                         exports.put(exportedPackage.getName(), exportSet);
                     }
                     exportSet.add(exportedPackage);
@@ -96,39 +102,44 @@ public class PackageAdminPlugin extends 
         return exports;
     }
 
-    private void printStatLine(final PrintWriter pw, final String format,
-            final Object... args) {
+    private void printStatLine(final PrintWriter pw, final String format, final Object...
args)
+    {
         final String message = String.format(format, args);
         pw.printf("<p class=\"statline\">%s</p>%n", message);
     }
 
-    private void printTitle(final PrintWriter pw, final String format,
-            final Object... args) {
+    private void printTitle(final PrintWriter pw, final String format, final Object... args)
+    {
         pw.println("<div class=\"ui-widget-header ui-corner-top\">");
         pw.printf(format, args);
         pw.println("</div>");
     }
 
-    private void dumpDuplicates(final PrintWriter pw,
-            final Map<String, Set<ExportedPackage>> exports) {
+    private void dumpDuplicates(final PrintWriter pw, final Map<String, Set<ExportedPackage>>
exports)
+    {
         printTitle(pw, "Duplicate Exported Packages");
         pw.println("<table class=\"nicetable\">");
         pw.println("<tr><th>Package</th><th>Exports</th><th>Imports</th></tr>");
-        for (Entry<String, Set<ExportedPackage>> exportEntry : exports.entrySet())
{
+        for (Entry<String, Set<ExportedPackage>> exportEntry : exports.entrySet())
+        {
             Set<ExportedPackage> exportSet = exportEntry.getValue();
-            if (exportSet.size() > 1) {
-                String firstCol = String.format("<td rowspan=\"%s\">%s</td>",
-                    exportSet.size(), exportEntry.getKey());
-                for (ExportedPackage exportedPackage : exportSet) {
+            if (exportSet.size() > 1)
+            {
+                String firstCol = String.format("<td rowspan=\"%s\">%s</td>",
exportSet.size(), exportEntry.getKey());
+                for (ExportedPackage exportedPackage : exportSet)
+                {
                     Bundle[] importers = exportedPackage.getImportingBundles();
-                    pw.printf("<tr>%s<td>version=%s, Bundle %s</td><td>",
-                        firstCol, exportedPackage.getVersion(),
+                    pw.printf("<tr>%s<td>version=%s, Bundle %s</td><td>",
firstCol, exportedPackage.getVersion(),
                         exportedPackage.getExportingBundle());
-                    if (importers != null && importers.length > 0) {
-                        for (Bundle bundle : importers) {
+                    if (importers != null && importers.length > 0)
+                    {
+                        for (Bundle bundle : importers)
+                        {
                             pw.printf("%s<br>", bundle);
                         }
-                    } else {
+                    }
+                    else
+                    {
                         pw.print("&nbsp;");
                     }
                     pw.println("</td></tr>");
@@ -139,13 +150,13 @@ public class PackageAdminPlugin extends 
         pw.println("</table>");
     }
 
-    private void dumpDuplicatesAsTxt(final PrintWriter pw,
-            final Map<String, Set<ExportedPackage>> exports)
+    private void dumpDuplicatesAsTxt(final PrintWriter pw, final Map<String, Set<ExportedPackage>>
exports)
     {
         pw.println("Duplicate Exported Packages");
         pw.println("---------------------------");
         final List<String[]> lines = new ArrayList<String[]>();
-        lines.add(new String[] {"Package", "Exports", "Imports"});
+        lines.add(new String[]
+            { "Package", "Exports", "Imports" });
 
         for (Entry<String, Set<ExportedPackage>> exportEntry : exports.entrySet())
         {
@@ -156,46 +167,51 @@ public class PackageAdminPlugin extends 
                 for (ExportedPackage exportedPackage : exportSet)
                 {
                     final Bundle[] importers = exportedPackage.getImportingBundles();
-                    final String secondCol = "version=" + exportedPackage.getVersion() +
", Bundle " + exportedPackage.getExportingBundle();
-                    if (importers != null && importers.length > 0) {
+                    final String secondCol = "version=" + exportedPackage.getVersion() +
", Bundle "
+                        + exportedPackage.getExportingBundle();
+                    if (importers != null && importers.length > 0)
+                    {
                         boolean first = true;
                         for (Bundle bundle : importers)
                         {
-                            if ( first )
+                            if (first)
                             {
-                                lines.add(new String[] {firstCol, secondCol, bundle.toString()});
+                                lines.add(new String[]
+                                    { firstCol, secondCol, bundle.toString() });
                                 first = false;
                             }
                             else
                             {
-                                lines.add(new String[] {"", "", bundle.toString()});
+                                lines.add(new String[]
+                                    { "", "", bundle.toString() });
 
                             }
                         }
                     }
                     else
                     {
-                        lines.add(new String[] {firstCol, secondCol, ""});
+                        lines.add(new String[]
+                            { firstCol, secondCol, "" });
                     }
                     firstCol = "";
                 }
             }
         }
         int maxFirst = 0, maxSecond = 0;
-        for(final String[] entry : lines)
+        for (final String[] entry : lines)
         {
-            if ( entry[0].length() > maxFirst )
+            if (entry[0].length() > maxFirst)
             {
                 maxFirst = entry[0].length();
             }
-            if ( entry[1].length() > maxSecond )
+            if (entry[1].length() > maxSecond)
             {
                 maxSecond = entry[1].length();
             }
         }
         maxFirst += 2;
         maxSecond += 2;
-        for(final String[] entry : lines)
+        for (final String[] entry : lines)
         {
             padText(pw, entry[0], maxFirst);
             padText(pw, entry[1], maxSecond);
@@ -207,31 +223,35 @@ public class PackageAdminPlugin extends 
     {
         pw.print(text);
         final int padLength = length - text.length();
-        for(int i=0;i<padLength;i++) {
+        for (int i = 0; i < padLength; i++)
+        {
             pw.print(' ');
         }
     }
 
-    private static class ExportedPackageComparator implements
-            Comparator<ExportedPackage> {
+    private static class ExportedPackageComparator implements Comparator<ExportedPackage>
+    {
 
-        public int compare(ExportedPackage o1, ExportedPackage o2) {
-            if (o1 == o2) {
+        public int compare(ExportedPackage o1, ExportedPackage o2)
+        {
+            if (o1 == o2)
+            {
                 return 0;
             }
 
             int name = o1.getName().compareTo(o2.getName());
-            if (name != 0) {
+            if (name != 0)
+            {
                 return name;
             }
 
             int version = o1.getVersion().compareTo(o2.getVersion());
-            if (version != 0) {
+            if (version != 0)
+            {
                 return version;
             }
 
-            return Long.valueOf(o1.getExportingBundle().getBundleId()).compareTo(
-                o2.getExportingBundle().getBundleId());
+            return Long.valueOf(o1.getExportingBundle().getBundleId()).compareTo(o2.getExportingBundle().getBundleId());
         }
 
     }
@@ -248,7 +268,8 @@ public class PackageAdminPlugin extends 
             return;
         }
 
-        try {
+        try
+        {
             Map<String, Set<ExportedPackage>> exports = collectExportedPackages(pa);
 
             pw.print("PackageAdmin service reports ");
@@ -257,7 +278,9 @@ public class PackageAdminPlugin extends 
             pw.println();
 
             dumpDuplicatesAsTxt(pw, exports);
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             pw.println("failure ...." + e);
         }
     }

Modified: felix/trunk/webconsole-plugins/packageadmin/src/test/java/org/apache/felix/webconsole/plugins/packageadmin/internal/DependencyFinderPluginTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/packageadmin/src/test/java/org/apache/felix/webconsole/plugins/packageadmin/internal/DependencyFinderPluginTest.java?rev=1187509&r1=1187508&r2=1187509&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/packageadmin/src/test/java/org/apache/felix/webconsole/plugins/packageadmin/internal/DependencyFinderPluginTest.java
(original)
+++ felix/trunk/webconsole-plugins/packageadmin/src/test/java/org/apache/felix/webconsole/plugins/packageadmin/internal/DependencyFinderPluginTest.java
Fri Oct 21 19:09:09 2011
@@ -22,25 +22,30 @@ import java.util.SortedSet;
 import static org.junit.Assert.*;
 import org.junit.Test;
 
-public class DependencyFinderPluginTest {
-    
+public class DependencyFinderPluginTest
+{
+
     @Test
-    public void single() {
+    public void single()
+    {
         SortedSet<String> r = DependencyFinderPlugin.getPackageNames("com.foo.bar");
         assertEquals(1, r.size());
         assertEquals("com.foo.bar", r.first());
     }
-    
+
     @Test
-    public void singleClass() {
+    public void singleClass()
+    {
         SortedSet<String> r = DependencyFinderPlugin.getPackageNames("com.foo.bar.MyClass");
         assertEquals(1, r.size());
         assertEquals("com.foo.bar", r.first());
     }
-    
+
     @Test
-    public void multiple() {
-        SortedSet<String> r = DependencyFinderPlugin.getPackageNames("com.foo.bar\ncom.foo.bar2\ncom.foo.bar3.MyClass\ncom.foo.bar.MyClass");
+    public void multiple()
+    {
+        SortedSet<String> r = DependencyFinderPlugin
+            .getPackageNames("com.foo.bar\ncom.foo.bar2\ncom.foo.bar3.MyClass\ncom.foo.bar.MyClass");
         assertEquals(3, r.size());
         Iterator<String> it = r.iterator();
         assertEquals("com.foo.bar", it.next());



Mime
View raw message