felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1450134 - in /felix/trunk/inventory: ./ src/main/java/org/apache/felix/inventory/ src/main/java/org/apache/felix/inventory/impl/ src/main/java/org/apache/felix/inventory/impl/webconsole/
Date Tue, 26 Feb 2013 11:06:46 GMT
Author: cziegeler
Date: Tue Feb 26 11:06:45 2013
New Revision: 1450134

URL: http://svn.apache.org/r1450134
Log:
Remove printer handler and printer manager interface, remove category support and use java 1.4 as the base

Added:
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java   (with props)
Removed:
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinterHandler.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinterManager.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/package-info.java
Modified:
    felix/trunk/inventory/pom.xml
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinter.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/PrinterMode.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/ZipAttachmentProvider.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/AbstractWebConsolePlugin.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/Activator.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/ClassUtils.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/WebConsolePlugin.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConfigurationPrinterAdapter.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConsoleConstants.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ResourceBundleManager.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java

Modified: felix/trunk/inventory/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/pom.xml?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/pom.xml (original)
+++ felix/trunk/inventory/pom.xml Tue Feb 26 11:06:45 2013
@@ -42,6 +42,7 @@
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
+                        <Package-Export>org.apache.felix.inventory;version=1.0.0</Package-Export>
                         <Bundle-Category>osgi</Bundle-Category>
                         <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                         <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
@@ -50,16 +51,6 @@
                     </instructions>
                 </configuration>
             </plugin>
-            <!--
-                Configure default compilation for Java 5
-            -->
-            <plugin>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                </configuration>
-            </plugin>
         </plugins>        
     </build>    
 

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinter.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinter.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinter.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinter.java Tue Feb 26 11:06:45 2013
@@ -66,12 +66,6 @@ public interface InventoryPrinter {
     String CONFIG_TITLE = "felix.inventory.printer.title"; //$NON-NLS-1$
 
     /**
-     * The category under which this printer is categorized.
-     * This property is optional.
-     */
-    String CONFIG_CATEGORY = "felix.inventory.printer.category"; //$NON-NLS-1$
-
-    /**
      * Prints the configuration report to the given <code>printWriter</code>.
      * Implementations are free to print whatever information they deem useful.
      *

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/PrinterMode.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/PrinterMode.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/PrinterMode.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/PrinterMode.java Tue Feb 26 11:06:45 2013
@@ -21,11 +21,69 @@ package org.apache.felix.inventory;
 /**
  * Enumeration for the different printer modes.
  */
-public enum PrinterMode {
+public final class PrinterMode {
 
-    TEXT,          // plain text
-    HTML_BODY,     // HTML which can be placed inside a HTML body element (no external references)
-    JSON,          // JSON output
-    ZIP_FILE_TEXT, // file content for a zip
-    ZIP_FILE_JSON  // json file content for a zip
+    // plain text
+    public static PrinterMode TEXT = new PrinterMode("TEXT");
+
+    // HTML which can be placed inside a HTML body element (no external references)
+    public static PrinterMode HTML_BODY = new PrinterMode("HTML_BODY");
+
+    // JSON output
+    public static PrinterMode JSON = new PrinterMode("JSON");
+
+    // file content for a zip
+    public static PrinterMode ZIP_FILE_TEXT = new PrinterMode("ZIP_FILE_TEXT");
+
+    // json file content for a zip
+    public static PrinterMode ZIP_FILE_JSON = new PrinterMode("ZIP_FILE_JSON");
+
+    private final String mode;
+
+    private PrinterMode(final String mode) {
+        this.mode = mode;
+    }
+
+    public static PrinterMode valueOf(final String m) {
+        if ( TEXT.name().equals(m) ) {
+            return TEXT;
+        } else if ( HTML_BODY.equals(m) ) {
+            return HTML_BODY;
+        } else if ( JSON.equals(m) ) {
+            return JSON;
+        } else if ( ZIP_FILE_TEXT.equals(m) ) {
+            return ZIP_FILE_TEXT;
+        } else if ( ZIP_FILE_JSON.equals(m) ) {
+            return ZIP_FILE_JSON;
+        }
+        return null;
+    }
+
+    public String name() {
+        return this.mode;
+    }
+
+    /**
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode() {
+        return mode.hashCode();
+    }
+
+    /**
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final PrinterMode other = (PrinterMode) obj;
+        return mode.equals(other.mode);
+    }
 }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/ZipAttachmentProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/ZipAttachmentProvider.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/ZipAttachmentProvider.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/ZipAttachmentProvider.java Tue Feb 26 11:06:45 2013
@@ -33,7 +33,7 @@ import java.util.zip.ZipOutputStream;
  * should either support {@link PrinterMode.ZIP_FILE_JSON}
  * or {@link PrinterMode.ZIP_FILE_TEXT}
  */
-public interface ZipAttachmentProvider extends InventoryPrinter {
+public interface ZipAttachmentProvider {
 
     /**
      * Add attachments to the zip output stream.

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/AbstractWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/AbstractWebConsolePlugin.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/AbstractWebConsolePlugin.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/AbstractWebConsolePlugin.java Tue Feb 26 11:06:45 2013
@@ -31,8 +31,6 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.felix.inventory.InventoryPrinterHandler;
-import org.apache.felix.inventory.InventoryPrinterManager;
 import org.apache.felix.inventory.PrinterMode;
 
 /**
@@ -43,13 +41,13 @@ public abstract class AbstractWebConsole
     private static final long serialVersionUID = 1L;
 
     /** The inventory printer manager. */
-    protected final InventoryPrinterManager inventoryPrinterManager;
+    protected final InventoryPrinterManagerImpl inventoryPrinterManager;
 
     /**
      * Constructor
      * @param inventoryPrinterManager The manager
      */
-    AbstractWebConsolePlugin(final InventoryPrinterManager inventoryPrinterManager) {
+    AbstractWebConsolePlugin(final InventoryPrinterManagerImpl inventoryPrinterManager) {
         this.inventoryPrinterManager = inventoryPrinterManager;
     }
 
@@ -60,8 +58,9 @@ public abstract class AbstractWebConsole
             final InventoryPrinterHandler handler )
     throws IOException {
         if ( handler == null ) {
-            for(final InventoryPrinterHandler sph : this.inventoryPrinterManager.getHandlers(mode)) {
-                pw.printInventory(mode, sph);
+            final InventoryPrinterHandler[] adapters = this.inventoryPrinterManager.getHandlers(mode);
+            for(int i = 0; i < adapters.length; i++) {
+                pw.printInventory(mode, adapters[i]);
             }
         } else {
             if ( handler.supports(mode) ) {
@@ -89,7 +88,6 @@ public abstract class AbstractWebConsole
         response.setHeader("Pragma", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    @Override
     protected void doGet(final HttpServletRequest request,
             final HttpServletResponse response)
     throws ServletException, IOException {
@@ -299,7 +297,6 @@ public abstract class AbstractWebConsole
         // IE has an issue with white-space:pre in our case so, we write
         // <br/> instead of [CR]LF to get the line break. This also works
         // in other browsers.
-        @Override
         public void println() {
             if ( doFilter ) {
                 this.write('\n'); // write <br/>
@@ -311,7 +308,6 @@ public abstract class AbstractWebConsole
         // some VM implementation directly write in underlying stream, instead of
         // delegation to the write() method. So we need to override this, to make
         // sure, that everything is escaped correctly
-        @Override
         public void print(final String str) {
             final char[] chars = str.toCharArray();
             write(chars, 0, chars.length);
@@ -322,7 +318,6 @@ public abstract class AbstractWebConsole
 
         // always delegate to write(char[], int, int) otherwise in some VM
         // it cause endless cycle and StackOverflowError
-        @Override
         public void write(final int character) {
             synchronized (oneChar) {
                 oneChar[0] = (char) character;
@@ -332,7 +327,6 @@ public abstract class AbstractWebConsole
 
         // write the characters unmodified unless filtering is enabled in
         // which case the writeFiltered(String) method is called for filtering
-        @Override
         public void write(char[] chars, int off, int len) {
             if (doFilter) {
                 chars = this.escapeHtml(new String(chars, off, len)).toCharArray();
@@ -344,7 +338,6 @@ public abstract class AbstractWebConsole
 
         // write the string unmodified unless filtering is enabled in
         // which case the writeFiltered(String) method is called for filtering
-        @Override
         public void write( final String string, final int off, final int len ) {
             write(string.toCharArray(), off, len);
         }
@@ -397,7 +390,6 @@ public abstract class AbstractWebConsole
             super( delegatee );
         }
 
-        @Override
         protected void title( final String title ) throws IOException {
             print( "*** " );
             print( title );
@@ -405,7 +397,6 @@ public abstract class AbstractWebConsole
         }
 
 
-        @Override
         protected void end() throws IOException {
             println();
         }
@@ -433,7 +424,6 @@ public abstract class AbstractWebConsole
                     { new Integer( counter ), title } );
         }
 
-        @Override
         protected void title( final String title ) throws IOException {
             counter++;
 
@@ -443,14 +433,12 @@ public abstract class AbstractWebConsole
             zip.putNextEntry( entry );
         }
 
-        @Override
         protected void end() throws IOException {
             flush();
 
             zip.closeEntry();
         }
 
-        @Override
         public void printInventory(
                 final PrinterMode mode,
                 final InventoryPrinterHandler handler)

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/Activator.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/Activator.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/Activator.java Tue Feb 26 11:06:45 2013
@@ -16,25 +16,17 @@
  */
 package org.apache.felix.inventory.impl;
 
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.apache.felix.inventory.InventoryPrinterManager;
 import org.apache.felix.inventory.impl.webconsole.WebConsoleAdapter;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceRegistration;
 
 /**
- * Activate bridges and register manager.
+ * Activate bridges and internal manager.
  */
 public class Activator implements BundleActivator {
 
     private InventoryPrinterManagerImpl printerManager;
 
-    private ServiceRegistration managerRegistration;
-
     private WebConsoleAdapter webAdapter;
 
     /**
@@ -43,22 +35,12 @@ public class Activator implements Bundle
     public void start(final BundleContext context) throws Exception {
         this.webAdapter = new WebConsoleAdapter(context);
         this.printerManager = new InventoryPrinterManagerImpl(context);
-        final Dictionary<String, Object> props = new Hashtable<String, Object>();
-        props.put(Constants.SERVICE_DESCRIPTION, "Apache Felix Inventory Printer Manager");
-        props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
-        this.managerRegistration = context.registerService(
-                InventoryPrinterManager.class.getName(),
-                this.printerManager, props);
 }
 
     /**
      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
      */
     public void stop(final BundleContext context) throws Exception {
-        if( this.managerRegistration != null ) {
-            this.managerRegistration.unregister();
-            this.managerRegistration = null;
-        }
         if ( this.printerManager != null ) {
             this.printerManager.dispose();
             this.printerManager = null;
@@ -68,5 +50,4 @@ public class Activator implements Bundle
             this.webAdapter = null;
         }
     }
-
 }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/ClassUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/ClassUtils.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/ClassUtils.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/ClassUtils.java Tue Feb 26 11:06:45 2013
@@ -27,7 +27,7 @@ public class ClassUtils {
      * Search a method with the given name and signature.
      * @return The method or <code>null</code> if not found.
      */
-    public static Method searchMethod(final Class<?> clazz, final String mName, final Class<?>[] params) {
+    public static Method searchMethod(final Class clazz, final String mName, final Class[] params) {
         try {
             final Method m = clazz.getMethod(mName, params);
             m.setAccessible(true);

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java Tue Feb 26 11:06:45 2013
@@ -22,8 +22,6 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.zip.ZipOutputStream;
 
-import org.apache.felix.inventory.InventoryPrinterHandler;
-import org.apache.felix.inventory.InventoryPrinterManager;
 import org.apache.felix.inventory.PrinterMode;
 import org.apache.felix.inventory.impl.webconsole.ConsoleConstants;
 import org.osgi.framework.Bundle;
@@ -42,45 +40,37 @@ public class DefaultWebConsolePlugin ext
      * Constructor
      * @param inventoryPrinterAdapter The adapter
      */
-    DefaultWebConsolePlugin(final InventoryPrinterManager inventoryPrinterManager) {
+    DefaultWebConsolePlugin(final InventoryPrinterManagerImpl inventoryPrinterManager) {
         super(inventoryPrinterManager);
     }
 
-    @Override
     protected InventoryPrinterHandler getInventoryPrinterHandler() {
         return this;
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterHandler#getTitle()
+     * @see org.apache.felix.inventory.impl.InventoryPrinterHandler#getTitle()
      */
     public String getTitle() {
         return "Overview";
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterHandler#getName()
+     * @see org.apache.felix.inventory.impl.InventoryPrinterHandler#getName()
      */
     public String getName() {
         return "config";
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterHandler#getCategory()
-     */
-    public String getCategory() {
-        return "Inventory";
-    }
-
-    /**
-     * @see org.apache.felix.inventory.InventoryPrinterHandler#getModes()
+     * @see org.apache.felix.inventory..implInventoryPrinterHandler#getModes()
      */
     public PrinterMode[] getModes() {
         return new PrinterMode[] {PrinterMode.TEXT};
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterHandler#supports(org.apache.felix.inventory.PrinterMode)
+     * @see org.apache.felix.inventory.impl.InventoryPrinterHandler#supports(org.apache.felix.inventory.PrinterMode)
      */
     public boolean supports(final PrinterMode mode) {
         return mode == PrinterMode.TEXT;
@@ -93,10 +83,10 @@ public class DefaultWebConsolePlugin ext
         final InventoryPrinterHandler[] handlers = this.inventoryPrinterManager.getAllHandlers();
         printWriter.print("Currently registered ");
         printWriter.print(String.valueOf(handlers.length));
-        printWriter.println(" inventory printer.");
+        printWriter.println(" printer(s).");
         printWriter.println();
-        for(final InventoryPrinterHandler handler : handlers) {
-            printWriter.println(handler.getTitle());
+        for(int i=0; i<handlers.length; i++) {
+            printWriter.println(handlers[i].getTitle());
         }
     }
 
@@ -109,13 +99,13 @@ public class DefaultWebConsolePlugin ext
     }
 
     public static ServiceRegistration register(final BundleContext context,
-            final InventoryPrinterManager manager) {
+            final InventoryPrinterManagerImpl manager) {
         final DefaultWebConsolePlugin dwcp = new DefaultWebConsolePlugin(manager);
 
-        final Dictionary<String, Object> props = new Hashtable<String, Object>();
+        final Dictionary props = new Hashtable();
         props.put(ConsoleConstants.PLUGIN_LABEL, dwcp.getName());
         props.put(ConsoleConstants.PLUGIN_TITLE, dwcp.getTitle());
-        props.put(ConsoleConstants.PLUGIN_CATEGORY, dwcp.getCategory());
+        props.put(ConsoleConstants.PLUGIN_CATEGORY, ConsoleConstants.WEB_CONSOLE_CATEGORY);
         return context.registerService(ConsoleConstants.INTERFACE_SERVLET, new ServiceFactory() {
 
             public void ungetService(final Bundle bundle, final ServiceRegistration registration,

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java Tue Feb 26 11:06:45 2013
@@ -25,8 +25,6 @@ import java.util.Locale;
 import java.util.zip.ZipOutputStream;
 
 import org.apache.felix.inventory.InventoryPrinter;
-import org.apache.felix.inventory.InventoryPrinterHandler;
-import org.apache.felix.inventory.InventoryPrinterManager;
 import org.apache.felix.inventory.PrinterMode;
 import org.apache.felix.inventory.ZipAttachmentProvider;
 import org.osgi.framework.BundleContext;
@@ -34,8 +32,10 @@ import org.osgi.framework.ServiceRegistr
 
 /**
  * Helper class for a inventory printer.
+ *
+ * The adapter simplifies accessing and working with the inventory printer.
  */
-public class InventoryPrinterAdapter implements InventoryPrinterHandler, Comparable<InventoryPrinterAdapter> {
+public class InventoryPrinterAdapter implements InventoryPrinterHandler, Comparable {
 
     /**
      * Formatter pattern to render the current time of inventory generation.
@@ -78,10 +78,10 @@ public class InventoryPrinterAdapter imp
     /**
      * Comparator for adapters based on the service ranking.
      */
-    public static final Comparator<InventoryPrinterAdapter> RANKING_COMPARATOR = new Comparator<InventoryPrinterAdapter>() {
+    public static final Comparator RANKING_COMPARATOR = new Comparator() {
 
-        public int compare(final InventoryPrinterAdapter o1, final InventoryPrinterAdapter o2) {
-            return o1.description.compareTo(o2.description);
+        public int compare(final Object o1, final Object o2) {
+            return ((InventoryPrinterAdapter)o1).description.compareTo(((InventoryPrinterAdapter)o2).description);
         }
     };
 
@@ -112,7 +112,7 @@ public class InventoryPrinterAdapter imp
         this.attachmentMethod = attachmentMethod;
     }
 
-    public void registerConsole(final BundleContext context, final InventoryPrinterManager manager) {
+    public void registerConsole(final BundleContext context, final InventoryPrinterManagerImpl manager) {
         if ( this.registration == null &&
              (supports(PrinterMode.HTML_BODY) || supports(PrinterMode.TEXT))) {
             this.registration = WebConsolePlugin.register(context, manager, this.description);
@@ -127,28 +127,21 @@ public class InventoryPrinterAdapter imp
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterHandler#getTitle()
+     * The human readable title for the inventory printer.
      */
     public String getTitle() {
         return this.description.getTitle();
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterHandler#getName()
+     * The unique name of the printer.
      */
     public String getName() {
         return this.description.getName();
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterHandler#getCategory()
-     */
-    public String getCategory() {
-        return this.description.getCategory();
-    }
-
-    /**
-     * @see org.apache.felix.inventory.InventoryPrinterHandler#getModes()
+     * All supported modes.
      */
     public PrinterMode[] getModes() {
         return this.description.getModes();
@@ -168,7 +161,7 @@ public class InventoryPrinterAdapter imp
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterHandler#supports(org.apache.felix.inventory.PrinterMode)
+     * Whether the printer supports this mode.
      */
     public boolean supports(final PrinterMode mode) {
         for(int i=0; i<this.description.getModes().length; i++) {
@@ -196,7 +189,6 @@ public class InventoryPrinterAdapter imp
     /**
      * @see java.lang.Object#toString()
      */
-    @Override
     public String toString() {
         return printer.getClass() + "(" + super.toString() + ")";
     }
@@ -204,8 +196,8 @@ public class InventoryPrinterAdapter imp
     /**
      * @see java.lang.Comparable#compareTo(java.lang.Object)
      */
-    public int compareTo(final InventoryPrinterAdapter spa) {
-        return this.description.getSortKey().compareTo(spa.description.getSortKey());
+    public int compareTo(final Object spa) {
+        return this.description.getSortKey().compareTo(((InventoryPrinterAdapter)spa).description.getSortKey());
     }
 
     public InventoryPrinterDescription getDescription() {

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java Tue Feb 26 11:06:45 2013
@@ -25,7 +25,7 @@ import org.osgi.framework.ServiceReferen
 /**
  * Helper class for a configuration printer.
  */
-public class InventoryPrinterDescription implements Comparable<InventoryPrinterDescription> {
+public class InventoryPrinterDescription implements Comparable {
 
     private final ServiceReference reference;
 
@@ -37,8 +37,6 @@ public class InventoryPrinterDescription
 
     private final String sortKey;
 
-    private final String category;
-
     public InventoryPrinterDescription(final ServiceReference ref) {
         this.reference = ref;
 
@@ -75,13 +73,6 @@ public class InventoryPrinterDescription
             this.title = null;
             this.sortKey = null;
         }
-
-        // check category
-        if ( ref.getProperty(InventoryPrinter.CONFIG_CATEGORY) != null ) {
-            this.category = ref.getProperty(InventoryPrinter.CONFIG_CATEGORY).toString();
-        } else {
-            this.category = null;
-        }
     }
 
     public String getTitle() {
@@ -96,10 +87,6 @@ public class InventoryPrinterDescription
         return this.name;
     }
 
-    public String getCategory() {
-        return this.category;
-    }
-
     public PrinterMode[] getModes() {
         return this.modes;
     }
@@ -111,24 +98,20 @@ public class InventoryPrinterDescription
     /**
      * @see java.lang.Comparable#compareTo(java.lang.Object)
      */
-    public int compareTo(final InventoryPrinterDescription spa) {
-        return this.reference.compareTo(spa.reference);
+    public int compareTo(final Object spa) {
+        return this.reference.compareTo(((InventoryPrinterDescription)spa).reference);
     }
 
-    @Override
     public boolean equals(final Object obj) {
         return this.reference.equals(obj);
     }
 
-    @Override
     public int hashCode() {
         return this.reference.hashCode();
     }
 
-    @Override
     public String toString() {
         return "InventoryPrinterDescription [title=" + title + ", name=" + name
-                + ", modes=" + Arrays.toString(modes) + ", sortKey=" + sortKey
-                + ", category=" + category + "]";
+                + ", modes=" + Arrays.toString(modes) + ", sortKey=" + sortKey + "]";
     }
 }

Added: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java?rev=1450134&view=auto
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java (added)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java Tue Feb 26 11:06:45 2013
@@ -0,0 +1,46 @@
+/*
+ * 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 (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
+ *
+ * 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
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.inventory.impl;
+
+import org.apache.felix.inventory.InventoryPrinter;
+import org.apache.felix.inventory.PrinterMode;
+import org.apache.felix.inventory.ZipAttachmentProvider;
+
+
+/**
+ * The inventory printer handler can be used by clients to access
+ * a inventory printer.
+ *
+ * For clients using inventory printers, a handler simplifies accessing and
+ * working with the inventory printer.
+ */
+public interface InventoryPrinterHandler extends InventoryPrinter, ZipAttachmentProvider {
+
+    /** The unique name of the printer. */
+    String getName();
+
+    /** The human readable title for the inventory printer. */
+    String getTitle();
+
+    /** All supported modes. */
+    PrinterMode[] getModes();
+
+    /** Whether the printer supports this mode. */
+    boolean supports( final PrinterMode mode );
+}
\ No newline at end of file

Propchange: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java Tue Feb 26 11:06:45 2013
@@ -24,12 +24,11 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentSkipListSet;
 
 import org.apache.felix.inventory.InventoryPrinter;
-import org.apache.felix.inventory.InventoryPrinterHandler;
-import org.apache.felix.inventory.InventoryPrinterManager;
 import org.apache.felix.inventory.PrinterMode;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
@@ -46,8 +45,7 @@ import org.slf4j.LoggerFactory;
  * based on their name. If more than one printer with the same name
  * is registered, the one with highest service ranking is used.
  */
-public class InventoryPrinterManagerImpl implements InventoryPrinterManager,
-    ServiceTrackerCustomizer {
+public class InventoryPrinterManagerImpl implements ServiceTrackerCustomizer {
 
     /** Logger. */
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -58,11 +56,11 @@ public class InventoryPrinterManagerImpl
     /** Service tracker for Inventory printers. */
     private final ServiceTracker cfgPrinterTracker;
 
-    /** All adapters mapped by their name. */
-    private final Map<String, List<InventoryPrinterAdapter>> allAdapters = new HashMap<String, List<InventoryPrinterAdapter>>();
+    /** All adapters mapped by their name. Type of the map: String, List<InventoryPrinterAdapter> */
+    private final Map allAdapters = new HashMap();
 
-    /** Used adapters. */
-    private final Set<InventoryPrinterAdapter> usedAdapters = new ConcurrentSkipListSet<InventoryPrinterAdapter>();
+    /** Used adapters. Type of the set: InventoryPrinterAdapter */
+    private final Set usedAdapters = new ConcurrentSkipListSet();
 
     /** Registration for the web console. */
     private final ServiceRegistration pluginRegistration;
@@ -149,14 +147,14 @@ public class InventoryPrinterManagerImpl
 
         final String key = adapter.getName();
         synchronized ( this.allAdapters ) {
-            List<InventoryPrinterAdapter> list = this.allAdapters.get(key);
+            List list = (List) this.allAdapters.get(key);
             final InventoryPrinterAdapter first;
             if ( list == null ) {
-                list = new LinkedList<InventoryPrinterAdapter>();
+                list = new LinkedList();
                 this.allAdapters.put(key, list);
                 first = null;
             } else {
-                first = list.get(0);
+                first = (InventoryPrinterAdapter) list.get(0);
             }
             list.add(adapter);
             Collections.sort(list, InventoryPrinterAdapter.RANKING_COMPARATOR);
@@ -172,7 +170,7 @@ public class InventoryPrinterManagerImpl
             }
         }
         if ( removeAdapter != null ) {
-            final Iterator<InventoryPrinterAdapter> i = this.usedAdapters.iterator();
+            final Iterator i = this.usedAdapters.iterator();
             while ( i.hasNext() ) {
                 if ( i.next() == removeAdapter ) {
                     i.remove();
@@ -197,13 +195,13 @@ public class InventoryPrinterManagerImpl
 
     private void removeService(final ServiceReference reference) {
         synchronized ( this.allAdapters ) {
-            final Iterator<Map.Entry<String, List<InventoryPrinterAdapter>>> i = this.allAdapters.entrySet().iterator();
+            final Iterator i = this.allAdapters.entrySet().iterator();
             while ( i.hasNext() ) {
-                final Map.Entry<String, List<InventoryPrinterAdapter>> entry = i.next();
-                final Iterator<InventoryPrinterAdapter> iter = entry.getValue().iterator();
+                final Map.Entry entry = (Entry) i.next();
+                final Iterator iter = ((List) entry.getValue()).iterator();
                 boolean removed = false;
                 while ( iter.hasNext() ) {
-                    final InventoryPrinterAdapter adapter = iter.next();
+                    final InventoryPrinterAdapter adapter = (InventoryPrinterAdapter) iter.next();
                     if ( adapter.getDescription().getServiceReference().compareTo(reference) == 0 ) {
                         iter.remove();
                         removed = true;
@@ -211,16 +209,16 @@ public class InventoryPrinterManagerImpl
                     }
                 }
                 if ( removed ) {
-                    if ( entry.getValue().size() == 0 ) {
+                    if ( ((List)entry.getValue()).size() == 0 ) {
                         i.remove();
                     }
                     break;
                 }
             }
         }
-        final Iterator<InventoryPrinterAdapter> iter = this.usedAdapters.iterator();
+        final Iterator iter = this.usedAdapters.iterator();
         while ( iter.hasNext() ) {
-            final InventoryPrinterAdapter adapter = iter.next();
+            final InventoryPrinterAdapter adapter = (InventoryPrinterAdapter) iter.next();
             if ( adapter.getDescription().getServiceReference().compareTo(reference) == 0 ) {
                 iter.remove();
                 adapter.unregisterConsole();
@@ -230,30 +228,37 @@ public class InventoryPrinterManagerImpl
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterManager#getAllHandlers()
+     * Get all inventory printer handlers.
+     * @return A list of handlers - might be empty.
      */
     public InventoryPrinterHandler[] getAllHandlers() {
-        return this.usedAdapters.toArray(new InventoryPrinterHandler[this.usedAdapters.size()]);
+        return (InventoryPrinterHandler[]) this.usedAdapters.toArray(new InventoryPrinterHandler[this.usedAdapters.size()]);
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterManager#getHandlers(org.apache.felix.inventory.PrinterMode)
+     * Get all handlers supporting the mode.
+     * @return A list of handlers - might be empty.
      */
     public InventoryPrinterHandler[] getHandlers(final PrinterMode mode) {
-        final List<InventoryPrinterHandler> result = new ArrayList<InventoryPrinterHandler>();
-        for(final InventoryPrinterAdapter printer : this.usedAdapters) {
+        final List result = new ArrayList();
+        final Iterator i = this.usedAdapters.iterator();
+        while ( i .hasNext() ) {
+            final InventoryPrinterAdapter printer = (InventoryPrinterAdapter) i.next();
             if ( printer.supports(mode) ) {
                 result.add(printer);
             }
         }
-        return result.toArray(new InventoryPrinterHandler[result.size()]);
+        return (InventoryPrinterHandler[]) result.toArray(new InventoryPrinterHandler[result.size()]);
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinterManager#getHandler(java.lang.String)
+     * Return a handler for the unique name.
+     * @return The corresponding handler or <code>null</code>.
      */
     public InventoryPrinterHandler getHandler(final String name) {
-        for(final InventoryPrinterAdapter printer : this.usedAdapters) {
+        final Iterator i = this.usedAdapters.iterator();
+        while ( i .hasNext() ) {
+            final InventoryPrinterAdapter printer = (InventoryPrinterAdapter) i.next();
             if ( name.equals(printer.getName()) ) {
                 return printer;
             }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/WebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/WebConsolePlugin.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/WebConsolePlugin.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/WebConsolePlugin.java Tue Feb 26 11:06:45 2013
@@ -19,8 +19,6 @@ package org.apache.felix.inventory.impl;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
-import org.apache.felix.inventory.InventoryPrinterHandler;
-import org.apache.felix.inventory.InventoryPrinterManager;
 import org.apache.felix.inventory.impl.webconsole.ConsoleConstants;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -42,25 +40,24 @@ public class WebConsolePlugin extends Ab
      * @param inventoryPrinterManager The inventory printer manager.
      * @param printerName The name of the printer this plugin is displaying.
      */
-    WebConsolePlugin(final InventoryPrinterManager inventoryPrinterManager,
+    WebConsolePlugin(final InventoryPrinterManagerImpl inventoryPrinterManager,
             final String printerName) {
         super(inventoryPrinterManager);
         this.printerName = printerName;
     }
 
-    @Override
     protected InventoryPrinterHandler getInventoryPrinterHandler() {
         return this.inventoryPrinterManager.getHandler(this.printerName);
     }
 
     public static ServiceRegistration register(
             final BundleContext context,
-            final InventoryPrinterManager manager,
+            final InventoryPrinterManagerImpl manager,
             final InventoryPrinterDescription desc) {
-        final Dictionary<String, Object> props = new Hashtable<String, Object>();
-        props.put(ConsoleConstants.PLUGIN_LABEL, "inventory-" + desc.getName());
+        final Dictionary props = new Hashtable();
+        props.put(ConsoleConstants.PLUGIN_LABEL, "status-" + desc.getName());
         props.put(ConsoleConstants.PLUGIN_TITLE, desc.getTitle());
-        props.put(ConsoleConstants.PLUGIN_CATEGORY, desc.getCategory() == null ? "Inventory" : desc.getCategory());
+        props.put(ConsoleConstants.PLUGIN_CATEGORY, ConsoleConstants.WEB_CONSOLE_CATEGORY);
         return context.registerService(ConsoleConstants.INTERFACE_SERVLET, new ServiceFactory() {
 
             public void ungetService(final Bundle bundle, final ServiceRegistration registration,

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConfigurationPrinterAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConfigurationPrinterAdapter.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConfigurationPrinterAdapter.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConfigurationPrinterAdapter.java Tue Feb 26 11:06:45 2013
@@ -41,7 +41,7 @@ public class ConfigurationPrinterAdapter
     private final Method printMethod;
     private final Method attachmentMethod;
 
-    private static final List<String> CUSTOM_MODES = new ArrayList<String>();
+    private static final List CUSTOM_MODES = new ArrayList();
     static {
         CUSTOM_MODES.add( ConsoleConstants.MODE_TXT);
         CUSTOM_MODES.add( ConsoleConstants.MODE_WEB );
@@ -52,9 +52,10 @@ public class ConfigurationPrinterAdapter
      * Check whether the class implements the configuration printer.
      * This is done manually to avoid having the configuration printer class available.
      */
-    private static boolean isConfigurationPrinter(final Class<?> clazz) {
-        for(final Class<?> i : clazz.getInterfaces() ) {
-            if ( i.getName().equals(ConsoleConstants.INTERFACE_CONFIGURATION_PRINTER) ) {
+    private static boolean isConfigurationPrinter(final Class clazz) {
+        final Class[] interf = clazz.getInterfaces();
+        for(int i=0; i<interf.length; i++) {
+            if ( interf[i].getName().equals(ConsoleConstants.INTERFACE_CONFIGURATION_PRINTER) ) {
                 return true;
             }
         }
@@ -181,7 +182,7 @@ public class ConfigurationPrinterAdapter
      * Map the modes to inventory printer modes
      */
     public String[] getPrinterModes() {
-        final Set<String> list = new HashSet<String>();
+        final Set list = new HashSet();
         if ( this.match(ConsoleConstants.MODE_TXT) || this.match(ConsoleConstants.MODE_ZIP) ) {
             list.add(PrinterMode.ZIP_FILE_TEXT.name());
         }
@@ -192,7 +193,7 @@ public class ConfigurationPrinterAdapter
                 list.add(PrinterMode.TEXT.name());
             }
         }
-        return list.toArray(new String[list.size()]);
+        return (String[]) list.toArray(new String[list.size()]);
     }
 
     private boolean match(final String mode) {
@@ -227,7 +228,6 @@ public class ConfigurationPrinterAdapter
     /**
      * @see java.lang.Object#toString()
      */
-    @Override
     public String toString() {
         return title + " (" + printer.getClass() + ")";
     }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConsoleConstants.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConsoleConstants.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConsoleConstants.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConsoleConstants.java Tue Feb 26 11:06:45 2013
@@ -42,4 +42,6 @@ public class ConsoleConstants {
     public static final String MODE_TXT = "txt"; //$NON-NLS-1$
 
     public static final String PROPERTY_MODES = "modes"; //$NON-NLS-1$
+
+    public static final String WEB_CONSOLE_CATEGORY = "Status"; //$NON-NLS-1$
 }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ResourceBundleManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ResourceBundleManager.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ResourceBundleManager.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ResourceBundleManager.java Tue Feb 26 11:06:45 2013
@@ -45,7 +45,7 @@ public class ResourceBundleManager imple
 
     private final BundleContext bundleContext;
 
-    private final Map<Long, ResourceBundle> resourceBundleCaches;
+    private final Map resourceBundleCaches;
 
 
     /**
@@ -56,7 +56,7 @@ public class ResourceBundleManager imple
     public ResourceBundleManager( final BundleContext bundleContext )
     {
         this.bundleContext = bundleContext;
-        this.resourceBundleCaches = new HashMap<Long, ResourceBundle>();
+        this.resourceBundleCaches = new HashMap();
 
         bundleContext.addBundleListener( this );
     }
@@ -82,7 +82,7 @@ public class ResourceBundleManager imple
         ResourceBundle cache;
         final Long key = new Long( provider.getBundleId() );
         synchronized ( resourceBundleCaches ) {
-            cache = resourceBundleCaches.get( key );
+            cache = (ResourceBundle) resourceBundleCaches.get( key );
             if ( cache == null && !resourceBundleCaches.containsKey(key)) {
                 cache = this.loadResourceBundle(provider);
                 resourceBundleCaches.put( key, cache );

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java?rev=1450134&r1=1450133&r2=1450134&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java Tue Feb 26 11:06:45 2013
@@ -21,9 +21,12 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.zip.ZipEntry;
@@ -42,6 +45,8 @@ import org.osgi.util.tracker.ServiceTrac
 
 
 /**
+ * The web console adapter registers web console status printers
+ * as inventory printers.
  */
 public class WebConsoleAdapter implements ServiceTrackerCustomizer {
 
@@ -49,7 +54,7 @@ public class WebConsoleAdapter implement
 
     private final ServiceTracker cfgPrinterTracker;
 
-    private final Map<ServiceReference, ServiceRegistration> registrations = new HashMap<ServiceReference, ServiceRegistration>();
+    private final Map registrations = new HashMap();
 
     private final ResourceBundleManager rbManager;
 
@@ -70,16 +75,20 @@ public class WebConsoleAdapter implement
      */
     public void dispose() {
         this.cfgPrinterTracker.close();
+        final List regs = new ArrayList();
         synchronized ( this.registrations ) {
-            for(final ServiceRegistration reg : this.registrations.values()) {
-                reg.unregister();
-            }
+            regs.addAll( this.registrations.values() );
             this.registrations.clear();
         }
+        final Iterator i = regs.iterator();
+        while (i.hasNext()) {
+            final ServiceRegistration reg = (ServiceRegistration) i.next();
+            reg.unregister();
+        }
         this.rbManager.dispose();
     }
 
-    public void add(final ServiceReference reference, final Object service) {
+    private void add(final ServiceReference reference, final Object service) {
         final ConfigurationPrinterAdapter cpa = ConfigurationPrinterAdapter.createAdapter(service, reference);
         if ( cpa != null && cpa.title != null ) {
             if ( cpa.title.startsWith("%") ) {
@@ -94,73 +103,12 @@ public class WebConsoleAdapter implement
             if ( cpa.label == null ) {
                 cpa.label = cpa.title;
             }
-            final Dictionary<String, Object> props = new Hashtable<String, Object>();
+            final Dictionary props = new Hashtable();
             props.put(InventoryPrinter.CONFIG_NAME, cpa.label);
             props.put(InventoryPrinter.CONFIG_TITLE, cpa.title);
             props.put(InventoryPrinter.CONFIG_PRINTER_MODES, cpa.getPrinterModes());
 
-            if ( reference.getProperty(ConsoleConstants.PLUGIN_CATEGORY) != null ) {
-                props.put(InventoryPrinter.CONFIG_CATEGORY, reference.getProperty(ConsoleConstants.PLUGIN_CATEGORY));
-            }
-            final ServiceRegistration reg = this.bundleContext.registerService(InventoryPrinter.class.getName(), new ZipAttachmentProvider() {
-
-                /**
-                 * @see org.apache.felix.inventory.InventoryPrinter#print(org.apache.felix.inventory.PrinterMode, java.io.PrintWriter)
-                 */
-                public void print(final PrinterMode mode, final PrintWriter printWriter) {
-                    final String m;
-                    if ( mode == PrinterMode.HTML_BODY ) {
-                        m = ConsoleConstants.MODE_WEB;
-                    } else if ( mode == PrinterMode.TEXT ) {
-                        m = ConsoleConstants.MODE_TXT;
-                    } else if ( mode == PrinterMode.ZIP_FILE_TEXT ) {
-                        m = ConsoleConstants.MODE_ZIP;
-                    } else {
-                        m = null;
-                    }
-                    if ( m != null ) {
-                        cpa.printConfiguration(printWriter, m);
-                    }
-                }
-
-                /**
-                 * @see org.apache.felix.inventory.ZipAttachmentProvider#addAttachments(java.lang.String, java.util.zip.ZipOutputStream)
-                 */
-                public void addAttachments(final String namePrefix, final ZipOutputStream zos)
-                throws IOException {
-                    final URL[] attachments = cpa.getAttachments();
-                    if ( attachments != null ) {
-                        for(final URL current : attachments) {
-                            final String path = current.getPath();
-                            final String name;
-                            if ( path == null || path.length() == 0 ) {
-                                // sanity code, we should have a path, but if not let's
-                                // just create some random name
-                                name = "file" + Double.doubleToLongBits( Math.random() );
-                            } else {
-                                final int pos = path.lastIndexOf('/');
-                                name = (pos == -1 ? path : path.substring(pos + 1));
-                            }
-                            final ZipEntry entry = new ZipEntry(namePrefix + name);
-                            zos.putNextEntry(entry);
-                            final InputStream is = current.openStream();
-                            try {
-                                byte[] buffer = new byte[4096];
-                                int n = 0;
-                                while (-1 != (n = is.read(buffer))) {
-                                    zos.write(buffer, 0, n);
-                                }
-                            } finally {
-                                if ( is != null ) {
-                                    try { is.close(); } catch (final IOException ignore) {}
-                                }
-                            }
-                            zos.closeEntry();
-                        }
-                    }
-                }
-
-            }, props);
+            final ServiceRegistration reg = this.bundleContext.registerService(InventoryPrinter.class.getName(), new WebConsolePrinter(cpa), props);
             synchronized ( this.registrations ) {
                 this.registrations.put(reference, reg);
             }
@@ -170,7 +118,7 @@ public class WebConsoleAdapter implement
     private final void remove(final ServiceReference reference) {
         final ServiceRegistration reg;
         synchronized ( this.registrations ) {
-            reg = this.registrations.remove(reference);
+            reg = (ServiceRegistration) this.registrations.remove(reference);
         }
         if ( reg != null ) {
             reg.unregister();
@@ -202,4 +150,71 @@ public class WebConsoleAdapter implement
         this.remove(reference);
         this.bundleContext.ungetService(reference);
     }
+
+    private static class WebConsolePrinter implements InventoryPrinter, ZipAttachmentProvider {
+
+        final ConfigurationPrinterAdapter cpa;
+
+        public WebConsolePrinter(final ConfigurationPrinterAdapter cpa) {
+            this.cpa = cpa;
+        }
+
+        /**
+         * @see org.apache.felix.inventory.InventoryPrinter#print(org.apache.felix.inventory.PrinterMode, java.io.PrintWriter)
+         */
+        public void print(final PrinterMode mode, final PrintWriter printWriter) {
+            final String m;
+            if ( mode == PrinterMode.HTML_BODY ) {
+                m = ConsoleConstants.MODE_WEB;
+            } else if ( mode == PrinterMode.TEXT ) {
+                m = ConsoleConstants.MODE_TXT;
+            } else if ( mode == PrinterMode.ZIP_FILE_TEXT ) {
+                m = ConsoleConstants.MODE_ZIP;
+            } else {
+                m = null;
+            }
+            if ( m != null ) {
+                cpa.printConfiguration(printWriter, m);
+            }
+        }
+
+        /**
+         * @see org.apache.felix.inventory.ZipAttachmentProvider#addAttachments(java.lang.String, java.util.zip.ZipOutputStream)
+         */
+        public void addAttachments(final String namePrefix, final ZipOutputStream zos)
+        throws IOException {
+            final URL[] attachments = cpa.getAttachments();
+            if ( attachments != null ) {
+                for(int i=0;i<attachments.length;i++) {
+                    final URL current = attachments[i];
+                    final String path = current.getPath();
+                    final String name;
+                    if ( path == null || path.length() == 0 ) {
+                        // sanity code, we should have a path, but if not let's
+                        // just create some random name
+                        name = "file" + Double.doubleToLongBits( Math.random() );
+                    } else {
+                        final int pos = path.lastIndexOf('/');
+                        name = (pos == -1 ? path : path.substring(pos + 1));
+                    }
+                    final ZipEntry entry = new ZipEntry(namePrefix + name);
+                    zos.putNextEntry(entry);
+                    final InputStream is = current.openStream();
+                    try {
+                        byte[] buffer = new byte[4096];
+                        int n = 0;
+                        while (-1 != (n = is.read(buffer))) {
+                            zos.write(buffer, 0, n);
+                        }
+                    } finally {
+                        if ( is != null ) {
+                            try { is.close(); } catch (final IOException ignore) {}
+                        }
+                    }
+                    zos.closeEntry();
+                }
+            }
+        }
+
+    }
 }



Mime
View raw message