You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2009/04/27 22:35:54 UTC

svn commit: r769151 - in /felix/trunk/webconsole/src/main: java/org/apache/felix/webconsole/internal/core/BundlesServlet.java resources/res/ui/bundles.js

Author: cziegeler
Date: Mon Apr 27 20:35:53 2009
New Revision: 769151

URL: http://svn.apache.org/viewvc?rev=769151&view=rev
Log:
FELIX-1048 : Recognize fragment bundles and display them properly in the bundles list.

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
    felix/trunk/webconsole/src/main/resources/res/ui/bundles.js

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java?rev=769151&r1=769150&r2=769151&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java Mon Apr 27 20:35:53 2009
@@ -343,7 +343,7 @@
 
     private String getStatusLine(final Bundle[] bundles)
     {
-        int active = 0, installed = 0, resolved = 0;
+        int active = 0, installed = 0, resolved = 0, fragments = 0;
         for ( int i = 0; i < bundles.length; i++ )
         {
             switch ( bundles[i].getState() )
@@ -355,14 +355,21 @@
                     installed++;
                     break;
                 case Bundle.RESOLVED:
-                    resolved++;
+                    if ( bundles[i].getHeaders().get(Constants.FRAGMENT_HOST) != null )
+                    {
+                        fragments++;
+                    }
+                    else
+                    {
+                        resolved++;
+                    }
                     break;
             }
         }
         final StringBuffer buffer = new StringBuffer();
         buffer.append("Bundle information: ");
         appendBundleInfoCount(buffer, "in total", bundles.length);
-        if ( active == bundles.length )
+        if ( active == bundles.length || active + fragments == bundles.length )
         {
             buffer.append(" - all ");
             appendBundleInfoCount(buffer, "active.", bundles.length);
@@ -374,6 +381,11 @@
                 buffer.append(", ");
                 appendBundleInfoCount(buffer, "active", active);
             }
+            if ( fragments != 0 )
+            {
+                buffer.append(", ");
+                appendBundleInfoCount(buffer, "active fragments", fragments);
+            }
             if ( resolved != 0 )
             {
                 buffer.append(", ");
@@ -397,7 +409,7 @@
         jw.key( "name" );
         jw.value( Util.getName( bundle ) );
         jw.key( "state" );
-        jw.value( toStateString( bundle.getState() ) );
+        jw.value( toStateString( bundle ) );
 
         jw.key( "actions" );
         jw.array();
@@ -432,13 +444,17 @@
     }
 
 
-    private String toStateString( int bundleState )
+    private String toStateString( final Bundle bundle )
     {
-        switch ( bundleState )
+        switch ( bundle.getState() )
         {
             case Bundle.INSTALLED:
                 return "Installed";
             case Bundle.RESOLVED:
+                if ( bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null )
+                {
+                    return "Fragment";
+                }
                 return "Resolved";
             case Bundle.STARTING:
                 return "Starting";
@@ -449,7 +465,7 @@
             case Bundle.UNINSTALLED:
                 return "Uninstalled";
             default:
-                return "Unknown: " + bundleState;
+                return "Unknown: " + bundle.getState();
         }
     }
 
@@ -467,12 +483,20 @@
 
     private boolean hasStart( Bundle bundle )
     {
+        if ( bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null )
+        {
+            return false;
+        }
         return bundle.getState() == Bundle.INSTALLED || bundle.getState() == Bundle.RESOLVED;
     }
 
 
     private boolean hasStop( Bundle bundle )
     {
+        if ( bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null )
+        {
+            return false;
+        }
         return bundle.getState() == Bundle.ACTIVE;
     }
 

Modified: felix/trunk/webconsole/src/main/resources/res/ui/bundles.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/res/ui/bundles.js?rev=769151&r1=769150&r2=769151&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/res/ui/bundles.js (original)
+++ felix/trunk/webconsole/src/main/resources/res/ui/bundles.js Mon Apr 27 20:35:53 2009
@@ -55,6 +55,9 @@
 }
 
 function actionButton( /* Element */ parent, /* string */ id, /* Obj */ action ) {
+	if ( !action.enabled ) {
+		return;
+	}
 	var enabled = action.enabled;
 	var op = action.link;
 	var opLabel = action.name;