FELIX-3237 Add ConfigurationPrinter functionality to the plugin to get the same information in Configuration Status dumps
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1203908 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java b/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java
index 7c81303..e6dd0d4 100644
--- a/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java
+++ b/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java
@@ -56,7 +56,9 @@
Hashtable<String, Object> props = new Hashtable<String, Object>();
props.put("felix.webconsole.label", plugin.getLabel());
props.put("felix.webconsole.title", plugin.getTitle());
- props.put(Constants.SERVICE_DESCRIPTION, "Felix Http Whiteboard WebConsole Plugin");
+ props.put("felix.webconsole.configprinter.modes", new String[]
+ { "txt", "zip" });
+ props.put(Constants.SERVICE_DESCRIPTION, "Felix Http Whiteboard WebConsole Plugin and Configuration Printer");
httpPlugin = getBundleContext().registerService("javax.servlet.Servlet", plugin, props);
SystemLogger.info("Http service whiteboard started");
diff --git a/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/HttpWhiteboardWebConsolePlugin.java b/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/HttpWhiteboardWebConsolePlugin.java
index 9e57b9b..408f7e3 100755
--- a/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/HttpWhiteboardWebConsolePlugin.java
+++ b/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/HttpWhiteboardWebConsolePlugin.java
@@ -105,7 +105,7 @@
private void printServletMappings(PrintWriter pw, Map<Object, AbstractMapping> mappings)
{
pw.println("<tr>");
- pw.println("<th class='content container' colspan='4'>Registered Filter and Servlet Services</td>");
+ pw.println("<th class='content container' colspan='4'>Registered Servlet Services</td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<th class='content'>Alias</td>");
@@ -132,7 +132,7 @@
private void printFilterMappings(PrintWriter pw, Map<Object, AbstractMapping> mappings)
{
pw.println("<tr>");
- pw.println("<th class='content container' colspan='4'>Registered Filter and Servlet Services</td>");
+ pw.println("<th class='content container' colspan='4'>Registered Filter Services</td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<th class='content'>Pattern</td>");
@@ -156,4 +156,52 @@
}
}
+ public void printConfiguration(final PrintWriter pw)
+ {
+ printHttpContextServicesTxt(pw);
+ final Map<Object, AbstractMapping> mappings = extMgr.getMappings();
+ printServletMappingsTxt(pw, mappings);
+ printFilterMappingsTxt(pw, mappings);
+ }
+
+ private void printHttpContextServicesTxt(PrintWriter pw)
+ {
+ pw.println("Registered HttpContext Services");
+ final Map<String, HttpContext> contexts = extMgr.getHttpContexts();
+ for (Map.Entry<String, HttpContext> handler : contexts.entrySet())
+ {
+ pw.println(" " + handler.getKey() + " ==> " + handler.getValue() + "</td>");
+ }
+ pw.println();
+ }
+
+ private void printServletMappingsTxt(PrintWriter pw, Map<Object, AbstractMapping> mappings)
+ {
+ pw.println("Registered Servlet Services");
+ for (Map.Entry<Object, AbstractMapping> handler : mappings.entrySet())
+ {
+ if (handler.getValue() instanceof ServletMapping)
+ {
+ ServletMapping sm = (ServletMapping) handler.getValue();
+ pw.println(" " + sm.getAlias() + " ==> " + sm.getServlet() + " (" + sm.getInitParams() + ", "
+ + sm.getContext() + ")");
+ }
+ }
+ pw.println();
+ }
+
+ private void printFilterMappingsTxt(PrintWriter pw, Map<Object, AbstractMapping> mappings)
+ {
+ pw.println("Registered Filter Services");
+ for (Map.Entry<Object, AbstractMapping> handler : mappings.entrySet())
+ {
+ if (handler.getValue() instanceof FilterMapping)
+ {
+ FilterMapping fm = (FilterMapping) handler.getValue();
+ pw.println(" " + fm.getPattern() + " ==> " + fm.getFilter() + " (" + fm.getRanking() + ", "
+ + fm.getInitParams() + ", " + fm.getContext() + ")");
+ }
+ }
+ pw.println();
+ }
}