You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2008/05/19 09:36:39 UTC

svn commit: r657742 [2/4] - in /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole: ./ internal/ internal/compendium/ internal/core/ internal/misc/ internal/obr/ internal/servlet/ internal/system/

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java?rev=657742&r1=657741&r2=657742&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java Mon May 19 00:36:38 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.felix.webconsole.internal.compendium;
 
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Dictionary;
@@ -40,10 +41,12 @@
 import org.osgi.service.cm.ManagedServiceFactory;
 import org.osgi.service.metatype.ObjectClassDefinition;
 
+
 /**
  * The <code>ConfigManager</code> TODO
  */
-public class ConfigManager extends ConfigManagerBase implements Render {
+public class ConfigManager extends ConfigManagerBase implements Render
+{
 
     public static final String NAME = "configMgr";
 
@@ -51,128 +54,153 @@
 
     public static final String PID = "pid";
 
-    public String getLabel() {
+
+    public String getLabel()
+    {
         return LABEL;
     }
 
-    public String getName() {
+
+    public String getName()
+    {
         return NAME;
     }
 
-    public void render(HttpServletRequest request, HttpServletResponse response)
-            throws IOException {
+
+    public void render( HttpServletRequest request, HttpServletResponse response ) throws IOException
+    {
 
         // true if MetaType service information is not required
         boolean optionalMetaType = false;
 
         PrintWriter pw = response.getWriter();
 
-        pw.println("<script type='text/javascript' src='res/ui/configmanager.js'></script>");
+        pw.println( "<script type='text/javascript' src='res/ui/configmanager.js'></script>" );
 
-        pw.println("<table class='content' cellpadding='0' cellspacing='0' width='100%'>");
+        pw.println( "<table class='content' cellpadding='0' cellspacing='0' width='100%'>" );
 
-        pw.println("<tr class='content' id='configField'>");
-        pw.println("<td class='content'>Configurations</th>");
-        pw.println("<td class='content'>");
-        this.listConfigurations(pw, optionalMetaType, getLocale(request));
-        pw.println("</td>");
-        pw.println("</tr>");
+        pw.println( "<tr class='content' id='configField'>" );
+        pw.println( "<td class='content'>Configurations</th>" );
+        pw.println( "<td class='content'>" );
+        this.listConfigurations( pw, optionalMetaType, getLocale( request ) );
+        pw.println( "</td>" );
+        pw.println( "</tr>" );
 
-        pw.println("</table>");
+        pw.println( "</table>" );
     }
 
-    private void listConfigurations(PrintWriter pw, boolean optionalMetaType,
-            Locale loc) {
+
+    private void listConfigurations( PrintWriter pw, boolean optionalMetaType, Locale loc )
+    {
 
         ConfigurationAdmin ca = this.getConfigurationAdmin();
-        if (ca == null) {
-            pw.print("Configuration Admin Service not available");
+        if ( ca == null )
+        {
+            pw.print( "Configuration Admin Service not available" );
             return;
         }
 
-        String locale = (loc != null) ? loc.toString() : null;
+        String locale = ( loc != null ) ? loc.toString() : null;
 
-        try {
+        try
+        {
             // get a list of all pids for which MetaData exists
             Map metaDataPids = this.getMetadataPids();
 
             // sorted map of options
-            SortedMap options = new TreeMap(String.CASE_INSENSITIVE_ORDER);
+            SortedMap options = new TreeMap( String.CASE_INSENSITIVE_ORDER );
 
             // find all ManagedServiceFactories to get the factoryPIDs
             ServiceReference[] refs = this.getBundleContext().getServiceReferences(
-                ManagedServiceFactory.class.getName(), null);
-            for (int i = 0; refs != null && i < refs.length; i++) {
-                Object factoryPid = refs[i].getProperty(Constants.SERVICE_PID);
-                if (factoryPid instanceof String) {
-                    String pid = (String) factoryPid;
+                ManagedServiceFactory.class.getName(), null );
+            for ( int i = 0; refs != null && i < refs.length; i++ )
+            {
+                Object factoryPid = refs[i].getProperty( Constants.SERVICE_PID );
+                if ( factoryPid instanceof String )
+                {
+                    String pid = ( String ) factoryPid;
                     String name;
-                    ObjectClassDefinition ocd = this.getObjectClassDefinition(
-                        refs[i].getBundle(), pid, locale);
-                    if (ocd != null) {
+                    ObjectClassDefinition ocd = this.getObjectClassDefinition( refs[i].getBundle(), pid, locale );
+                    if ( ocd != null )
+                    {
                         name = ocd.getName() + " (";
                         name += pid + ")";
-                    } else {
+                    }
+                    else
+                    {
                         name = pid;
                     }
 
-                    if (ocd != null || optionalMetaType) {
-                        options.put("factoryPid=" + pid, name);
+                    if ( ocd != null || optionalMetaType )
+                    {
+                        options.put( "factoryPid=" + pid, name );
                     }
                 }
             }
 
             // get a sorted list of configuration PIDs
-            Configuration[] cfgs = ca.listConfigurations(null);
-            for (int i = 0; cfgs != null && i < cfgs.length; i++) {
+            Configuration[] cfgs = ca.listConfigurations( null );
+            for ( int i = 0; cfgs != null && i < cfgs.length; i++ )
+            {
 
                 // ignore configuration object if an entry already exists in the
                 // map
                 String pid = cfgs[i].getPid();
-                if (options.containsKey("pid=" + pid)
-                    || options.containsKey("factoryPid=" + pid)) {
+                if ( options.containsKey( "pid=" + pid ) || options.containsKey( "factoryPid=" + pid ) )
+                {
                     continue;
                 }
 
                 Dictionary props = cfgs[i].getProperties();
 
                 // insert and entry for the pid
-                ObjectClassDefinition ocd = this.getObjectClassDefinition(
-                    cfgs[i], locale);
+                ObjectClassDefinition ocd = this.getObjectClassDefinition( cfgs[i], locale );
                 String name;
-                if (ocd != null) {
+                if ( ocd != null )
+                {
                     name = ocd.getName() + " (";
                     name += pid + ")";
 
                     // remove from the list of known pids
-                    metaDataPids.remove(pid);
+                    metaDataPids.remove( pid );
 
-                } else {
+                }
+                else
+                {
                     name = pid;
                 }
 
-                if (ocd != null || optionalMetaType) {
-                    options.put("pid=" + pid, name);
+                if ( ocd != null || optionalMetaType )
+                {
+                    options.put( "pid=" + pid, name );
                 }
 
                 // if the configuration is part of a factory, ensure an entry
                 // for the factory
-                if (cfgs[i].getFactoryPid() != null) {
+                if ( cfgs[i].getFactoryPid() != null )
+                {
                     pid = cfgs[i].getFactoryPid();
-                    if (options.containsValue("factoryPid=" + pid)) {
+                    if ( options.containsValue( "factoryPid=" + pid ) )
+                    {
                         continue;
                     }
 
-                    String existing = (String) options.remove("pid=" + pid);
-                    if (existing != null) {
-                        options.put("factoryPid=" + pid, existing);
-                    } else {
-                        Bundle bundle = this.getBundle(cfgs[i].getBundleLocation());
-                        ocd = this.getObjectClassDefinition(bundle, pid, locale);
-                        if (ocd != null) {
-                            options.put("factoryPid=" + pid, ocd.getName());
-                        } else if (optionalMetaType) {
-                            options.put("factoryPid=" + pid, pid);
+                    String existing = ( String ) options.remove( "pid=" + pid );
+                    if ( existing != null )
+                    {
+                        options.put( "factoryPid=" + pid, existing );
+                    }
+                    else
+                    {
+                        Bundle bundle = this.getBundle( cfgs[i].getBundleLocation() );
+                        ocd = this.getObjectClassDefinition( bundle, pid, locale );
+                        if ( ocd != null )
+                        {
+                            options.put( "factoryPid=" + pid, ocd.getName() );
+                        }
+                        else if ( optionalMetaType )
+                        {
+                            options.put( "factoryPid=" + pid, pid );
                         }
                     }
                 }
@@ -180,32 +208,36 @@
 
             // If there are any meta data PIDs for which there is no existing
             // configuration, we add them to the list to create configuration
-            if (!metaDataPids.isEmpty()) {
-                for(Iterator mdpi=metaDataPids.entrySet().iterator(); mdpi.hasNext(); ) {
-                Entry mdp = (Entry) mdpi.next();
-                    ObjectClassDefinition ocd = this.getObjectClassDefinition(
-                        (Bundle) mdp.getValue(), (String) mdp.getKey(), locale);
-                    options.put("pid=" + mdp.getKey(), ocd.getName() + " ("
-                        + mdp.getKey() + ")");
+            if ( !metaDataPids.isEmpty() )
+            {
+                for ( Iterator mdpi = metaDataPids.entrySet().iterator(); mdpi.hasNext(); )
+                {
+                    Entry mdp = ( Entry ) mdpi.next();
+                    ObjectClassDefinition ocd = this.getObjectClassDefinition( ( Bundle ) mdp.getValue(),
+                        ( String ) mdp.getKey(), locale );
+                    options.put( "pid=" + mdp.getKey(), ocd.getName() + " (" + mdp.getKey() + ")" );
                 }
             }
 
-            pw.println("<form method='post' name='configSelection' onSubmit='configure(); return false;'");
-            pw.println("<input type='hidden' name='" + Util.PARAM_ACTION
-                + "' value='" + SetStartLevelAction.NAME + "'>");
-            pw.println("<select class='select' name='pid' onChange='configure();'>");
-            for (Iterator ei = options.entrySet().iterator(); ei.hasNext();) {
-                Entry entry = (Entry) ei.next();
-                pw.print("<option value='" + entry.getKey() + "'>");
-                pw.print(entry.getValue());
-                pw.println("</option>");
+            pw.println( "<form method='post' name='configSelection' onSubmit='configure(); return false;'" );
+            pw.println( "<input type='hidden' name='" + Util.PARAM_ACTION + "' value='" + SetStartLevelAction.NAME
+                + "'>" );
+            pw.println( "<select class='select' name='pid' onChange='configure();'>" );
+            for ( Iterator ei = options.entrySet().iterator(); ei.hasNext(); )
+            {
+                Entry entry = ( Entry ) ei.next();
+                pw.print( "<option value='" + entry.getKey() + "'>" );
+                pw.print( entry.getValue() );
+                pw.println( "</option>" );
             }
-            pw.println("</select>");
-            pw.println("&nbsp;&nbsp;");
-            pw.println("<input class='submit' type='submit' value='Configure' />");
-            pw.println("</form>");
+            pw.println( "</select>" );
+            pw.println( "&nbsp;&nbsp;" );
+            pw.println( "<input class='submit' type='submit' value='Configure' />" );
+            pw.println( "</form>" );
 
-        } catch (Exception e) {
+        }
+        catch ( Exception e )
+        {
             // write a message or ignore
         }
     }

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java?rev=657742&r1=657741&r2=657742&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java Mon May 19 00:36:38 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.felix.webconsole.internal.compendium;
 
+
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -33,53 +34,71 @@
 import org.osgi.service.metatype.ObjectClassDefinition;
 import org.osgi.util.tracker.ServiceTracker;
 
+
 /**
  * The <code>ConfigManagerBase</code> TODO
  * 
  */
-abstract class ConfigManagerBase extends BaseManagementPlugin {
+abstract class ConfigManagerBase extends BaseManagementPlugin
+{
 
     private ServiceTracker configurationAdmin;
 
     private ServiceTracker metaTypeService;
 
-    public void setBundleContext(BundleContext bundleContext) {
-        super.setBundleContext(bundleContext);
-        
-        configurationAdmin = new ServiceTracker(bundleContext, ConfigurationAdmin.class.getName(), null);
+
+    public void setBundleContext( BundleContext bundleContext )
+    {
+        super.setBundleContext( bundleContext );
+
+        configurationAdmin = new ServiceTracker( bundleContext, ConfigurationAdmin.class.getName(), null );
         configurationAdmin.open();
-        metaTypeService = new ServiceTracker(bundleContext, MetaTypeService.class.getName(), null);
+        metaTypeService = new ServiceTracker( bundleContext, MetaTypeService.class.getName(), null );
         metaTypeService.open();
     }
-    
-    public void destroy() {
-        if (configurationAdmin != null) {
+
+
+    public void destroy()
+    {
+        if ( configurationAdmin != null )
+        {
             configurationAdmin.close();
         }
-        if (metaTypeService != null) {
+        if ( metaTypeService != null )
+        {
             metaTypeService.close();
         }
     }
-    
-    protected ConfigurationAdmin getConfigurationAdmin() {
-        return (ConfigurationAdmin) configurationAdmin.getService();
+
+
+    protected ConfigurationAdmin getConfigurationAdmin()
+    {
+        return ( ConfigurationAdmin ) configurationAdmin.getService();
     }
 
-    protected MetaTypeService getMetaTypeService() {
-        return (MetaTypeService) metaTypeService.getService();
+
+    protected MetaTypeService getMetaTypeService()
+    {
+        return ( MetaTypeService ) metaTypeService.getService();
     }
 
-    protected Map getMetadataPids() {
+
+    protected Map getMetadataPids()
+    {
         Map pids = new HashMap();
         MetaTypeService mts = this.getMetaTypeService();
-        if (mts != null) {
+        if ( mts != null )
+        {
             Bundle[] bundles = this.getBundleContext().getBundles();
-            for (int i = 0; i < bundles.length; i++) {
-                MetaTypeInformation mti = mts.getMetaTypeInformation(bundles[i]);
-                if (mti != null) {
+            for ( int i = 0; i < bundles.length; i++ )
+            {
+                MetaTypeInformation mti = mts.getMetaTypeInformation( bundles[i] );
+                if ( mti != null )
+                {
                     String[] pidList = mti.getPids();
-                    for (int j = 0; pidList != null && j < pidList.length; j++) {
-                        pids.put(pidList[j], bundles[i]);
+                    for ( int j = 0; pidList != null && j < pidList.length; j++ )
+                    {
+                        pids.put( pidList[j], bundles[i] );
                     }
                 }
             }
@@ -87,42 +106,47 @@
         return pids;
     }
 
-    protected ObjectClassDefinition getObjectClassDefinition(
-            Configuration config, String locale) {
+
+    protected ObjectClassDefinition getObjectClassDefinition( Configuration config, String locale )
+    {
 
         // if the configuration is not bound, search in the bundles
-        if (config.getBundleLocation() == null) {
-            ObjectClassDefinition ocd = this.getObjectClassDefinition(
-                config.getPid(), locale);
-            if (ocd != null) {
+        if ( config.getBundleLocation() == null )
+        {
+            ObjectClassDefinition ocd = this.getObjectClassDefinition( config.getPid(), locale );
+            if ( ocd != null )
+            {
                 return ocd;
             }
 
             // if none, check whether there might be one for the factory PID
-            if (config.getFactoryPid() != null) {
-                return this.getObjectClassDefinition(config.getFactoryPid(),
-                    locale);
+            if ( config.getFactoryPid() != null )
+            {
+                return this.getObjectClassDefinition( config.getFactoryPid(), locale );
             }
         }
 
         MetaTypeService mts = this.getMetaTypeService();
-        if (mts != null) {
-            Bundle bundle = this.getBundle(config.getBundleLocation());
-            if (bundle != null) {
-                MetaTypeInformation mti = mts.getMetaTypeInformation(bundle);
-                if (mti != null) {
+        if ( mts != null )
+        {
+            Bundle bundle = this.getBundle( config.getBundleLocation() );
+            if ( bundle != null )
+            {
+                MetaTypeInformation mti = mts.getMetaTypeInformation( bundle );
+                if ( mti != null )
+                {
                     // try OCD by PID first
-                    ObjectClassDefinition ocd = mti.getObjectClassDefinition(
-                        config.getPid(), locale);
-                    if (ocd != null) {
+                    ObjectClassDefinition ocd = mti.getObjectClassDefinition( config.getPid(), locale );
+                    if ( ocd != null )
+                    {
                         return ocd;
                     }
 
                     // if none, check whether there might be one for the factory
                     // PID
-                    if (config.getFactoryPid() != null) {
-                        return mti.getObjectClassDefinition(
-                            config.getFactoryPid(), locale);
+                    if ( config.getFactoryPid() != null )
+                    {
+                        return mti.getObjectClassDefinition( config.getFactoryPid(), locale );
                     }
                 }
             }
@@ -132,14 +156,18 @@
         return null;
     }
 
-    protected ObjectClassDefinition getObjectClassDefinition(Bundle bundle,
-            String pid, String locale) {
-        if (bundle != null) {
+
+    protected ObjectClassDefinition getObjectClassDefinition( Bundle bundle, String pid, String locale )
+    {
+        if ( bundle != null )
+        {
             MetaTypeService mts = this.getMetaTypeService();
-            if (mts != null) {
-                MetaTypeInformation mti = mts.getMetaTypeInformation(bundle);
-                if (mti != null) {
-                    return mti.getObjectClassDefinition(pid, locale);
+            if ( mts != null )
+            {
+                MetaTypeInformation mti = mts.getMetaTypeInformation( bundle );
+                if ( mti != null )
+                {
+                    return mti.getObjectClassDefinition( pid, locale );
                 }
             }
         }
@@ -148,33 +176,41 @@
         return null;
     }
 
-    protected ObjectClassDefinition getObjectClassDefinition(String pid,
-            String locale) {
+
+    protected ObjectClassDefinition getObjectClassDefinition( String pid, String locale )
+    {
         Bundle[] bundles = this.getBundleContext().getBundles();
-        for (int i = 0; i < bundles.length; i++) {
-            try {
-                ObjectClassDefinition ocd = this.getObjectClassDefinition(
-                    bundles[i], pid, locale);
-                if (ocd != null) {
+        for ( int i = 0; i < bundles.length; i++ )
+        {
+            try
+            {
+                ObjectClassDefinition ocd = this.getObjectClassDefinition( bundles[i], pid, locale );
+                if ( ocd != null )
+                {
                     return ocd;
                 }
-            } catch (IllegalArgumentException iae) {
+            }
+            catch ( IllegalArgumentException iae )
+            {
                 // don't care
             }
         }
         return null;
     }
 
-    protected Map getAttributeDefinitionMap(
-            Configuration config, String locale) {
-        ObjectClassDefinition ocd = this.getObjectClassDefinition(config,
-            locale);
-        if (ocd != null) {
-            AttributeDefinition[] ad = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
-            if (ad != null) {
+
+    protected Map getAttributeDefinitionMap( Configuration config, String locale )
+    {
+        ObjectClassDefinition ocd = this.getObjectClassDefinition( config, locale );
+        if ( ocd != null )
+        {
+            AttributeDefinition[] ad = ocd.getAttributeDefinitions( ObjectClassDefinition.ALL );
+            if ( ad != null )
+            {
                 Map adMap = new HashMap();
-                for (int i = 0; i < ad.length; i++) {
-                    adMap.put(ad[i].getID(), ad[i]);
+                for ( int i = 0; i < ad.length; i++ )
+                {
+                    adMap.put( ad[i].getID(), ad[i] );
                 }
                 return adMap;
             }
@@ -184,14 +220,19 @@
         return null;
     }
 
-    protected Bundle getBundle(String bundleLocation) {
-        if (bundleLocation == null) {
+
+    protected Bundle getBundle( String bundleLocation )
+    {
+        if ( bundleLocation == null )
+        {
             return null;
         }
 
         Bundle[] bundles = this.getBundleContext().getBundles();
-        for (int i = 0; i < bundles.length; i++) {
-            if (bundleLocation.equals(bundles[i].getLocation())) {
+        for ( int i = 0; i < bundles.length; i++ )
+        {
+            if ( bundleLocation.equals( bundles[i].getLocation() ) )
+            {
                 return bundles[i];
             }
         }
@@ -199,10 +240,15 @@
         return null;
     }
 
-    protected Locale getLocale(HttpServletRequest request) {
-        try {
+
+    protected Locale getLocale( HttpServletRequest request )
+    {
+        try
+        {
             return request.getLocale();
-        } catch (Throwable t) {
+        }
+        catch ( Throwable t )
+        {
             // expected in standard OSGi Servlet 2.1 environments
             // fallback to using the default locale
             return Locale.getDefault();

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/AjaxBundleDetailsAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/AjaxBundleDetailsAction.java?rev=657742&r1=657741&r2=657742&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/AjaxBundleDetailsAction.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/AjaxBundleDetailsAction.java Mon May 19 00:36:38 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.felix.webconsole.internal.core;
 
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -50,7 +51,9 @@
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.service.startlevel.StartLevel;
 
-public class AjaxBundleDetailsAction extends BundleAction {
+
+public class AjaxBundleDetailsAction extends BundleAction
+{
 
     public static final String NAME = "ajaxBundleDetails";
 
@@ -65,136 +68,166 @@
     // see #activate and #isBootDelegated
     private boolean[] bootPkgWildcards;
 
-    public void setBundleContext(BundleContext bundleContext) {
-        super.setBundleContext(bundleContext);
+
+    public void setBundleContext( BundleContext bundleContext )
+    {
+        super.setBundleContext( bundleContext );
 
         // bootdelegation property parsing from Apache Felix R4SearchPolicyCore
-        String bootDelegation = bundleContext.getProperty(Constants.FRAMEWORK_BOOTDELEGATION);
-        bootDelegation = (bootDelegation == null) ? "java.*" : bootDelegation
-            + ",java.*";
-        StringTokenizer st = new StringTokenizer(bootDelegation, " ,");
+        String bootDelegation = bundleContext.getProperty( Constants.FRAMEWORK_BOOTDELEGATION );
+        bootDelegation = ( bootDelegation == null ) ? "java.*" : bootDelegation + ",java.*";
+        StringTokenizer st = new StringTokenizer( bootDelegation, " ," );
         bootPkgs = new String[st.countTokens()];
         bootPkgWildcards = new boolean[bootPkgs.length];
-        for (int i = 0; i < bootPkgs.length; i++) {
+        for ( int i = 0; i < bootPkgs.length; i++ )
+        {
             bootDelegation = st.nextToken();
-            if (bootDelegation.endsWith("*")) {
+            if ( bootDelegation.endsWith( "*" ) )
+            {
                 bootPkgWildcards[i] = true;
-                bootDelegation = bootDelegation.substring(0,
-                    bootDelegation.length() - 1);
+                bootDelegation = bootDelegation.substring( 0, bootDelegation.length() - 1 );
             }
             bootPkgs[i] = bootDelegation;
         }
     }
 
-    public String getName() {
+
+    public String getName()
+    {
         return NAME;
     }
 
-    public String getLabel() {
+
+    public String getLabel()
+    {
         return NAME;
     }
 
-    public boolean performAction(HttpServletRequest request,
-            HttpServletResponse response) throws IOException {
+
+    public boolean performAction( HttpServletRequest request, HttpServletResponse response ) throws IOException
+    {
         JSONObject result = null;
-        try {
-            long bundleId = getBundleId(request);
-            Bundle bundle = getBundleContext().getBundle(bundleId);
-            if (bundle != null) {
+        try
+        {
+            long bundleId = getBundleId( request );
+            Bundle bundle = getBundleContext().getBundle( bundleId );
+            if ( bundle != null )
+            {
                 Dictionary headers = bundle.getHeaders();
 
                 JSONArray props = new JSONArray();
-                keyVal(props, "Symbolic Name", bundle.getSymbolicName());
-                keyVal(props, "Version", headers.get(Constants.BUNDLE_VERSION));
-                keyVal(props, "Location", bundle.getLocation());
-                keyVal(props, "Last Modification", new Date(
-                    bundle.getLastModified()));
-
-                keyVal(props, "Vendor", headers.get(Constants.BUNDLE_VENDOR));
-                keyVal(props, "Copyright",
-                    headers.get(Constants.BUNDLE_COPYRIGHT));
-                keyVal(props, "Description",
-                    headers.get(Constants.BUNDLE_DESCRIPTION));
-
-                keyVal(props, "Start Level", getStartLevel(bundle));
-
-                if (bundle.getState() == Bundle.INSTALLED) {
-                    listImportExportsUnresolved(props, bundle);
-                } else {
-                    listImportExport(props, bundle);
+                keyVal( props, "Symbolic Name", bundle.getSymbolicName() );
+                keyVal( props, "Version", headers.get( Constants.BUNDLE_VERSION ) );
+                keyVal( props, "Location", bundle.getLocation() );
+                keyVal( props, "Last Modification", new Date( bundle.getLastModified() ) );
+
+                keyVal( props, "Vendor", headers.get( Constants.BUNDLE_VENDOR ) );
+                keyVal( props, "Copyright", headers.get( Constants.BUNDLE_COPYRIGHT ) );
+                keyVal( props, "Description", headers.get( Constants.BUNDLE_DESCRIPTION ) );
+
+                keyVal( props, "Start Level", getStartLevel( bundle ) );
+
+                if ( bundle.getState() == Bundle.INSTALLED )
+                {
+                    listImportExportsUnresolved( props, bundle );
+                }
+                else
+                {
+                    listImportExport( props, bundle );
                 }
 
-                listServices(props, bundle);
+                listServices( props, bundle );
 
                 result = new JSONObject();
-                result.put(BundleListRender.BUNDLE_ID, bundleId);
-                result.put("props", props);
+                result.put( BundleListRender.BUNDLE_ID, bundleId );
+                result.put( "props", props );
             }
-        } catch (Exception exception) {
+        }
+        catch ( Exception exception )
+        {
             // create an empty result on problems
             result = new JSONObject();
         }
 
         // send the result
-        response.setContentType("text/javascript");
-        response.getWriter().print(result.toString());
+        response.setContentType( "text/javascript" );
+        response.getWriter().print( result.toString() );
 
         return false;
     }
 
-    private Integer getStartLevel(Bundle bundle) {
+
+    private Integer getStartLevel( Bundle bundle )
+    {
         StartLevel sl = getStartLevel();
-        return (sl != null) ? new Integer(sl.getBundleStartLevel(bundle)) : null;
+        return ( sl != null ) ? new Integer( sl.getBundleStartLevel( bundle ) ) : null;
     }
 
-    private void listImportExport(JSONArray props, Bundle bundle) {
+
+    private void listImportExport( JSONArray props, Bundle bundle )
+    {
         PackageAdmin packageAdmin = getPackageAdmin();
-        if (packageAdmin == null) {
+        if ( packageAdmin == null )
+        {
             return;
         }
 
         Map usingBundles = new TreeMap();
 
-        ExportedPackage[] exports = packageAdmin.getExportedPackages(bundle);
-        if (exports != null && exports.length > 0) {
+        ExportedPackage[] exports = packageAdmin.getExportedPackages( bundle );
+        if ( exports != null && exports.length > 0 )
+        {
             // do alphabetical sort
-            Arrays.sort(exports, new Comparator() {
-                public int compare(ExportedPackage p1, ExportedPackage p2) {
-                    return p1.getName().compareTo(p2.getName());
+            Arrays.sort( exports, new Comparator()
+            {
+                public int compare( ExportedPackage p1, ExportedPackage p2 )
+                {
+                    return p1.getName().compareTo( p2.getName() );
                 }
 
-                public int compare(Object o1, Object o2) {
-                    return compare((ExportedPackage) o1, (ExportedPackage) o2);
+
+                public int compare( Object o1, Object o2 )
+                {
+                    return compare( ( ExportedPackage ) o1, ( ExportedPackage ) o2 );
                 }
-            });
+            } );
 
             StringBuffer val = new StringBuffer();
-            for (int j=0; j < exports.length; j++) {
+            for ( int j = 0; j < exports.length; j++ )
+            {
                 ExportedPackage export = exports[j];
-                printExport(val, export.getName(), export.getVersion());
+                printExport( val, export.getName(), export.getVersion() );
                 Bundle[] ubList = export.getImportingBundles();
-                if (ubList != null) {
-                    for (int i=0; i < ubList.length; i++) {
+                if ( ubList != null )
+                {
+                    for ( int i = 0; i < ubList.length; i++ )
+                    {
                         Bundle ub = ubList[i];
-                        usingBundles.put(ub.getSymbolicName(), ub);
+                        usingBundles.put( ub.getSymbolicName(), ub );
                     }
                 }
             }
-            keyVal(props, "Exported Packages", val.toString());
-        } else {
-            keyVal(props, "Exported Packages", "None");
+            keyVal( props, "Exported Packages", val.toString() );
+        }
+        else
+        {
+            keyVal( props, "Exported Packages", "None" );
         }
 
-        exports = packageAdmin.getExportedPackages((Bundle) null);
-        if (exports != null && exports.length > 0) {
+        exports = packageAdmin.getExportedPackages( ( Bundle ) null );
+        if ( exports != null && exports.length > 0 )
+        {
             // collect import packages first
             final List imports = new ArrayList();
-            for (int i = 0; i < exports.length; i++) {
+            for ( int i = 0; i < exports.length; i++ )
+            {
                 final ExportedPackage ep = exports[i];
                 final Bundle[] importers = ep.getImportingBundles();
-                for (int j = 0; importers != null && j < importers.length; j++) {
-                    if (importers[j].getBundleId() == bundle.getBundleId()) {
-                        imports.add(ep);
+                for ( int j = 0; importers != null && j < importers.length; j++ )
+                {
+                    if ( importers[j].getBundleId() == bundle.getBundleId() )
+                    {
+                        imports.add( ep );
 
                         break;
                     }
@@ -202,94 +235,122 @@
             }
             // now sort
             StringBuffer val = new StringBuffer();
-            if (imports.size() > 0) {
-                final ExportedPackage[] packages = (ExportedPackage[]) imports.toArray(new ExportedPackage[imports.size()]);
-                Arrays.sort(packages, new Comparator() {
-                    public int compare(ExportedPackage p1, ExportedPackage p2) {
-                        return p1.getName().compareTo(p2.getName());
+            if ( imports.size() > 0 )
+            {
+                final ExportedPackage[] packages = ( ExportedPackage[] ) imports.toArray( new ExportedPackage[imports
+                    .size()] );
+                Arrays.sort( packages, new Comparator()
+                {
+                    public int compare( ExportedPackage p1, ExportedPackage p2 )
+                    {
+                        return p1.getName().compareTo( p2.getName() );
                     }
 
-                    public int compare(Object o1, Object o2) {
-                        return compare((ExportedPackage) o1,
-                            (ExportedPackage) o2);
+
+                    public int compare( Object o1, Object o2 )
+                    {
+                        return compare( ( ExportedPackage ) o1, ( ExportedPackage ) o2 );
                     }
-                });
+                } );
                 // and finally print out
-                for (int i=0; i < packages.length; i++) {
+                for ( int i = 0; i < packages.length; i++ )
+                {
                     ExportedPackage ep = packages[i];
-                    printImport(val, ep.getName(), ep.getVersion(), ep);
+                    printImport( val, ep.getName(), ep.getVersion(), ep );
                 }
-            } else {
+            }
+            else
+            {
                 // add description if there are no imports
-                val.append("None");
+                val.append( "None" );
             }
 
-            keyVal(props, "Imported Packages", val.toString());
+            keyVal( props, "Imported Packages", val.toString() );
         }
 
-        if (!usingBundles.isEmpty()) {
+        if ( !usingBundles.isEmpty() )
+        {
             StringBuffer val = new StringBuffer();
-            for (Iterator ui = usingBundles.values().iterator(); ui.hasNext();) {
-                Bundle usingBundle = (Bundle) ui.next();
-                val.append(getBundleDescriptor(usingBundle));
-                val.append("<br />");
+            for ( Iterator ui = usingBundles.values().iterator(); ui.hasNext(); )
+            {
+                Bundle usingBundle = ( Bundle ) ui.next();
+                val.append( getBundleDescriptor( usingBundle ) );
+                val.append( "<br />" );
             }
-            keyVal(props, "Importing Bundles", val.toString());
+            keyVal( props, "Importing Bundles", val.toString() );
         }
     }
 
-    private void listImportExportsUnresolved(JSONArray props, Bundle bundle) {
+
+    private void listImportExportsUnresolved( JSONArray props, Bundle bundle )
+    {
         Dictionary dict = bundle.getHeaders();
 
-        String target = (String) dict.get(Constants.EXPORT_PACKAGE);
-        if (target != null) {
-            R4Package[] pkgs = R4Package.parseImportOrExportHeader(target);
-            if (pkgs != null && pkgs.length > 0) {
+        String target = ( String ) dict.get( Constants.EXPORT_PACKAGE );
+        if ( target != null )
+        {
+            R4Package[] pkgs = R4Package.parseImportOrExportHeader( target );
+            if ( pkgs != null && pkgs.length > 0 )
+            {
                 // do alphabetical sort
-                Arrays.sort(pkgs, new Comparator() {
-                    public int compare(R4Package p1, R4Package p2) {
-                        return p1.getName().compareTo(p2.getName());
+                Arrays.sort( pkgs, new Comparator()
+                {
+                    public int compare( R4Package p1, R4Package p2 )
+                    {
+                        return p1.getName().compareTo( p2.getName() );
                     }
 
-                    public int compare(Object o1, Object o2) {
-                        return compare((R4Package) o1, (R4Package) o2);
+
+                    public int compare( Object o1, Object o2 )
+                    {
+                        return compare( ( R4Package ) o1, ( R4Package ) o2 );
                     }
-                });
+                } );
 
                 StringBuffer val = new StringBuffer();
-                for (int i=0; i < pkgs.length; i++) {
-                    R4Export export = new R4Export(pkgs[i]);
-                    printExport(val, export.getName(), export.getVersion());
+                for ( int i = 0; i < pkgs.length; i++ )
+                {
+                    R4Export export = new R4Export( pkgs[i] );
+                    printExport( val, export.getName(), export.getVersion() );
                 }
-                keyVal(props, "Exported Packages", val.toString());
-            } else {
-                keyVal(props, "Exported Packages", "None");
+                keyVal( props, "Exported Packages", val.toString() );
+            }
+            else
+            {
+                keyVal( props, "Exported Packages", "None" );
             }
         }
 
-        target = (String) dict.get(Constants.IMPORT_PACKAGE);
-        if (target != null) {
-            R4Package[] pkgs = R4Package.parseImportOrExportHeader(target);
-            if (pkgs != null && pkgs.length > 0) {
+        target = ( String ) dict.get( Constants.IMPORT_PACKAGE );
+        if ( target != null )
+        {
+            R4Package[] pkgs = R4Package.parseImportOrExportHeader( target );
+            if ( pkgs != null && pkgs.length > 0 )
+            {
                 Map imports = new TreeMap();
-                for (int i=0; i < pkgs.length; i++) {
+                for ( int i = 0; i < pkgs.length; i++ )
+                {
                     R4Package pkg = pkgs[i];
-                    imports.put(pkg.getName(), new R4Import(pkg));
+                    imports.put( pkg.getName(), new R4Import( pkg ) );
                 }
 
                 // collect import packages first
                 final Map candidates = new HashMap();
                 PackageAdmin packageAdmin = getPackageAdmin();
-                if (packageAdmin != null) {
-                    ExportedPackage[] exports = packageAdmin.getExportedPackages((Bundle) null);
-                    if (exports != null && exports.length > 0) {
+                if ( packageAdmin != null )
+                {
+                    ExportedPackage[] exports = packageAdmin.getExportedPackages( ( Bundle ) null );
+                    if ( exports != null && exports.length > 0 )
+                    {
 
-                        for (int i = 0; i < exports.length; i++) {
+                        for ( int i = 0; i < exports.length; i++ )
+                        {
                             final ExportedPackage ep = exports[i];
 
-                            R4Import imp = (R4Import) imports.get(ep.getName());
-                            if (imp != null && imp.isSatisfied(toR4Export(ep))) {
-                                candidates.put(ep.getName(), ep);
+                            R4Import imp = ( R4Import ) imports.get( ep.getName() );
+                            if ( imp != null && imp.isSatisfied( toR4Export( ep ) ) )
+                            {
+                                candidates.put( ep.getName(), ep );
                             }
                         }
                     }
@@ -297,150 +358,180 @@
 
                 // now sort
                 StringBuffer val = new StringBuffer();
-                if (imports.size() > 0) {
-                    for (Iterator ii = imports.values().iterator(); ii.hasNext();) {
-                        R4Import r4Import = (R4Import) ii.next();
-                        ExportedPackage ep = (ExportedPackage) candidates.get(r4Import.getName());
+                if ( imports.size() > 0 )
+                {
+                    for ( Iterator ii = imports.values().iterator(); ii.hasNext(); )
+                    {
+                        R4Import r4Import = ( R4Import ) ii.next();
+                        ExportedPackage ep = ( ExportedPackage ) candidates.get( r4Import.getName() );
 
                         // if there is no matching export, check whether this
                         // bundle has the package, ignore the entry in this case
-                        if (ep == null) {
-                            String path = r4Import.getName().replace('.', '/');
-                            if (bundle.getResource(path) != null) {
+                        if ( ep == null )
+                        {
+                            String path = r4Import.getName().replace( '.', '/' );
+                            if ( bundle.getResource( path ) != null )
+                            {
                                 continue;
                             }
                         }
 
-                        printImport(val, r4Import.getName(),
-                            r4Import.getVersion(), ep);
+                        printImport( val, r4Import.getName(), r4Import.getVersion(), ep );
                     }
-                } else {
+                }
+                else
+                {
                     // add description if there are no imports
-                    val.append("None");
+                    val.append( "None" );
                 }
 
-                keyVal(props, "Imported Packages", val.toString());
+                keyVal( props, "Imported Packages", val.toString() );
             }
         }
     }
 
-    private void listServices(JSONArray props, Bundle bundle) {
+
+    private void listServices( JSONArray props, Bundle bundle )
+    {
         ServiceReference[] refs = bundle.getRegisteredServices();
-        if (refs == null || refs.length == 0) {
+        if ( refs == null || refs.length == 0 )
+        {
             return;
         }
 
-        for (int i = 0; i < refs.length; i++) {
-            String key = "Service ID "
-                + refs[i].getProperty(Constants.SERVICE_ID);
+        for ( int i = 0; i < refs.length; i++ )
+        {
+            String key = "Service ID " + refs[i].getProperty( Constants.SERVICE_ID );
 
             StringBuffer val = new StringBuffer();
 
-            appendProperty(val, refs[i], Constants.OBJECTCLASS, "Types");
-            appendProperty(val, refs[i], Constants.SERVICE_PID, "PID");
-            appendProperty(val, refs[i], ConfigurationAdmin.SERVICE_FACTORYPID,
-                "Factory PID");
-            appendProperty(val, refs[i], ComponentConstants.COMPONENT_NAME,
-                "Component Name");
-            appendProperty(val, refs[i], ComponentConstants.COMPONENT_ID,
-                "Component ID");
-            appendProperty(val, refs[i], ComponentConstants.COMPONENT_FACTORY,
-                "Component Factory");
-            appendProperty(val, refs[i], Constants.SERVICE_DESCRIPTION,
-                "Description");
-            appendProperty(val, refs[i], Constants.SERVICE_VENDOR, "Vendor");
-
-            keyVal(props, key, val.toString());
+            appendProperty( val, refs[i], Constants.OBJECTCLASS, "Types" );
+            appendProperty( val, refs[i], Constants.SERVICE_PID, "PID" );
+            appendProperty( val, refs[i], ConfigurationAdmin.SERVICE_FACTORYPID, "Factory PID" );
+            appendProperty( val, refs[i], ComponentConstants.COMPONENT_NAME, "Component Name" );
+            appendProperty( val, refs[i], ComponentConstants.COMPONENT_ID, "Component ID" );
+            appendProperty( val, refs[i], ComponentConstants.COMPONENT_FACTORY, "Component Factory" );
+            appendProperty( val, refs[i], Constants.SERVICE_DESCRIPTION, "Description" );
+            appendProperty( val, refs[i], Constants.SERVICE_VENDOR, "Vendor" );
+
+            keyVal( props, key, val.toString() );
         }
     }
 
-    private void appendProperty(StringBuffer dest, ServiceReference ref,
-            String name, String label) {
-        Object value = ref.getProperty(name);
-        if (value instanceof Object[]) {
-            Object[] values = (Object[]) value;
-            dest.append(label).append(": ");
-            for (int j = 0; j < values.length; j++) {
-                if (j > 0) dest.append(", ");
-                dest.append(values[j]);
-            }
-            dest.append("<br />"); // assume HTML use of result
-        } else if (value != null) {
-            dest.append(label).append(": ").append(value).append("<br />");
+
+    private void appendProperty( StringBuffer dest, ServiceReference ref, String name, String label )
+    {
+        Object value = ref.getProperty( name );
+        if ( value instanceof Object[] )
+        {
+            Object[] values = ( Object[] ) value;
+            dest.append( label ).append( ": " );
+            for ( int j = 0; j < values.length; j++ )
+            {
+                if ( j > 0 )
+                    dest.append( ", " );
+                dest.append( values[j] );
+            }
+            dest.append( "<br />" ); // assume HTML use of result
+        }
+        else if ( value != null )
+        {
+            dest.append( label ).append( ": " ).append( value ).append( "<br />" );
         }
     }
 
-    private void keyVal(JSONArray props, String key, Object value) {
-        if (key != null && value != null) {
-            try {
+
+    private void keyVal( JSONArray props, String key, Object value )
+    {
+        if ( key != null && value != null )
+        {
+            try
+            {
                 JSONObject obj = new JSONObject();
-                obj.put("key", key);
-                obj.put("value", value);
-                props.put(obj);
-            } catch (JSONException je) {
+                obj.put( "key", key );
+                obj.put( "value", value );
+                props.put( obj );
+            }
+            catch ( JSONException je )
+            {
                 // don't care
             }
         }
     }
 
-    private void printExport(StringBuffer val, String name, Version version) {
-        boolean bootDel = isBootDelegated(name);
-        if (bootDel) {
-            val.append("<span style=\"color: red\">!! ");
+
+    private void printExport( StringBuffer val, String name, Version version )
+    {
+        boolean bootDel = isBootDelegated( name );
+        if ( bootDel )
+        {
+            val.append( "<span style=\"color: red\">!! " );
         }
 
-        val.append(name);
-        val.append(",version=");
-        val.append(version);
+        val.append( name );
+        val.append( ",version=" );
+        val.append( version );
 
-        if (bootDel) {
-            val.append(" -- Overwritten by Boot Delegation</span>");
+        if ( bootDel )
+        {
+            val.append( " -- Overwritten by Boot Delegation</span>" );
         }
 
-        val.append("<br />");
+        val.append( "<br />" );
     }
 
-    private void printImport(StringBuffer val, String name, Version version,
-            ExportedPackage export) {
-        boolean bootDel = isBootDelegated(name);
-        if (bootDel || export == null) {
-            val.append("<span style=\"color: red\">!! ");
+
+    private void printImport( StringBuffer val, String name, Version version, ExportedPackage export )
+    {
+        boolean bootDel = isBootDelegated( name );
+        if ( bootDel || export == null )
+        {
+            val.append( "<span style=\"color: red\">!! " );
         }
 
-        val.append(name);
-        val.append(",version=").append(version);
-        val.append(" from ");
+        val.append( name );
+        val.append( ",version=" ).append( version );
+        val.append( " from " );
 
-        if (export != null) {
-            val.append(getBundleDescriptor(export.getExportingBundle()));
+        if ( export != null )
+        {
+            val.append( getBundleDescriptor( export.getExportingBundle() ) );
 
-            if (bootDel) {
-                val.append(" -- Overwritten by Boot Delegation</span>");
+            if ( bootDel )
+            {
+                val.append( " -- Overwritten by Boot Delegation</span>" );
             }
-        } else {
-            val.append(" -- Cannot be resolved");
-            if (bootDel) {
-                val.append(" and overwritten by Boot Delegation");
+        }
+        else
+        {
+            val.append( " -- Cannot be resolved" );
+            if ( bootDel )
+            {
+                val.append( " and overwritten by Boot Delegation" );
             }
-            val.append("</span>");
+            val.append( "</span>" );
         }
 
-        val.append("<br />");
+        val.append( "<br />" );
     }
 
+
     // returns true if the package is listed in the bootdelegation property
-    private boolean isBootDelegated(String pkgName) {
+    private boolean isBootDelegated( String pkgName )
+    {
 
         // bootdelegation analysis from Apache Felix R4SearchPolicyCore
 
         // Only consider delegation if we have a package name, since
         // we don't want to promote the default package. The spec does
         // not take a stand on this issue.
-        if (pkgName.length() > 0) {
+        if ( pkgName.length() > 0 )
+        {
 
             // Delegate any packages listed in the boot delegation
             // property to the parent class loader.
-            for (int i = 0; i < bootPkgs.length; i++) {
+            for ( int i = 0; i < bootPkgs.length; i++ )
+            {
 
                 // A wildcarded boot delegation package will be in the form of
                 // "foo.", so if the package is wildcarded do a startsWith() or
@@ -449,9 +540,10 @@
                 // If the package is not wildcarded, then simply do an equals()
                 // test to see if the request should be delegated to the parent
                 // class loader.
-                if ((bootPkgWildcards[i] && (pkgName.startsWith(bootPkgs[i]) || bootPkgs[i].regionMatches(
-                    0, pkgName, 0, pkgName.length())))
-                    || (!bootPkgWildcards[i] && bootPkgs[i].equals(pkgName))) {
+                if ( ( bootPkgWildcards[i] && ( pkgName.startsWith( bootPkgs[i] ) || bootPkgs[i].regionMatches( 0,
+                    pkgName, 0, pkgName.length() ) ) )
+                    || ( !bootPkgWildcards[i] && bootPkgs[i].equals( pkgName ) ) )
+                {
                     return true;
                 }
             }
@@ -460,29 +552,37 @@
         return false;
     }
 
-    private R4Export toR4Export(ExportedPackage export) {
-        R4Attribute version = new R4Attribute(Constants.VERSION_ATTRIBUTE,
-            export.getVersion().toString(), false);
-        return new R4Export(export.getName(), null,
-            new R4Attribute[] { version });
+
+    private R4Export toR4Export( ExportedPackage export )
+    {
+        R4Attribute version = new R4Attribute( Constants.VERSION_ATTRIBUTE, export.getVersion().toString(), false );
+        return new R4Export( export.getName(), null, new R4Attribute[]
+            { version } );
     }
 
-    private String getBundleDescriptor(Bundle bundle) {
+
+    private String getBundleDescriptor( Bundle bundle )
+    {
         StringBuffer val = new StringBuffer();
-        if (bundle.getSymbolicName() != null) {
+        if ( bundle.getSymbolicName() != null )
+        {
             // list the bundle name if not null
-            val.append(bundle.getSymbolicName());
-            val.append(" (").append(bundle.getBundleId());
-            val.append(")");
-        } else if (bundle.getLocation() != null) {
+            val.append( bundle.getSymbolicName() );
+            val.append( " (" ).append( bundle.getBundleId() );
+            val.append( ")" );
+        }
+        else if ( bundle.getLocation() != null )
+        {
             // otherwise try the location
-            val.append(bundle.getLocation());
-            val.append(" (").append(bundle.getBundleId());
-            val.append(")");
-        } else {
+            val.append( bundle.getLocation() );
+            val.append( " (" ).append( bundle.getBundleId() );
+            val.append( ")" );
+        }
+        else
+        {
             // fallback to just the bundle id
             // only append the bundle
-            val.append(bundle.getBundleId());
+            val.append( bundle.getBundleId() );
         }
         return val.toString();
     }

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleAction.java?rev=657742&r1=657741&r2=657742&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleAction.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleAction.java Mon May 19 00:36:38 2008
@@ -16,19 +16,27 @@
  */
 package org.apache.felix.webconsole.internal.core;
 
+
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.felix.webconsole.Action;
 import org.apache.felix.webconsole.internal.BaseManagementPlugin;
 
-abstract class BundleAction extends BaseManagementPlugin implements Action {
 
-    protected long getBundleId(HttpServletRequest request) {
-        String bundleIdPar = request.getParameter(BundleListRender.BUNDLE_ID);
-        if (bundleIdPar != null) {
-            try {
-                return Long.parseLong(bundleIdPar);
-            } catch (NumberFormatException nfe) {
+abstract class BundleAction extends BaseManagementPlugin implements Action
+{
+
+    protected long getBundleId( HttpServletRequest request )
+    {
+        String bundleIdPar = request.getParameter( BundleListRender.BUNDLE_ID );
+        if ( bundleIdPar != null )
+        {
+            try
+            {
+                return Long.parseLong( bundleIdPar );
+            }
+            catch ( NumberFormatException nfe )
+            {
                 // TODO: log
             }
         }

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleListRender.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleListRender.java?rev=657742&r1=657741&r2=657742&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleListRender.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleListRender.java Mon May 19 00:36:38 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.felix.webconsole.internal.core;
 
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Arrays;
@@ -33,10 +34,12 @@
 import org.osgi.framework.Version;
 import org.osgi.util.tracker.ServiceTracker;
 
+
 /**
  * The <code>BundleListRender</code> TODO
  */
-public class BundleListRender extends BaseManagementPlugin implements Render {
+public class BundleListRender extends BaseManagementPlugin implements Render
+{
 
     public static final String NAME = "list";
 
@@ -49,14 +52,16 @@
     // track the optional installer service manually
     private ServiceTracker installerService;
 
-    public void setBundleContext(BundleContext bundleContext) {
-        super.setBundleContext(bundleContext);
 
-        installerService = new ServiceTracker(bundleContext,
-            INSTALLER_SERVICE_NAME, null);
+    public void setBundleContext( BundleContext bundleContext )
+    {
+        super.setBundleContext( bundleContext );
+
+        installerService = new ServiceTracker( bundleContext, INSTALLER_SERVICE_NAME, null );
         installerService.open();
     }
 
+
     // protected void deactivate(ComponentContext context) {
     // if (installerService != null) {
     // installerService.close();
@@ -64,210 +69,220 @@
     // }
     // }
 
-    public String getName() {
+    public String getName()
+    {
         return NAME;
     }
 
-    public String getLabel() {
+
+    public String getLabel()
+    {
         return LABEL;
     }
 
-    public void render(HttpServletRequest request, HttpServletResponse response)
-            throws IOException {
+
+    public void render( HttpServletRequest request, HttpServletResponse response ) throws IOException
+    {
 
         PrintWriter pw = response.getWriter();
 
-        this.header(pw);
+        this.header( pw );
 
-        this.installForm(pw);
-        pw.println("<tr class='content'>");
-        pw.println("<td colspan='7' class='content'>&nbsp;</th>");
-        pw.println("</tr>");
+        this.installForm( pw );
+        pw.println( "<tr class='content'>" );
+        pw.println( "<td colspan='7' class='content'>&nbsp;</th>" );
+        pw.println( "</tr>" );
 
-        this.tableHeader(pw);
+        this.tableHeader( pw );
 
         Bundle[] bundles = this.getBundles();
-        if (bundles == null || bundles.length == 0) {
-            pw.println("<tr class='content'>");
-            pw.println("<td class='content' colspan='6'>No " + this.getLabel()
-                + " installed currently</td>");
-            pw.println("</tr>");
-        } else {
+        if ( bundles == null || bundles.length == 0 )
+        {
+            pw.println( "<tr class='content'>" );
+            pw.println( "<td class='content' colspan='6'>No " + this.getLabel() + " installed currently</td>" );
+            pw.println( "</tr>" );
+        }
+        else
+        {
 
-            sort(bundles);
+            sort( bundles );
 
             long previousBundle = -1;
-            for (int i = 0; i < bundles.length; i++) {
+            for ( int i = 0; i < bundles.length; i++ )
+            {
 
-                if (previousBundle >= 0) {
+                if ( previousBundle >= 0 )
+                {
                     // prepare for injected table information row
-                    pw.println("<tr id='bundle" + previousBundle + "'></tr>");
+                    pw.println( "<tr id='bundle" + previousBundle + "'></tr>" );
                 }
 
-                this.bundle(pw, bundles[i]);
+                this.bundle( pw, bundles[i] );
 
                 previousBundle = bundles[i].getBundleId();
             }
 
-            if (previousBundle >= 0) {
+            if ( previousBundle >= 0 )
+            {
                 // prepare for injected table information row
-                pw.println("<tr id='bundle" + previousBundle + "'></tr>");
+                pw.println( "<tr id='bundle" + previousBundle + "'></tr>" );
             }
         }
 
-        pw.println("<tr class='content'>");
-        pw.println("<td colspan='7' class='content'>&nbsp;</th>");
-        pw.println("</tr>");
+        pw.println( "<tr class='content'>" );
+        pw.println( "<td colspan='7' class='content'>&nbsp;</th>" );
+        pw.println( "</tr>" );
 
-        this.installForm(pw);
+        this.installForm( pw );
 
-        this.footer(pw);
+        this.footer( pw );
     }
 
-    protected Bundle[] getBundles() {
+
+    protected Bundle[] getBundles()
+    {
         return getBundleContext().getBundles();
     }
 
-    private void header(PrintWriter pw) {
-        Util.startScript(pw);
-        pw.println("function showDetails(bundleId) {");
-        pw.println("    var span = document.getElementById('bundle' + bundleId);");
-        pw.println("    if (!span) {");
-        pw.println("        return;");
-        pw.println("    }");
-        pw.println("    if (span.innerHTML) {");
-        pw.println("        span.innerHTML = '';");
-        pw.println("        return;");
-        pw.println("    }");
-        pw.println("    var parm = '?" + Util.PARAM_ACTION + "="
-            + AjaxBundleDetailsAction.NAME + "&" + BUNDLE_ID + "=' + bundleId;");
-        pw.println("    sendRequest('GET', parm, displayBundleDetails);");
-        pw.println("}");
-        pw.println("function displayBundleDetails(obj) {");
-        pw.println("    var span = document.getElementById('bundle' + obj."
-            + BUNDLE_ID + ");");
-        pw.println("    if (!span) {");
-        pw.println("        return;");
-        pw.println("    }");
-        pw.println("    var innerHtml = '<td class=\"content\">&nbsp;</td><td class=\"content\" colspan=\"6\"><table broder=\"0\">';");
-        pw.println("    var props = obj.props;");
-        pw.println("    for (var i=0; i < props.length; i++) {");
-        pw.println("        innerHtml += '<tr><td valign=\"top\" noWrap>' + props[i].key + '</td><td valign=\"top\">' + props[i].value + '</td></tr>';");
-        pw.println("    }");
-        pw.println("    innerHtml += '</table></td>';");
-        pw.println("    span.innerHTML = innerHtml;");
-        pw.println("}");
-        Util.endScript(pw);
 
-        pw.println("<table class='content' cellpadding='0' cellspacing='0' width='100%'>");
+    private void header( PrintWriter pw )
+    {
+        Util.startScript( pw );
+        pw.println( "function showDetails(bundleId) {" );
+        pw.println( "    var span = document.getElementById('bundle' + bundleId);" );
+        pw.println( "    if (!span) {" );
+        pw.println( "        return;" );
+        pw.println( "    }" );
+        pw.println( "    if (span.innerHTML) {" );
+        pw.println( "        span.innerHTML = '';" );
+        pw.println( "        return;" );
+        pw.println( "    }" );
+        pw.println( "    var parm = '?" + Util.PARAM_ACTION + "=" + AjaxBundleDetailsAction.NAME + "&" + BUNDLE_ID
+            + "=' + bundleId;" );
+        pw.println( "    sendRequest('GET', parm, displayBundleDetails);" );
+        pw.println( "}" );
+        pw.println( "function displayBundleDetails(obj) {" );
+        pw.println( "    var span = document.getElementById('bundle' + obj." + BUNDLE_ID + ");" );
+        pw.println( "    if (!span) {" );
+        pw.println( "        return;" );
+        pw.println( "    }" );
+        pw
+            .println( "    var innerHtml = '<td class=\"content\">&nbsp;</td><td class=\"content\" colspan=\"6\"><table broder=\"0\">';" );
+        pw.println( "    var props = obj.props;" );
+        pw.println( "    for (var i=0; i < props.length; i++) {" );
+        pw
+            .println( "        innerHtml += '<tr><td valign=\"top\" noWrap>' + props[i].key + '</td><td valign=\"top\">' + props[i].value + '</td></tr>';" );
+        pw.println( "    }" );
+        pw.println( "    innerHtml += '</table></td>';" );
+        pw.println( "    span.innerHTML = innerHtml;" );
+        pw.println( "}" );
+        Util.endScript( pw );
+
+        pw.println( "<table class='content' cellpadding='0' cellspacing='0' width='100%'>" );
     }
 
-    private void tableHeader(PrintWriter pw) {
+
+    private void tableHeader( PrintWriter pw )
+    {
         // pw.println("<tr class='content'>");
         // pw.println("<th class='content container' colspan='7'>Installed " +
         // getLabel() + "</th>");
         // pw.println("</tr>");
 
-        pw.println("<tr class='content'>");
-        pw.println("<th class='content'>ID</th>");
-        pw.println("<th class='content' width='100%'>Name</th>");
-        pw.println("<th class='content'>Status</th>");
-        pw.println("<th class='content' colspan='4'>Actions</th>");
-        pw.println("</tr>");
-    }
-
-    private void footer(PrintWriter pw) {
-        pw.println("</table>");
-    }
-
-    private void bundle(PrintWriter pw, Bundle bundle) {
-        String name = getName(bundle);
-
-        pw.println("<tr>");
-        pw.println("<td class='content right'>" + bundle.getBundleId()
-            + "</td>");
-        pw.println("<td class='content'><a href='javascript:showDetails("
-            + bundle.getBundleId() + ")'>" + name + "</a></td>");
-        pw.println("<td class='content center'>"
-            + this.toStateString(bundle.getState()) + "</td>");
+        pw.println( "<tr class='content'>" );
+        pw.println( "<th class='content'>ID</th>" );
+        pw.println( "<th class='content' width='100%'>Name</th>" );
+        pw.println( "<th class='content'>Status</th>" );
+        pw.println( "<th class='content' colspan='4'>Actions</th>" );
+        pw.println( "</tr>" );
+    }
+
+
+    private void footer( PrintWriter pw )
+    {
+        pw.println( "</table>" );
+    }
+
+
+    private void bundle( PrintWriter pw, Bundle bundle )
+    {
+        String name = getName( bundle );
+
+        pw.println( "<tr>" );
+        pw.println( "<td class='content right'>" + bundle.getBundleId() + "</td>" );
+        pw.println( "<td class='content'><a href='javascript:showDetails(" + bundle.getBundleId() + ")'>" + name
+            + "</a></td>" );
+        pw.println( "<td class='content center'>" + this.toStateString( bundle.getState() ) + "</td>" );
 
         // no buttons for system bundle
-        if (bundle.getBundleId() == 0) {
-            pw.println("<td class='content' colspan='4'>&nbsp;</td>");
-        } else {
-            boolean enabled = bundle.getState() == Bundle.INSTALLED
-                || bundle.getState() == Bundle.RESOLVED;
-            this.actionForm(pw, enabled, bundle.getBundleId(),
-                StartAction.NAME, StartAction.LABEL);
+        if ( bundle.getBundleId() == 0 )
+        {
+            pw.println( "<td class='content' colspan='4'>&nbsp;</td>" );
+        }
+        else
+        {
+            boolean enabled = bundle.getState() == Bundle.INSTALLED || bundle.getState() == Bundle.RESOLVED;
+            this.actionForm( pw, enabled, bundle.getBundleId(), StartAction.NAME, StartAction.LABEL );
 
             enabled = bundle.getState() == Bundle.ACTIVE;
-            this.actionForm(pw, enabled, bundle.getBundleId(), StopAction.NAME,
-                StopAction.LABEL);
+            this.actionForm( pw, enabled, bundle.getBundleId(), StopAction.NAME, StopAction.LABEL );
 
-            enabled = bundle.getState() != Bundle.UNINSTALLED
-                && this.hasUpdates(bundle);
-            this.actionForm(pw, enabled, bundle.getBundleId(),
-                UpdateAction.NAME, UpdateAction.LABEL);
+            enabled = bundle.getState() != Bundle.UNINSTALLED && this.hasUpdates( bundle );
+            this.actionForm( pw, enabled, bundle.getBundleId(), UpdateAction.NAME, UpdateAction.LABEL );
 
-            enabled = bundle.getState() == Bundle.INSTALLED
-                || bundle.getState() == Bundle.RESOLVED
+            enabled = bundle.getState() == Bundle.INSTALLED || bundle.getState() == Bundle.RESOLVED
                 || bundle.getState() == Bundle.ACTIVE;
-            this.actionForm(pw, enabled, bundle.getBundleId(),
-                UninstallAction.NAME, UninstallAction.LABEL);
+            this.actionForm( pw, enabled, bundle.getBundleId(), UninstallAction.NAME, UninstallAction.LABEL );
         }
 
-        pw.println("</tr>");
+        pw.println( "</tr>" );
     }
 
-    private void actionForm(PrintWriter pw, boolean enabled, long bundleId,
-            String action, String actionLabel) {
-        pw.println("<form name='form" + bundleId + "' method='post'>");
-        pw.println("<td class='content' align='right'>");
-        pw.println("<input type='hidden' name='" + Util.PARAM_ACTION
-            + "' value='" + action + "' />");
-        pw.println("<input type='hidden' name='" + BUNDLE_ID + "' value='"
-            + bundleId + "' />");
-        pw.println("<input class='submit' type='submit' value='" + actionLabel
-            + "'" + (enabled ? "" : "disabled") + " />");
-        pw.println("</td>");
-        pw.println("</form>");
+
+    private void actionForm( PrintWriter pw, boolean enabled, long bundleId, String action, String actionLabel )
+    {
+        pw.println( "<form name='form" + bundleId + "' method='post'>" );
+        pw.println( "<td class='content' align='right'>" );
+        pw.println( "<input type='hidden' name='" + Util.PARAM_ACTION + "' value='" + action + "' />" );
+        pw.println( "<input type='hidden' name='" + BUNDLE_ID + "' value='" + bundleId + "' />" );
+        pw.println( "<input class='submit' type='submit' value='" + actionLabel + "'" + ( enabled ? "" : "disabled" )
+            + " />" );
+        pw.println( "</td>" );
+        pw.println( "</form>" );
     }
 
-    private void installForm(PrintWriter pw) {
+
+    private void installForm( PrintWriter pw )
+    {
         int startLevel = getStartLevel().getInitialBundleStartLevel();
 
-        pw.println("<form method='post' enctype='multipart/form-data'>");
-        pw.println("<tr class='content'>");
-        pw.println("<td class='content'>&nbsp;</td>");
-        pw.println("<td class='content'>");
-        pw.println("<input type='hidden' name='" + Util.PARAM_ACTION
-            + "' value='" + InstallAction.NAME + "' />");
-        pw.println("<input class='input' type='file' name='"
-            + InstallAction.FIELD_BUNDLEFILE + "'>");
-        pw.println(" - Start <input class='checkradio' type='checkbox' name='"
-            + InstallAction.FIELD_START + "' value='start'>");
-        pw.println(" - Start Level <input class='input' type='input' name='"
-            + InstallAction.FIELD_STARTLEVEL + "' value='" + startLevel
-            + "' width='4'>");
-        pw.println("</td>");
-        pw.println("<td class='content' align='right' colspan='5' noWrap>");
-        pw.println("<input class='submit' style='width:auto' type='submit' value='"
-            + InstallAction.LABEL + "'>");
-        pw.println("&nbsp;");
-        pw.println("<input class='submit' style='width:auto' type='submit' value='"
-            + RefreshPackagesAction.LABEL
-            + "' onClick='this.form[\""
-            + Util.PARAM_ACTION
-            + "\"].value=\""
-            + RefreshPackagesAction.NAME
-            + "\"; return true;'>");
-        pw.println("</td>");
-        pw.println("</tr>");
-        pw.println("</form>");
+        pw.println( "<form method='post' enctype='multipart/form-data'>" );
+        pw.println( "<tr class='content'>" );
+        pw.println( "<td class='content'>&nbsp;</td>" );
+        pw.println( "<td class='content'>" );
+        pw.println( "<input type='hidden' name='" + Util.PARAM_ACTION + "' value='" + InstallAction.NAME + "' />" );
+        pw.println( "<input class='input' type='file' name='" + InstallAction.FIELD_BUNDLEFILE + "'>" );
+        pw.println( " - Start <input class='checkradio' type='checkbox' name='" + InstallAction.FIELD_START
+            + "' value='start'>" );
+        pw.println( " - Start Level <input class='input' type='input' name='" + InstallAction.FIELD_STARTLEVEL
+            + "' value='" + startLevel + "' width='4'>" );
+        pw.println( "</td>" );
+        pw.println( "<td class='content' align='right' colspan='5' noWrap>" );
+        pw.println( "<input class='submit' style='width:auto' type='submit' value='" + InstallAction.LABEL + "'>" );
+        pw.println( "&nbsp;" );
+        pw.println( "<input class='submit' style='width:auto' type='submit' value='" + RefreshPackagesAction.LABEL
+            + "' onClick='this.form[\"" + Util.PARAM_ACTION + "\"].value=\"" + RefreshPackagesAction.NAME
+            + "\"; return true;'>" );
+        pw.println( "</td>" );
+        pw.println( "</tr>" );
+        pw.println( "</form>" );
     }
 
-    private String toStateString(int bundleState) {
-        switch (bundleState) {
+
+    private String toStateString( int bundleState )
+    {
+        switch ( bundleState )
+        {
             case Bundle.INSTALLED:
                 return "Installed";
             case Bundle.RESOLVED:
@@ -285,48 +300,59 @@
         }
     }
 
-    private boolean hasUpdates(Bundle bundle) {
+
+    private boolean hasUpdates( Bundle bundle )
+    {
 
         // no updates if there is no installer service
         Object isObject = installerService.getService();
-        if (isObject == null) {
+        if ( isObject == null )
+        {
             return false;
         }
 
         // don't care for bundles with no symbolic name
-        if (bundle.getSymbolicName() == null) {
+        if ( bundle.getSymbolicName() == null )
+        {
             return false;
         }
-/*
-        Version bundleVersion = Version.parseVersion((String) bundle.getHeaders().get(
-            Constants.BUNDLE_VERSION));
-
-        BundleRepositoryAdmin repoAdmin = ((InstallerService) isObject).getBundleRepositoryAdmin();
-        for (Iterator<Resource> ri = repoAdmin.getResources(); ri.hasNext();) {
-            Resource res = ri.next();
-            if (bundle.getSymbolicName().equals(res.getSymbolicName())) {
-                if (res.getVersion().compareTo(bundleVersion) > 0) {
-                    return true;
+        /*
+                Version bundleVersion = Version.parseVersion((String) bundle.getHeaders().get(
+                    Constants.BUNDLE_VERSION));
+
+                BundleRepositoryAdmin repoAdmin = ((InstallerService) isObject).getBundleRepositoryAdmin();
+                for (Iterator<Resource> ri = repoAdmin.getResources(); ri.hasNext();) {
+                    Resource res = ri.next();
+                    if (bundle.getSymbolicName().equals(res.getSymbolicName())) {
+                        if (res.getVersion().compareTo(bundleVersion) > 0) {
+                            return true;
+                        }
+                    }
                 }
-            }
-        }
-*/
+        */
 
         return false;
     }
 
-    private void sort(Bundle[] bundles) {
-        Arrays.sort(bundles, BUNDLE_NAME_COMPARATOR);
+
+    private void sort( Bundle[] bundles )
+    {
+        Arrays.sort( bundles, BUNDLE_NAME_COMPARATOR );
     }
 
-    private static String getName(Bundle bundle) {
-        String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
-        if (name == null || name.length() == 0) {
+
+    private static String getName( Bundle bundle )
+    {
+        String name = ( String ) bundle.getHeaders().get( Constants.BUNDLE_NAME );
+        if ( name == null || name.length() == 0 )
+        {
             name = bundle.getSymbolicName();
-            if (name == null) {
+            if ( name == null )
+            {
                 name = bundle.getLocation();
-                if (name == null) {
-                    name = String.valueOf(bundle.getBundleId());
+                if ( name == null )
+                {
+                    name = String.valueOf( bundle.getBundleId() );
                 }
             }
         }
@@ -335,42 +361,52 @@
 
     // ---------- inner classes ------------------------------------------------
 
-    private static final Comparator BUNDLE_NAME_COMPARATOR = new Comparator() {
-        public int compare(Object o1, Object o2) {
-            return compare((Bundle) o1, (Bundle) o2);
+    private static final Comparator BUNDLE_NAME_COMPARATOR = new Comparator()
+    {
+        public int compare( Object o1, Object o2 )
+        {
+            return compare( ( Bundle ) o1, ( Bundle ) o2 );
         }
-        public int compare(Bundle b1, Bundle b2) {
+
+
+        public int compare( Bundle b1, Bundle b2 )
+        {
 
             // the same bundles
-            if (b1 == b2 || b1.getBundleId() == b2.getBundleId()) {
+            if ( b1 == b2 || b1.getBundleId() == b2.getBundleId() )
+            {
                 return 0;
             }
 
             // special case for system bundle, which always is first
-            if (b1.getBundleId() == 0) {
+            if ( b1.getBundleId() == 0 )
+            {
                 return -1;
-            } else if (b2.getBundleId() == 0) {
+            }
+            else if ( b2.getBundleId() == 0 )
+            {
                 return 1;
             }
 
             // compare the symbolic names
-            int snComp = getName(b1).compareToIgnoreCase(getName(b2));
-            if (snComp != 0) {
+            int snComp = getName( b1 ).compareToIgnoreCase( getName( b2 ) );
+            if ( snComp != 0 )
+            {
                 return snComp;
             }
 
             // same names, compare versions
-            Version v1 = Version.parseVersion((String) b1.getHeaders().get(
-                Constants.BUNDLE_VERSION));
-            Version v2 = Version.parseVersion((String) b2.getHeaders().get(
-                Constants.BUNDLE_VERSION));
-            int vComp = v1.compareTo(v2);
-            if (vComp != 0) {
+            Version v1 = Version.parseVersion( ( String ) b1.getHeaders().get( Constants.BUNDLE_VERSION ) );
+            Version v2 = Version.parseVersion( ( String ) b2.getHeaders().get( Constants.BUNDLE_VERSION ) );
+            int vComp = v1.compareTo( v2 );
+            if ( vComp != 0 )
+            {
                 return vComp;
             }
 
             // same version ? Not really, but then, we compare by bundle id
-            if (b1.getBundleId() < b2.getBundleId()) {
+            if ( b1.getBundleId() < b2.getBundleId() )
+            {
                 return -1;
             }