incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r783071 - /incubator/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java
Date Tue, 09 Jun 2009 17:12:35 GMT
Author: bdelacretaz
Date: Tue Jun  9 17:12:35 2009
New Revision: 783071

URL: http://svn.apache.org/viewvc?rev=783071&view=rev
Log:
SLING-1000 - add 'clear' option to recent requests plugin

Modified:
    incubator/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java

Modified: incubator/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java?rev=783071&r1=783070&r2=783071&view=diff
==============================================================================
--- incubator/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java
(original)
+++ incubator/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java
Tue Jun  9 17:12:35 2009
@@ -45,6 +45,7 @@
 
   public static final String LABEL = "requests";
   public static final String INDEX = "index";
+  public static final String CLEAR = "clear";
   private static RequestHistoryConsolePlugin instance;
   private ServiceRegistration serviceRegistration;
 
@@ -70,6 +71,13 @@
     requests[index] = r;
     lastRequestIndex = index;
   }
+  
+  private synchronized void clear() {
+    for(int i=0; i < requests.length; i++) {
+      requests[i] = null;
+    }
+    lastRequestIndex = -1;
+  }
 
   public static void initPlugin(BundleContext context) {
     if (instance == null) {
@@ -126,6 +134,13 @@
   protected void renderContent(HttpServletRequest req, HttpServletResponse res)
       throws ServletException, IOException {
 
+    // If so requested, clear our data
+    if(req.getParameter(CLEAR) != null) {
+      clear();
+      res.sendRedirect(LABEL);
+      return;
+    }
+    
     // Select request to display
     int index = 0;
     final String tmp = req.getParameter(INDEX);
@@ -157,7 +172,9 @@
     // Links to other requests
     pw.println("<thead>");
     pw.println("<tr class='content'>");
-    pw.println("<th colspan='2'class='content container'>Recent Requests</th>");
+    pw.println("<th colspan='2'class='content container'>Recent Requests");
+    pw.println(" (<a href='" + LABEL + "?clear=clear'>Clear</a>)");
+    pw.println("</th>");
     pw.println("</thead>");
     pw.println("<tbody>");
     pw.println("<tr class='content'><td>");



Mime
View raw message