You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2010/02/16 09:14:02 UTC

svn commit: r910420 - in /sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal: Activator.java ThreadDumperPanel.java

Author: cziegeler
Date: Tue Feb 16 08:14:01 2010
New Revision: 910420

URL: http://svn.apache.org/viewvc?rev=910420&view=rev
Log:
SLING-1376 : Don't register thread dumps view as a web console plugin, configuration printer is enough

Modified:
    sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java
    sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/ThreadDumperPanel.java

Modified: sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java?rev=910420&r1=910419&r2=910420&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java (original)
+++ sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/Activator.java Tue Feb 16 08:14:01 2010
@@ -45,22 +45,17 @@
         try {
             register(bundleContext,
                 new String[] { "org.apache.felix.shell.Command" },
-                new ThreadDumpCommand(), null);
+                new ThreadDumpCommand());
         } catch (Throwable t) {
             // shell service might not be available, don't care
         }
 
-        // install Web Console plugin
+        // install Web Console configuration printer
         try {
             ThreadDumperPanel tdp = new ThreadDumperPanel();
-            tdp.activate(bundleContext);
 
-            Dictionary<String, Object> properties = new Hashtable<String, Object>();
-            properties.put("felix.webconsole.label", tdp.getLabel());
-
-            register(bundleContext, new String[] { "javax.servlet.Servlet",
-                "org.apache.felix.webconsole.ConfigurationPrinter" }, tdp,
-                properties);
+            register(bundleContext, new String[] {
+                "org.apache.felix.webconsole.ConfigurationPrinter" }, tdp);
         } catch (Throwable t) {
             // web console might not be available, don't care
         }
@@ -71,12 +66,9 @@
     }
 
     private void register(BundleContext context, String[] serviceNames,
-            Object service, Dictionary<String, Object> properties) {
+            Object service) {
 
-        // ensure properties
-        if (properties == null) {
-            properties = new Hashtable<String, Object>();
-        }
+        final Dictionary<String, Object> properties = new Hashtable<String, Object>();
 
         // default settings
         properties.put(Constants.SERVICE_DESCRIPTION, "Thread Dumper ("
@@ -92,7 +84,7 @@
      * Logs the uncaught exception for the thread at level ERROR and chains to
      * the old handler, which was installed before this handler has been
      * installed.
-     * 
+     *
      * @param t The <code>Thread</code> which got the exception but did not
      *            handle it.
      * @param e The uncaught <code>Throwable</code> causing the thread to die.

Modified: sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/ThreadDumperPanel.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/ThreadDumperPanel.java?rev=910420&r1=910419&r2=910420&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/ThreadDumperPanel.java (original)
+++ sling/trunk/bundles/extensions/threaddump/src/main/java/org/apache/sling/extensions/threaddump/internal/ThreadDumperPanel.java Tue Feb 16 08:14:01 2010
@@ -18,73 +18,28 @@
  */
 package org.apache.sling.extensions.threaddump.internal;
 
-import java.io.IOException;
 import java.io.PrintWriter;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import javax.servlet.Servlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
-import org.apache.felix.webconsole.AbstractWebConsolePlugin;
 import org.apache.felix.webconsole.ConfigurationPrinter;
 
-public class ThreadDumperPanel extends AbstractWebConsolePlugin implements
-        Servlet, ConfigurationPrinter {
-
-    private static final String LABEL = "threads";
+public class ThreadDumperPanel implements ConfigurationPrinter {
 
     private static final String TITLE = "Threads";
 
     private BaseThreadDumper baseThreadDumper = new BaseThreadDumper();
 
-    // ---------- AbstractWebConsolePlugin API
-
-    @Override
-    public String getLabel() {
-        return LABEL;
-    }
-
-    @Override
+    /**
+     * @see org.apache.felix.webconsole.ConfigurationPrinter#getTitle()
+     */
     public String getTitle() {
         return TITLE;
     }
 
-    @Override
-    protected void renderContent(HttpServletRequest request,
-            HttpServletResponse response) throws IOException {
-        PrintWriter pw = response.getWriter();
-
-        pw.println("<pre>");
-        pw.println("</pre>");
-
-        pw.println( "<table class='content' cellpadding='0' cellspacing='0' width='100%'>" );
-
-        pw.println( "<tr class='content'>" );
-        pw.println( "<th class='content container'>" + getTitle() + "</th>" );
-        pw.println( "</tr>" );
-
-        pw.println( "<tr class='content'>" );
-        pw.println( "<td class='content'>" );
-        pw.println( "<pre>" );
-
-        pw.println( "*** Date: "
-            + SimpleDateFormat.getDateTimeInstance( SimpleDateFormat.LONG, SimpleDateFormat.LONG, Locale.US ).format(
-                new Date() ) );
-        pw.println();
-
-        baseThreadDumper.printThreads(pw, true);
-
-        pw.println( "</pre>" );
-        pw.println( "</td>" );
-        pw.println( "</tr>" );
-        pw.println( "</table>" );
-    }
-
     // ---------- ConfigurationPrinter
 
+    /**
+     * @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
+     */
     public void printConfiguration(PrintWriter pw) {
         pw.println("*** Threads Dumps:");
         baseThreadDumper.printThreads(pw, true);