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 2009/11/26 08:47:54 UTC

svn commit: r884436 - /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java

Author: fmeschbe
Date: Thu Nov 26 07:47:54 2009
New Revision: 884436

URL: http://svn.apache.org/viewvc?rev=884436&view=rev
Log:
FELIX-1894 Display fragment info in bundle details view.

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java

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=884436&r1=884435&r2=884436&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 Thu Nov 26 07:47:54 2009
@@ -506,7 +506,7 @@
                     installed++;
                     break;
                 case Bundle.RESOLVED:
-                    if ( bundles[i].getHeaders().get(Constants.FRAGMENT_HOST) != null )
+                    if ( isFragmentBundle( bundles[i] ) )
                     {
                         fragments++;
                     }
@@ -638,7 +638,7 @@
 
     private boolean isFragmentBundle( Bundle bundle)
     {
-        return bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null;
+        return getPackageAdmin().getBundleType( bundle ) == PackageAdmin.BUNDLE_TYPE_FRAGMENT;
     }
 
     private boolean hasStart( Bundle bundle )
@@ -694,6 +694,8 @@
 
         keyVal( jw, "Bundle Classpath", headers.get( Constants.BUNDLE_CLASSPATH ) );
 
+        listFragmentInfo( jw, bundle, pluginRoot );
+
         if ( bundle.getState() == Bundle.INSTALLED )
         {
             listImportExportsUnresolved( jw, bundle, pluginRoot );
@@ -993,6 +995,40 @@
     }
 
 
+    private void listFragmentInfo( final JSONWriter jw, final Bundle bundle, final String pluginRoot )
+        throws JSONException
+    {
+
+        if ( isFragmentBundle( bundle ) )
+        {
+            Bundle[] hostBundles = getPackageAdmin().getHosts( bundle );
+            if ( hostBundles != null )
+            {
+                JSONArray val = new JSONArray();
+                for ( int i = 0; i < hostBundles.length; i++ )
+                {
+                    val.put( getBundleDescriptor( hostBundles[i], pluginRoot ) );
+                }
+                keyVal( jw, "Host Bundles", val );
+            }
+        }
+        else
+        {
+            Bundle[] fragmentBundles = getPackageAdmin().getFragments( bundle );
+            if ( fragmentBundles != null )
+            {
+                JSONArray val = new JSONArray();
+                for ( int i = 0; i < fragmentBundles.length; i++ )
+                {
+                    val.put( getBundleDescriptor( fragmentBundles[i], pluginRoot ) );
+                }
+                keyVal( jw, "Fragments Attached", val );
+            }
+        }
+
+    }
+
+
     private void appendProperty( JSONArray array, ServiceReference ref, String name, String label )
     {
         StringBuffer dest = new StringBuffer();