FELIX-2448 Prevent WireAdmin and PermissionAdmin plugins from corrupting the Configuration Render output and improve Configuration Render to log ConfigurationPrinter failure instead of failing
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@957859 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/WireAdminConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/WireAdminConfigurationPrinter.java
index ab2e65c..6aa3bb7 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/WireAdminConfigurationPrinter.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/WireAdminConfigurationPrinter.java
@@ -31,7 +31,7 @@
import org.osgi.service.wireadmin.WireAdmin;
/**
- * WireAdminConfigurationPrinter reads the configured wires in WireAdmin service, and
+ * WireAdminConfigurationPrinter reads the configured wires in WireAdmin service, and
* prints them along their properties and values.
*/
public final class WireAdminConfigurationPrinter extends AbstractConfigurationPrinter
@@ -39,6 +39,9 @@
private static final String TITLE = "Wire Admin";
+ private static final String WIRE_ADMIN_NAME = "org.osgi.service.wireadmin.WireAdmin";
+
+
/**
* @see org.apache.felix.webconsole.ConfigurationPrinter#getTitle()
*/
@@ -53,7 +56,7 @@
public final void printConfiguration(PrintWriter pw)
{
final BundleContext bc = getBundleContext();
- final ServiceReference ref = bc.getServiceReference(WireAdmin.class.getName());
+ final ServiceReference ref = bc.getServiceReference( WIRE_ADMIN_NAME );
final WireAdmin wireAdmin = (WireAdmin) (ref != null ? bc.getService(ref) : null);
try
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/PermissionsConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/PermissionsConfigurationPrinter.java
index 05cb714..984cbd9 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/PermissionsConfigurationPrinter.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/PermissionsConfigurationPrinter.java
@@ -31,7 +31,7 @@
import org.osgi.service.permissionadmin.PermissionInfo;
/**
- * PermissionsPrinter reads the given permissions from PermissionAdmin and
+ * PermissionsPrinter reads the given permissions from PermissionAdmin and
* ConditionalPermissionAdmin and prints them.
*/
public final class PermissionsConfigurationPrinter extends AbstractConfigurationPrinter
@@ -39,6 +39,11 @@
private static final String TITLE = "Permissions";
+ private static final String PERMISSION_ADMIN_NAME = "org.osgi.service.permissionadmin.PermissionAdmin";
+
+ private static final String CONDITIONAL_PERMISSION_ADMIN_NAME = "org.osgi.service.condpermadmin.ConditionalPermissionAdmin";
+
+
/**
* @see org.apache.felix.webconsole.ConfigurationPrinter#getTitle()
*/
@@ -53,8 +58,8 @@
public final void printConfiguration(PrintWriter pw)
{
final BundleContext bc = getBundleContext();
- final ServiceReference paRef = bc.getServiceReference(PermissionAdmin.class.getName());
- final ServiceReference cpaRef = bc.getServiceReference(ConditionalPermissionAdmin.class.getName());
+ final ServiceReference paRef = bc.getServiceReference( PERMISSION_ADMIN_NAME );
+ final ServiceReference cpaRef = bc.getServiceReference( CONDITIONAL_PERMISSION_ADMIN_NAME );
final PermissionAdmin pa = paRef != null ? (PermissionAdmin) bc.getService(paRef)
: null;
final ConditionalPermissionAdmin cpa = cpaRef != null ? (ConditionalPermissionAdmin) bc.getService(cpaRef)
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
index 4154bea..0389843 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
@@ -339,13 +339,23 @@
{
pw.title( desc.title );
final ConfigurationPrinter cp = desc.printer;
- if ( cp instanceof ModeAwareConfigurationPrinter )
+ try
{
- ( ( ModeAwareConfigurationPrinter ) cp ).printConfiguration( pw, mode );
+ if ( cp instanceof ModeAwareConfigurationPrinter )
+ {
+ ( ( ModeAwareConfigurationPrinter ) cp ).printConfiguration( pw, mode );
+ }
+ else
+ {
+ cp.printConfiguration( pw );
+ }
}
- else
+ catch ( Throwable t )
{
- cp.printConfiguration( pw );
+ pw.println();
+ pw.println( "Configuration Printer failed: " + t.toString() );
+ pw.println();
+ log( "Configuration Printer " + desc.title + " (" + cp.getClass() + ") failed", t );
}
pw.end();
}