FELIX-1050 Add new Bundle detail block "Manifest Headers" showing
the complete list of manifest headers as returned from
Bundle.getHeaders()
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@773497 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
index 722ccb8..7f8a027 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
@@ -552,6 +552,8 @@
}
listServices( jw, bundle );
+
+ listHeaders( jw, bundle );
jw.endArray();
}
@@ -797,13 +799,13 @@
{
return;
}
-
+
for ( int i = 0; i < refs.length; i++ )
{
String key = "Service ID " + refs[i].getProperty( Constants.SERVICE_ID );
-
+
JSONArray val = new JSONArray();
-
+
appendProperty( val, refs[i], Constants.OBJECTCLASS, "Types" );
appendProperty( val, refs[i], Constants.SERVICE_PID, "PID" );
appendProperty( val, refs[i], ConfigurationAdmin.SERVICE_FACTORYPID, "Factory PID" );
@@ -812,10 +814,30 @@
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( jw, key, val);
}
}
+
+
+ private void listHeaders( JSONWriter jw, Bundle bundle ) throws JSONException
+ {
+ JSONArray val = new JSONArray();
+
+ Dictionary headers = bundle.getHeaders();
+ Enumeration he = headers.keys();
+ while ( he.hasMoreElements() )
+ {
+ Object header = he.nextElement();
+ String value = String.valueOf(headers.get( header ));
+ // Package headers may be long, support line breaking by
+ // ensuring blanks after comma and semicolon.
+ value = value.replaceAll( "([;,])", "$1 " );
+ val.put( header + ": " + value );
+ }
+
+ keyVal( jw, "Manifest Headers", val );
+ }
private void appendProperty( JSONArray array, ServiceReference ref, String name, String label )