commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1508066 [1/2] - in /commons/sandbox/monitoring/trunk: ./ aop/src/main/java/org/apache/commons/monitoring/aop/ cdi/src/test/java/org/apache/commons/monitoring/cdi/ core/src/main/java/org/apache/commons/monitoring/ core/src/main/java/org/apa...
Date Mon, 29 Jul 2013 13:47:41 GMT
Author: rmannibucau
Date: Mon Jul 29 13:47:39 2013
New Revision: 1508066

URL: http://svn.apache.org/r1508066
Log:
basic gui + getting rid of visitable/visitor pattern for formats

Added:
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/MapFormat.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/MapBuilder.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/Templates.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/WebResourceLoader.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/MonitoringController.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ClearHandler.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/FilteringHandler.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/Handler.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/HtmlHandler.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/RedirectHandler.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/Renderer.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ReportHandler.java
      - copied, changed from r1507950, commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/MonitoringServlet.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ResetHandler.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/util/
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/util/HttpUtils.java
      - copied, changed from r1507950, commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/HttpUtils.java
    commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/
    commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/home.vm
    commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/page.vm
    commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report.vm
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/
      - copied from r1507950, commons/sandbox/monitoring/trunk/reporting/src/main/webapp/css/
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/bootstrap.min.css
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/monitoring.css
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/images/
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/images/asc.gif   (with props)
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/images/desc.gif   (with props)
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/js/
      - copied from r1507950, commons/sandbox/monitoring/trunk/reporting/src/main/webapp/js/
    commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormatsTest.java
      - copied, changed from r1507950, commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormattingVisitorTest.java
Removed:
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/Visitable.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/Visitor.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/AbstractVisitor.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/FormattingVisitor.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/HttpUtils.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/MonitoringServlet.java
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/css/
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/js/
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/theme.blue.css
    commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormattingVisitorTest.java
    commons/sandbox/monitoring/trunk/reporting/src/test/resources/
Modified:
    commons/sandbox/monitoring/trunk/aop/src/main/java/org/apache/commons/monitoring/aop/AbstractPerformanceInterceptor.java
    commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/Counter.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/DefaultCounter.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/Unit.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/monitors/DefaultMonitor.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/monitors/Monitor.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/DefaultRepository.java
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/Repository.java
    commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/stopwatches/DefaultStopWatchTest.java
    commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredConnection.java
    commons/sandbox/monitoring/trunk/pom.xml
    commons/sandbox/monitoring/trunk/reporting/pom.xml
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/CSVFormat.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/Format.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/HTMLFormat.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/JSONFormat.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/MetricData.java
    commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/XMLFormat.java
    commons/sandbox/monitoring/trunk/reporting/src/main/resources/META-INF/NOTICE.txt
    commons/sandbox/monitoring/trunk/reporting/src/main/webapp/WEB-INF/web.xml

Modified: commons/sandbox/monitoring/trunk/aop/src/main/java/org/apache/commons/monitoring/aop/AbstractPerformanceInterceptor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/aop/src/main/java/org/apache/commons/monitoring/aop/AbstractPerformanceInterceptor.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/aop/src/main/java/org/apache/commons/monitoring/aop/AbstractPerformanceInterceptor.java (original)
+++ commons/sandbox/monitoring/trunk/aop/src/main/java/org/apache/commons/monitoring/aop/AbstractPerformanceInterceptor.java Mon Jul 29 13:47:39 2013
@@ -24,8 +24,6 @@ import org.apache.commons.monitoring.sto
 
 import java.lang.reflect.Method;
 
-import static org.apache.commons.monitoring.counter.Unit.UNARY;
-
 /**
  * A method interceptor that compute method invocation performances.
  * <p/>

Modified: commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java (original)
+++ commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java Mon Jul 29 13:47:39 2013
@@ -24,7 +24,6 @@ import org.junit.Test;
 
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.inject.spi.BeanManager;
-
 import java.util.concurrent.TimeUnit;
 
 import static org.junit.Assert.assertEquals;

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/Counter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/Counter.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/Counter.java (original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/Counter.java Mon Jul 29 13:47:39 2013
@@ -18,7 +18,6 @@
 package org.apache.commons.monitoring.counter;
 
 import org.apache.commons.monitoring.Role;
-import org.apache.commons.monitoring.Visitable;
 import org.apache.commons.monitoring.monitors.Monitor;
 
 /**
@@ -27,7 +26,7 @@ import org.apache.commons.monitoring.mon
  *
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
-public interface Counter extends Visitable {
+public interface Counter {
     /**
      * reset the Metric
      */

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/DefaultCounter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/DefaultCounter.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/DefaultCounter.java (original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/DefaultCounter.java Mon Jul 29 13:47:39 2013
@@ -18,7 +18,6 @@ package org.apache.commons.monitoring.co
 
 import org.apache.commons.math.stat.descriptive.SummaryStatistics;
 import org.apache.commons.monitoring.Role;
-import org.apache.commons.monitoring.Visitor;
 import org.apache.commons.monitoring.configuration.Configuration;
 import org.apache.commons.monitoring.counter.queuemanager.MetricQueueManager;
 import org.apache.commons.monitoring.monitors.Monitor;
@@ -130,11 +129,6 @@ public class DefaultCounter implements C
         return statistics.getN();
     }
 
-    @Override
-    public void accept(final Visitor visitor) {
-        visitor.visit(this);
-    }
-
     public Lock getLock() {
         return lock;
     }

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/Unit.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/Unit.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/Unit.java (original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/counter/Unit.java Mon Jul 29 13:47:39 2013
@@ -44,8 +44,7 @@ public class Unit implements Comparable<
     /**
      * Time based units
      */
-    public static class Time
-        extends Unit {
+    public static class Time extends Unit {
         public static final Unit NANOSECOND = new Unit("ns");
         public static final Unit MICROSECOND = new Unit("┬Ás", NANOSECOND, 1000);
         public static final Unit MILLISECOND = new Unit("ms", MICROSECOND, 1000);
@@ -95,7 +94,7 @@ public class Unit implements Comparable<
     // "BILLION" does not have same signification depending on country (10^12 or 10^9).
     // We use International system of unit names to avoid confusion
     // @see http://en.wikipedia.org/wiki/SI
-    public static final Unit UNARY = new Unit("-");
+    public static final Unit UNARY = new Unit("u");
     public static final Unit DECA = new Unit("*10", UNARY, 10);
     public static final Unit HECTO = new Unit("*100", DECA, 10);
     public static final Unit KILO = new Unit("*1000", HECTO, 10);

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/monitors/DefaultMonitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/monitors/DefaultMonitor.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/monitors/DefaultMonitor.java (original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/monitors/DefaultMonitor.java Mon Jul 29 13:47:39 2013
@@ -18,7 +18,6 @@
 package org.apache.commons.monitoring.monitors;
 
 import org.apache.commons.monitoring.Role;
-import org.apache.commons.monitoring.Visitor;
 import org.apache.commons.monitoring.configuration.Configuration;
 import org.apache.commons.monitoring.counter.Counter;
 import org.apache.commons.monitoring.counter.factory.CounterFactory;
@@ -111,9 +110,4 @@ public class DefaultMonitor implements M
     public int getMaxConcurrency() {
         return maxConcurrency;
     }
-
-    @Override
-    public void accept(final Visitor visitor) {
-        visitor.visit(this);
-    }
 }

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/monitors/Monitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/monitors/Monitor.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/monitors/Monitor.java (original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/monitors/Monitor.java Mon Jul 29 13:47:39 2013
@@ -18,7 +18,6 @@
 package org.apache.commons.monitoring.monitors;
 
 import org.apache.commons.monitoring.Role;
-import org.apache.commons.monitoring.Visitable;
 import org.apache.commons.monitoring.counter.Counter;
 
 import java.util.Collection;
@@ -46,7 +45,7 @@ import java.util.concurrent.atomic.Atomi
  *
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
-public interface Monitor extends Visitable {
+public interface Monitor {
     /**
      * @return the monitor key
      */

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/DefaultRepository.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/DefaultRepository.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/DefaultRepository.java (original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/DefaultRepository.java Mon Jul 29 13:47:39 2013
@@ -17,8 +17,6 @@
 
 package org.apache.commons.monitoring.repositories;
 
-import org.apache.commons.monitoring.Visitor;
-import org.apache.commons.monitoring.configuration.Configuration;
 import org.apache.commons.monitoring.monitors.DefaultMonitor;
 import org.apache.commons.monitoring.monitors.Monitor;
 import org.apache.commons.monitoring.monitors.Monitor.Key;
@@ -108,9 +106,4 @@ public class DefaultRepository implement
     public StopWatch start(final Monitor monitor) {
         return new CounterStopWatch(monitor);
     }
-
-    @Override
-    public void accept(final Visitor visitor) {
-        visitor.visit(this);
-    }
 }

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/Repository.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/Repository.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/Repository.java (original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/Repository.java Mon Jul 29 13:47:39 2013
@@ -17,7 +17,6 @@
 
 package org.apache.commons.monitoring.repositories;
 
-import org.apache.commons.monitoring.Visitable;
 import org.apache.commons.monitoring.configuration.Configuration;
 import org.apache.commons.monitoring.monitors.Monitor;
 import org.apache.commons.monitoring.stopwatches.StopWatch;
@@ -31,7 +30,7 @@ import java.util.Set;
  *
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
-public interface Repository extends Visitable {
+public interface Repository {
     static final Repository INSTANCE = Configuration.newInstance(Repository.class);
 
     /**

Modified: commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/stopwatches/DefaultStopWatchTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/stopwatches/DefaultStopWatchTest.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/stopwatches/DefaultStopWatchTest.java (original)
+++ commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/stopwatches/DefaultStopWatchTest.java Mon Jul 29 13:47:39 2013
@@ -21,7 +21,6 @@ import org.apache.commons.monitoring.Rol
 import org.apache.commons.monitoring.counter.Counter;
 import org.apache.commons.monitoring.counter.Unit;
 import org.apache.commons.monitoring.monitors.Monitor;
-import org.apache.commons.monitoring.Visitor;
 import org.apache.commons.monitoring.util.ClassLoaders;
 import org.junit.Test;
 
@@ -189,9 +188,5 @@ public class DefaultStopWatchTest {
         public int getMaxConcurrency() {
             return 0;
         }
-
-        public void accept(Visitor visitor) {
-            // NoOp
-        }
     }
 }

Modified: commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredConnection.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredConnection.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredConnection.java (original)
+++ commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredConnection.java Mon Jul 29 13:47:39 2013
@@ -20,7 +20,6 @@ package org.apache.commons.monitoring.jd
 import org.apache.commons.monitoring.Role;
 import org.apache.commons.monitoring.counter.Unit;
 import org.apache.commons.monitoring.monitors.Monitor;
-import org.apache.commons.monitoring.repositories.Repository;
 import org.apache.commons.monitoring.stopwatches.CounterStopWatch;
 import org.apache.commons.monitoring.stopwatches.StopWatch;
 import org.apache.commons.monitoring.util.ClassLoaders;

Modified: commons/sandbox/monitoring/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/pom.xml?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/pom.xml (original)
+++ commons/sandbox/monitoring/trunk/pom.xml Mon Jul 29 13:47:39 2013
@@ -79,8 +79,8 @@
             <exclude>**/*/MANIFEST.MF</exclude>
             <exclude>.git</exclude>
             <exclude>.gitignore</exclude>
-            <exclude>**/webapp/js/*.js</exclude>
-            <exclude>**/webapp/css/*.css</exclude>
+            <exclude>**/webapp/resources/js/*.js</exclude>
+            <exclude>**/webapp/resources/css/*.css</exclude>
           </excludes>
         </configuration>
         <executions>

Modified: commons/sandbox/monitoring/trunk/reporting/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/pom.xml?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/pom.xml (original)
+++ commons/sandbox/monitoring/trunk/reporting/pom.xml Mon Jul 29 13:47:39 2013
@@ -31,6 +31,10 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-servlet_2.5_spec</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.commons.monitoring</groupId>
       <artifactId>commons-monitoring-core</artifactId>
       <version>${project.version}</version>
@@ -43,26 +47,15 @@
       <version>3.1</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-servlet_2.5_spec</artifactId>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>1.7</version>
     </dependency>
 
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
     </dependency>
-    <dependency>
-      <groupId>xmlunit</groupId>
-      <artifactId>xmlunit</artifactId>
-      <version>1.3</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.jettison</groupId>
-      <artifactId>jettison</artifactId>
-      <version>1.2</version>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
   <repositories>

Modified: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/CSVFormat.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/CSVFormat.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/CSVFormat.java (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/CSVFormat.java Mon Jul 29 13:47:39 2013
@@ -17,82 +17,39 @@
 package org.apache.commons.monitoring.reporting.format;
 
 import org.apache.commons.monitoring.configuration.Configuration;
-import org.apache.commons.monitoring.monitors.Monitor;
+import org.apache.commons.monitoring.counter.Unit;
 
 import java.io.PrintWriter;
-import java.util.Arrays;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.Map;
 
-public class CSVFormat implements Format {
+public class CSVFormat extends MapFormat implements Format {
     private static final String SEPARATOR = Configuration.getProperty(Configuration.COMMONS_MONITORING_PREFIX + "csv.separator", ";");
-    private static final String ATTRIBUTES_CSV = buildMetricDataHeader();
+    public static final String HEADER = "Monitor" + SEPARATOR + "Category" + SEPARATOR + "Role" + SEPARATOR + toCsv(ATTRIBUTES_ORDERED_LIST);
 
-    public static final String HEADER = "Monitor" + SEPARATOR + "Category" + SEPARATOR + "Role" + SEPARATOR + ATTRIBUTES_CSV + "\n";
 
-    private static final Collection<String> ATTRIBUTES_ORDERED_LIST = Arrays.asList(ATTRIBUTES_CSV.split(SEPARATOR));
+    @Override
+    public void render(final PrintWriter writer, final Map<String, ?> params) {
+        final Unit timeUnit = timeUnit(params);
 
-    private static String buildMetricDataHeader() {
-        final StringBuilder builder = new StringBuilder();
-        for (final MetricData md : MetricData.values()) {
-            builder.append(md.name()).append(SEPARATOR);
-        }
-
-        final String str = builder.toString();
-        return str.substring(0, str.length() - 1);
-    }
-
-    private String monitorName;
-    private StringBuilder builder = new StringBuilder();
-    private final Map<String, String> attributes = new HashMap<String, String>();
-
-    public void repositoryStart(final PrintWriter writer) {
         writer.write(HEADER);
-    }
-
-    public void repositoryEnd(final PrintWriter writer) {
-        // no-op
-    }
-
-    public void monitorStart(final PrintWriter writer, final Monitor monitor) {
-        monitorName = monitor.getKey().getName() + SEPARATOR + monitor.getKey().getCategory() + SEPARATOR;
-    }
-
-    public void monitorEnd(final PrintWriter writer, final String name) {
-        // no-op
-    }
-
-    public void counterStart(final PrintWriter writer, final String name) {
-        builder.append(monitorName).append(name).append(SEPARATOR);
-        attributes.clear();
-    }
-
-    public void counterEnd(final PrintWriter writer, final String name) {
-        for (final String key : ATTRIBUTES_ORDERED_LIST) {
-            final String value = attributes.get(key);
-            if (value != null) {
-                builder.append(value);
-            } else {
-                builder.append("?");
-            }
-            builder.append(SEPARATOR);
+        for (final Collection<String> line : snapshot(timeUnit)) {
+            writer.write(toCsv(line));
         }
-
-        final String s = builder.toString();
-        writer.write(s.substring(0, s.length() - 1) + "\n");
-        builder = new StringBuilder();
     }
 
-    public void attribute(final PrintWriter writer, String name, final String value) {
-        attributes.put(name, value);
+    @Override
+    public String type() {
+        return "text/plain";
     }
 
-    public void separator(final PrintWriter writer) {
-        // no-op
-    }
+    private static String toCsv(final Collection<String> line) {
+        final StringBuilder builder = new StringBuilder();
+        for (final String s : line) {
+            builder.append(s).append(SEPARATOR);
+        }
 
-    public void escape(final PrintWriter writer, final String string) {
-        builder.append(string).append(SEPARATOR);
+        final String str = builder.toString();
+        return str.substring(0, str.length() - 1) + '\n';
     }
 }

Modified: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/Format.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/Format.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/Format.java (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/Format.java Mon Jul 29 13:47:39 2013
@@ -17,35 +17,14 @@
 
 package org.apache.commons.monitoring.reporting.format;
 
-import org.apache.commons.monitoring.monitors.Monitor;
+import org.apache.commons.monitoring.reporting.web.handler.Renderer;
 
-import java.io.PrintWriter;
-
-public interface Format {
-
-    void repositoryStart(PrintWriter writer);
-
-    void repositoryEnd(PrintWriter writer);
-
-    void monitorStart(PrintWriter writer, Monitor monitor);
-
-    void monitorEnd(PrintWriter writer, String name);
-
-    void counterStart(PrintWriter writer, String name);
-
-    void counterEnd(PrintWriter writer, String name);
-
-    void attribute(PrintWriter writer, String name, String value);
-
-    void separator(PrintWriter writer);
-
-    void escape(PrintWriter writer, String string);
+public interface Format extends Renderer {
+    String type();
 
     public static interface Defaults {
-        static final Format JSON = new JSONFormat(false);
-        static final Format JSON_PRETTY = new JSONFormat(true);
-        static final Format XML = new XMLFormat(false);
-        static final Format XML_PRETTY = new XMLFormat(true);
+        static final Format JSON = new JSONFormat();
+        static final Format XML = new XMLFormat();
         static final Format CSV = new CSVFormat();
         static final Format HTML = new HTMLFormat();
     }

Modified: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/HTMLFormat.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/HTMLFormat.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/HTMLFormat.java (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/HTMLFormat.java Mon Jul 29 13:47:39 2013
@@ -16,135 +16,26 @@
  */
 package org.apache.commons.monitoring.reporting.format;
 
-import org.apache.commons.lang3.StringEscapeUtils;
-import org.apache.commons.monitoring.monitors.Monitor;
+import org.apache.commons.monitoring.counter.Unit;
+import org.apache.commons.monitoring.reporting.template.MapBuilder;
+import org.apache.commons.monitoring.reporting.template.Templates;
 
 import java.io.PrintWriter;
-import java.util.Collection;
-import java.util.HashMap;
 import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
 
-// TODO: write a real front?
-public class HTMLFormat implements Format {
-    private static final Collection<String> ATTRIBUTES_ORDERED_LIST = buildMetricDataHeader();
-
-    private static Collection<String> buildMetricDataHeader() {
-        final Collection<String> list = new CopyOnWriteArrayList<String>();
-        list.add("Monitor");
-        list.add("Category");
-        list.add("Role");
-        for (final MetricData md : MetricData.values()) {
-            list.add(md.name());
-        }
-        return list;
-    }
-
-    private final Map<String, String> attributes = new HashMap<String, String>();
-
-    public void repositoryStart(final PrintWriter writer) {
-        writer.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n" +
-            "<html>\n" +
-            "  <head>\n" +
-            "    <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n" +
-            "    \n" +
-            "    <title>Monitoring HTML Report</title>\n" +
-            "\n" +
-            "    <link href=\"" + RenderingContext.getBase() + "/css/theme.blue.css\" rel=\"stylesheet\">\n" +
-            "    <script type=\"text/javascript\" language=\"javascript\" src=\"" + RenderingContext.getBase() + "/js/jquery.min.js" +"\"></script>\n" +
-            "    <script type=\"text/javascript\" language=\"javascript\" src=\"" + RenderingContext.getBase() + "/js/jquery.tablesorter.js" +"\"></script>\n" +
-            "    <script type=\"text/javascript\" language=\"javascript\" src=\"" + RenderingContext.getBase() + "/js/jquery.tablesorter.widgets.js" +"\"></script>\n" +
-            "  </head>\n" +
-            "  <body>\n" +
-            "    <div id=\"container\">\n" +
-            "      <h1>Report</h1>\n" +
-            "\n" +
-            "      <table class=\"sort-table\" id=\"report-table\" border=\"1\">\n" +
-            "        <thead>\n");
-        writeColumnNames(writer);
-        writer.write("        </thead>\n        <tbody>\n");
-    }
-
-    private void writeColumnNames(PrintWriter writer) {
-        for (final String n : ATTRIBUTES_ORDERED_LIST) {
-            writer.write("<th>");
-            writer.write(n);
-            writer.write("</th>\n");
-        }
-    }
-
-    public void repositoryEnd(final PrintWriter writer) {
-        writer.write("      </table>\n" +
-            "\n" +
-            "    </div>" +
-            "" +
-            "    <script type=\"text/javascript\">\n" +
-            "      $(function(){\n" +
-            "        $(\"#report-table\").tablesorter({\n" +
-            "    theme: 'blue',\n" +
-            "    widthFixed : true,\n" +
-            "    widgets: [\"zebra\", \"filter\"],\n" +
-            "    widgetOptions : {\n" +
-            "      filter_childRows : false,\n" +
-            "      filter_columnFilters : true,\n" +
-            "      filter_cssFilter : 'tablesorter-filter',\n" +
-            "      filter_filteredRow   : 'filtered',\n" +
-            "      filter_formatter : null,\n" +
-            "      filter_functions : null,\n" +
-            "      filter_hideFilters : false, // true, (see note in the options section above)\n" +
-            "      filter_ignoreCase : true,\n" +
-            "      filter_liveSearch : true,\n" +
-            "      filter_reset : 'button.reset',\n" +
-            "      filter_searchDelay : 300,\n" +
-            "      filter_serversideFiltering: false,\n" +
-            "      filter_startsWith : false,\n" +
-            "      filter_useParsedData : false\n" +
-            "\n" +
-            "    }\n" +
-            "\n" +
-            "  });\n" +
-            "      });" +
-            "    </script>" +
-            "  </body>\n" +
-            "</html>");
-    }
-
-    public void monitorStart(final PrintWriter writer, final Monitor monitor) {
-        attributes.put("Monitor", StringEscapeUtils.escapeHtml4(monitor.getKey().getName()));
-        attributes.put("Category", monitor.getKey().getCategory());
-    }
-
-    public void monitorEnd(final PrintWriter writer, final String name) {
-    }
-
-    public void counterStart(final PrintWriter writer, final String name) {
-        attributes.put("Role", name);
-    }
-
-    public void counterEnd(final PrintWriter writer, final String name) {
-        writer.write("<tr>\n");
-        for (final String key : ATTRIBUTES_ORDERED_LIST) {
-            writer.write("<td>");
-            final String value = attributes.get(key);
-            if (value != null) {
-                writer.write(value);
-            } else {
-                writer.write("");
-            }
-            writer.write("</td>\n");
-        }
-        writer.write("</tr>\n");
-    }
-
-    public void attribute(final PrintWriter writer, String name, final String value) {
-        attributes.put(name, value);
-    }
-
-    public void separator(final PrintWriter writer) {
-        // no-op
+public class HTMLFormat extends MapFormat implements Format {
+    @Override
+    public void render(final PrintWriter writer, final Map<String, ?> params) {
+        final Unit timeUnit = timeUnit(params);
+        Templates.htmlRender(writer, "report.vm",
+            new MapBuilder<String, Object>()
+                .set("headers", ATTRIBUTES_ORDERED_LIST)
+                .set("data", snapshot(timeUnit))
+                .build());
     }
 
-    public void escape(final PrintWriter writer, final String string) {
-        //  no-op
+    @Override
+    public String type() {
+        return "text/html";
     }
 }

Modified: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/JSONFormat.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/JSONFormat.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/JSONFormat.java (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/JSONFormat.java Mon Jul 29 13:47:39 2013
@@ -17,83 +17,52 @@
 
 package org.apache.commons.monitoring.reporting.format;
 
-import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.monitoring.counter.Counter;
 import org.apache.commons.monitoring.monitors.Monitor;
+import org.apache.commons.monitoring.repositories.Repository;
 
 import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Map;
 
-
-/**
- * Format to JSON (JavaScript), with optional indentation
- *
- * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
- */
 public class JSONFormat implements Format {
-    private boolean indent;
-
-    public JSONFormat(boolean indent) {
-        this.indent = indent;
-    }
-
-    public void repositoryStart(PrintWriter writer) {
-        writer.append("{");
-    }
-
-    public void repositoryEnd(PrintWriter writer) {
-        if (indent) {
-            writer.append("\n");
-        }
-        writer.append("}");
-    }
-
-    public void monitorStart(PrintWriter writer, Monitor monitor) {
-        if (indent) {
-            writer.append("\n  ");
-        }
-        Monitor.Key key = monitor.getKey();
-        escape(writer, key.getName());
-        writer.append(":{");
-        if (indent) {
-            writer.append("\n    \"category\": \"").append(monitor.getKey().getCategory()).append("\",");
-        }
-    }
+    private static final MetricData[] METRIC_DATA = MetricData.values();
 
-    public void monitorEnd(PrintWriter writer, String name) {
-        if (indent) {
-            writer.append("\n  ");
+    @Override
+    public void render(final PrintWriter writer, final Map<String, ?> params) {
+        writer.write("{\"monitors\":[");
+        final Iterator<Monitor> monitors = Repository.INSTANCE.getMonitors().iterator();
+        while (monitors.hasNext()) {
+            final Monitor monitor = monitors.next();
+            writer.write("{\"name\":\"" + monitor.getKey().getName() + "\",");
+            writer.write("\"category\":\"" + monitor.getKey().getCategory() + "\",");
+            writer.write("\"counters\":[");
+            final Iterator<Counter> counters = monitor.getCounters().iterator();
+            while (counters.hasNext()) {
+                final Counter counter = counters.next();
+                writer.write("{\"role\":\"" + counter.getRole().getName() + "\",");
+                writer.write("\"unit\":\"" + counter.getRole().getUnit().getName() + "\",");
+                for (int i = 0; i < METRIC_DATA.length; i++) {
+                    writer.write("\"" + METRIC_DATA[i].name() + "\":\"" + METRIC_DATA[i].value(counter) + "\"");
+                    if (i < METRIC_DATA.length - 1) {
+                        writer.write(",");
+                    }
+                }
+                writer.write("}");
+                if (counters.hasNext()) {
+                    writer.write(",");
+                }
+            }
+            writer.write("]}");
+            if (monitors.hasNext()) {
+                writer.write(",");
+            }
         }
-
-        writer.append("}");
-    }
-
-    public void counterStart(PrintWriter writer, String name) {
-        if (indent) {
-            writer.append("\n    ");
-        }
-        escape(writer, name);
-        writer.append(":{");
-        writeAttribute(writer, "type", "counter");
-    }
-
-    public void counterEnd(PrintWriter writer, String name) {
-        writer.append("}");
-    }
-
-    public void attribute(PrintWriter writer, String name, String value) {
-        separator(writer);
-        writeAttribute(writer, name, value);
-    }
-
-    protected void writeAttribute(PrintWriter writer, String name, String value) {
-        writer.append("\"").append(name).append("\"").append(":");
-        escape(writer, value);
-    }
-
-    public void escape(PrintWriter writer, String string) {
-        writer.append('\"').append(StringEscapeUtils.escapeEcmaScript(string)).append('\"');
+        writer.write("]}");
     }
 
-    public void separator(PrintWriter writer) {
-        writer.append(",");
+    @Override
+    public String type() {
+        return "application/json";
     }
 }
\ No newline at end of file

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/MapFormat.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/MapFormat.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/MapFormat.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/MapFormat.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.format;
+
+import org.apache.commons.monitoring.counter.Counter;
+import org.apache.commons.monitoring.counter.Unit;
+import org.apache.commons.monitoring.monitors.Monitor;
+import org.apache.commons.monitoring.repositories.Repository;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+public class MapFormat {
+    protected static final Collection<String> ATTRIBUTES_ORDERED_LIST = buildMetricDataHeader();
+
+    protected static Collection<String> buildMetricDataHeader() {
+        final Collection<String> list = new CopyOnWriteArrayList<String>();
+        list.add("Monitor");
+        list.add("Category");
+        list.add("Role");
+        for (final MetricData md : MetricData.values()) {
+            list.add(md.name());
+        }
+        return list;
+    }
+
+    protected static Unit timeUnit(final Map<String, ?> params) {
+        final Object u = params.get("unit");
+        if (u != null && String.class.isInstance(u)) {
+            return Unit.get(String.class.cast(u).toUpperCase());
+        }
+        return Unit.Time.MILLISECOND;
+    }
+
+    protected static Collection<Collection<String>> snapshot(final Unit timeUnit) {
+        final Collection<Collection<String>> data = new ArrayList<Collection<String>>();
+        for (final Monitor monitor : Repository.INSTANCE.getMonitors()) {
+            for (final Counter counter : monitor.getCounters()) {
+                final Unit counterUnit = counter.getRole().getUnit();
+                final boolean compatible = timeUnit.isCompatible(counterUnit);
+
+                final Collection<String> line = new ArrayList<String>();
+                data.add(line);
+
+                line.add(monitor.getKey().getName());
+                line.add(monitor.getKey().getCategory());
+
+                if (compatible) {
+                    line.add(counter.getRole().getName() + " (" + timeUnit.getName() + ")");
+                } else {
+                    line.add(counter.getRole().getName() + " (" + counterUnit.getName() + ")");
+                }
+
+                for (final MetricData md : MetricData.values()) {
+                    double value = md.value(counter);
+                    if (md.isTime() && compatible && timeUnit != counterUnit) {
+                        value = timeUnit.convert(value, counterUnit);
+                    }
+                    line.add(Double.toString(value));
+                }
+            }
+        }
+        return data;
+    }
+}

Modified: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/MetricData.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/MetricData.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/MetricData.java (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/MetricData.java Mon Jul 29 13:47:39 2013
@@ -39,73 +39,134 @@ public enum MetricData {
         public double value(final Counter counter) {
             return counter.getHits();
         }
+
+        @Override
+        public boolean isTime() {
+            return false;
+        }
     },
     Max {
         @Override
         public double value(final Counter counter) {
             return counter.getMax();
         }
+
+        @Override
+        public boolean isTime() {
+            return true;
+        }
     },
     Mean {
         @Override
         public double value(final Counter counter) {
             return counter.getMean();
         }
+
+        @Override
+        public boolean isTime() {
+            return true;
+        }
     },
     Min {
         @Override
         public double value(final Counter counter) {
             return counter.getMin();
         }
+
+        @Override
+        public boolean isTime() {
+            return true;
+        }
     },
     StandardDeviation {
         @Override
         public double value(final Counter counter) {
             return counter.getStandardDeviation();
         }
+
+        @Override
+        public boolean isTime() {
+            return false;
+        }
     },
     Sum {
         @Override
         public double value(final Counter counter) {
             return counter.getSum();
         }
+
+        @Override
+        public boolean isTime() {
+            return true;
+        }
     },
     SumOfLogs {
         @Override
         public double value(final Counter counter) {
             return counter.getSumOfLogs();
         }
+
+        @Override
+        public boolean isTime() {
+            return false;
+        }
     },
     SumOfSquares {
         @Override
         public double value(final Counter counter) {
             return counter.getSumOfSquares();
         }
+
+        @Override
+        public boolean isTime() {
+            return false;
+        }
     },
     Variance {
         @Override
         public double value(final Counter counter) {
             return counter.getVariance();
         }
+
+        @Override
+        public boolean isTime() {
+            return false;
+        }
     },
     GeometricMean {
         @Override
         public double value(final Counter counter) {
             return counter.getGeometricMean();
         }
+
+        @Override
+        public boolean isTime() {
+            return false;
+        }
     },
     Value {
         @Override
         public double value(final Counter counter) {
             return counter.getSum();
         }
+
+        @Override
+        public boolean isTime() {
+            return true;
+        }
     },
     MaxConcurrency {
         @Override
         public double value(final Counter counter) {
             return counter.getMonitor().getMaxConcurrency();
         }
+
+        @Override
+        public boolean isTime() {
+            return false;
+        }
     };
 
     public abstract double value(Counter counter);
+    public abstract boolean isTime();
 }
\ No newline at end of file

Modified: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/XMLFormat.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/XMLFormat.java?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/XMLFormat.java (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/format/XMLFormat.java Mon Jul 29 13:47:39 2013
@@ -17,78 +17,33 @@
 
 package org.apache.commons.monitoring.reporting.format;
 
-import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.monitoring.counter.Counter;
 import org.apache.commons.monitoring.monitors.Monitor;
+import org.apache.commons.monitoring.repositories.Repository;
 
 import java.io.PrintWriter;
+import java.util.Map;
 
-/**
- * Format to XML, with optional indentation
- *
- * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
- */
 public class XMLFormat implements Format {
-    public XMLFormat(boolean indent) {
-        super();
-        this.indent = indent;
-    }
-
-    private boolean indent;
-
-    public void repositoryStart(PrintWriter writer) {
-        writer.append("<repository>");
-    }
-
-    public void repositoryEnd(PrintWriter writer) {
-        if (indent) {
-            writer.append("\n");
-        }
-        writer.append("</repository>");
-    }
-
-    public void monitorStart(PrintWriter writer, Monitor monitor) {
-        if (indent) {
-            writer.append("\n  ");
-        }
-        writer.append("<monitor");
-        Monitor.Key key = monitor.getKey();
-        attribute(writer, "name", key.getName());
-        attribute(writer, "category", key.getCategory());
-        writer.append('>');
-    }
-
-    public void monitorEnd(PrintWriter writer, String name) {
-        if (indent) {
-            writer.append("\n  ");
+    @Override
+    public void render(final PrintWriter writer, final Map<String, ?> params) {
+        writer.write("<repository>");
+        for (final Monitor monitor : Repository.INSTANCE.getMonitors()) {
+            writer.write("<monitor name=\"" + monitor.getKey().getName() + "\" category=\"" + monitor.getKey().getCategory() + "\">");
+            for (final Counter counter : monitor.getCounters()) {
+                writer.write("<counter role=\"" + counter.getRole().getName() + "\" unit=\"" + counter.getRole().getUnit().getName() + "\"");
+                for (final MetricData md : MetricData.values()) {
+                    writer.write(" " + md.name() + "=\"" + md.value(counter) + "\"");
+                }
+                writer.write(" />");
+            }
+            writer.write("</monitor>");
         }
-        writer.append("</monitor>");
-    }
-
-    public void counterStart(PrintWriter writer, String name) {
-        if (indent) {
-            writer.append("\n    ");
-        }
-        writer.append("<counter");
-        attribute(writer, "role", name);
-    }
-
-    public void counterEnd(PrintWriter writer, String name) {
-        writer.append("/>");
-    }
-
-    public void attribute(PrintWriter writer, String name, String value) {
-        writer.append(" ")
-            .append(name)
-            .append("=\"");
-        escape(writer, value);
-        writer.append("\"");
-    }
-
-    public void escape(PrintWriter writer, String string) {
-        writer.append(StringEscapeUtils.escapeXml(string));
+        writer.write("</repository>");
     }
 
-    public void separator(PrintWriter writer) {
-        // Nop
+    @Override
+    public String type() {
+        return "application/xml";
     }
 }
\ No newline at end of file

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/MapBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/MapBuilder.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/MapBuilder.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/MapBuilder.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.template;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MapBuilder<A, B> {
+    private final Map<A, B> map = new HashMap<A, B>();
+
+    public MapBuilder<A, B> set(final A a, final B b) {
+        map.put(a, b);
+        return this;
+    }
+
+    public Map<A, B> build() {
+        return map;
+    }
+}

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/Templates.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/Templates.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/Templates.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/Templates.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.template;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.log.JdkLogChute;
+
+import javax.servlet.ServletContext;
+import java.io.PrintWriter;
+import java.util.Map;
+import java.util.Properties;
+
+public final class Templates {
+    private static String base;
+    private static String mapping;
+    private static ServletContext servletContext;
+
+    public static void init(final ServletContext context, final String filterMapping) {
+        servletContext = context;
+
+        final Properties velocityConfiguration = new Properties();
+        velocityConfiguration.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, JdkLogChute.class.getName());
+        velocityConfiguration.setProperty(RuntimeConstants.ENCODING_DEFAULT, "UTF-8");
+        velocityConfiguration.setProperty(RuntimeConstants.INPUT_ENCODING, "UTF-8");
+        velocityConfiguration.setProperty(RuntimeConstants.OUTPUT_ENCODING, "UTF-8");
+        velocityConfiguration.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, Boolean.TRUE.toString());
+        velocityConfiguration.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT_ESCAPE, Boolean.TRUE.toString());
+        velocityConfiguration.setProperty(RuntimeConstants.RESOURCE_LOADER, "monitoring");
+        velocityConfiguration.setProperty("monitoring." + RuntimeConstants.RESOURCE_LOADER + ".class", WebResourceLoader.class.getName());
+        Velocity.init(velocityConfiguration);
+
+        base = context.getContextPath();
+        if (filterMapping.isEmpty()) {
+            mapping = context.getContextPath();
+        } else {
+            mapping = context.getContextPath() + filterMapping;
+        }
+    }
+
+    public static ServletContext getServletContext() {
+        return servletContext;
+    }
+
+    public static void htmlRender(final PrintWriter writer, final String template, final Map<String, ?> variables) {
+        final VelocityContext context = newVelocityContext(variables);
+        context.put("base", base);
+        context.put("mapping", mapping);
+        context.put("currentTemplate", template);
+
+        final Template velocityTemplate = Velocity.getTemplate("/templates/page.vm", "UTF-8");
+        velocityTemplate.merge(context, writer);
+    }
+
+    public static void render(final PrintWriter writer, final String template, final Map<String, ?> variables) {
+        final VelocityContext context = newVelocityContext(variables);
+        context.put("base", base);
+        final Template velocityTemplate = Velocity.getTemplate(template, "UTF-8");
+        velocityTemplate.merge(context, writer);
+    }
+
+    private static VelocityContext newVelocityContext(final Map<String, ?> variables) {
+        final VelocityContext context;
+        if (variables.isEmpty()) {
+            context = new VelocityContext();
+        } else {
+            context = new VelocityContext(variables);
+        }
+        return context;
+    }
+
+    private Templates() {
+        // no-op
+    }
+}

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/WebResourceLoader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/WebResourceLoader.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/WebResourceLoader.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/template/WebResourceLoader.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.template;
+
+import org.apache.commons.collections.ExtendedProperties;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.resource.Resource;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+import java.io.InputStream;
+
+public class WebResourceLoader extends ClasspathResourceLoader {
+    @Override
+    public void init(final ExtendedProperties configuration) {
+        // no-op
+    }
+
+    @Override
+    public InputStream getResourceStream(final String source) throws ResourceNotFoundException {
+        try {
+            return super.getResourceStream(source);
+        } catch (final ResourceNotFoundException rnfe) {
+            final InputStream is = Templates.getServletContext().getResourceAsStream(source);
+            if (is == null) {
+                throw rnfe;
+            }
+            return is;
+        }
+    }
+
+    @Override
+    public boolean isSourceModified(final Resource resource) {
+        return false;
+    }
+
+    @Override
+    public long getLastModified(final Resource resource) {
+        return 0;
+    }
+}

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/MonitoringController.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/MonitoringController.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/MonitoringController.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/MonitoringController.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.web;
+
+import org.apache.commons.monitoring.reporting.template.Templates;
+import org.apache.commons.monitoring.reporting.web.handler.ClearHandler;
+import org.apache.commons.monitoring.reporting.web.handler.FilteringHandler;
+import org.apache.commons.monitoring.reporting.web.handler.Handler;
+import org.apache.commons.monitoring.reporting.web.handler.HtmlHandler;
+import org.apache.commons.monitoring.reporting.web.handler.Renderer;
+import org.apache.commons.monitoring.reporting.web.handler.ReportHandler;
+import org.apache.commons.monitoring.reporting.web.handler.ResetHandler;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MonitoringController implements Filter {
+    private final Map<String, Handler> handlers = new HashMap<String, Handler>();
+    private Handler defaultHandler;
+    private String mapping;
+    private ServletContext servletContext;
+
+    @Override
+    public void init(final FilterConfig config) throws ServletException {
+        servletContext = config.getServletContext();
+        initMapping(config);
+        initHandlers();
+        initTemplates();
+    }
+
+    private void initHandlers() {
+        defaultHandler = new HtmlHandler("home.vm");
+        handlers.put("/", defaultHandler);
+        handlers.put("/home", defaultHandler);
+        handlers.put("/report", new ReportHandler());
+        handlers.put("/clear", new ClearHandler());
+        handlers.put("/reset", new ResetHandler());
+        handlers.put("/resources/css/monitoring.css", FilteringHandler.INSTANCE); // filtered to get the right base for pictures
+    }
+
+    private void initTemplates() {
+        Templates.init(servletContext, mapping);
+    }
+
+    private void initMapping(FilterConfig config) {
+        mapping = config.getInitParameter("monitoring-mapping");
+        if (mapping == null) {
+            mapping = "";
+        } else if (!mapping.startsWith("/")) {
+            mapping = "/" + mapping;
+        }
+        if (mapping.endsWith("/")) {
+            mapping = mapping.substring(0, mapping.length() - 1);
+        }
+    }
+
+    @Override
+    public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
+        if (!HttpServletRequest.class.isInstance(request)) {
+            chain.doFilter(request, response);
+            return;
+        }
+
+        final HttpServletRequest httpRequest = HttpServletRequest.class.cast(request);
+
+        final Handler handler = findHandler(httpRequest);
+        final String path = httpRequest.getRequestURI().substring(httpRequest.getContextPath().length());
+        if (handler == defaultHandler && servletContext.getResourceAsStream(path) != null) {
+            chain.doFilter(request, response);
+            return;
+        }
+
+        final Renderer renderer = handler.handle(httpRequest, HttpServletResponse.class.cast(response));
+        if (renderer != null) {
+            renderer.render(response.getWriter(), request.getParameterMap());
+        }
+    }
+
+    private Handler findHandler(final HttpServletRequest request) {
+        String path = request.getRequestURI().substring(request.getContextPath().length() + mapping.length());
+        if (!path.startsWith("/")) {
+            path = "/" + path;
+        }
+
+        final Handler handler = handlers.get(path);
+        if (handler != null) {
+            return handler;
+        }
+
+        return defaultHandler;
+    }
+
+    @Override
+    public void destroy() {
+        handlers.clear();
+    }
+}

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ClearHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ClearHandler.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ClearHandler.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ClearHandler.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.web.handler;
+
+import org.apache.commons.monitoring.repositories.Repository;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ClearHandler extends RedirectHandler {
+    @Override
+    public Renderer handle(final HttpServletRequest request, final HttpServletResponse response) {
+        Repository.INSTANCE.clear();
+        return super.handle(request, response);
+    }
+
+    @Override
+    public String from() {
+        return "clear";
+    }
+
+    @Override
+    public String to() {
+        return "report";
+    }
+}

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/FilteringHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/FilteringHandler.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/FilteringHandler.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/FilteringHandler.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.web.handler;
+
+import org.apache.commons.monitoring.reporting.template.Templates;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.PrintWriter;
+import java.util.Collections;
+import java.util.Map;
+
+public class FilteringHandler implements Handler {
+    public static final FilteringHandler INSTANCE = new FilteringHandler();
+
+    private FilteringHandler() {
+        // no-op
+    }
+
+    @Override
+    public Renderer handle(final HttpServletRequest request, final HttpServletResponse response) {
+        return new FilteringRenderer(request.getRequestURI().substring(request.getContextPath().length()));
+    }
+
+    private static class FilteringRenderer implements Renderer {
+        private final String path;
+
+        public FilteringRenderer(final String path) {
+            this.path = path;
+        }
+
+        @Override
+        public void render(final PrintWriter writer, final Map<String, ?> params) {
+            Templates.render(writer, path, Collections.<String, Object>emptyMap());
+        }
+    }
+}

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/Handler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/Handler.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/Handler.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/Handler.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.web.handler;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public interface Handler {
+    Renderer handle(HttpServletRequest request, HttpServletResponse response);
+}

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/HtmlHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/HtmlHandler.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/HtmlHandler.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/HtmlHandler.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.web.handler;
+
+import org.apache.commons.monitoring.reporting.template.Templates;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.PrintWriter;
+import java.util.Map;
+
+public class HtmlHandler implements Handler {
+    private final HtmlRenderer renderer;
+
+    public HtmlHandler(final String template) {
+        this.renderer = new HtmlRenderer(template);
+    }
+
+    @Override
+    public Renderer handle(final HttpServletRequest request, final HttpServletResponse response) {
+        return renderer;
+    }
+
+    protected static class HtmlRenderer implements Renderer {
+        private final String template;
+
+        public HtmlRenderer(final String template) {
+            this.template = template;
+        }
+
+        @Override
+        public void render(PrintWriter writer, Map<String, ?> params) {
+            Templates.htmlRender(writer, template, params);
+        }
+    }
+}

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/RedirectHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/RedirectHandler.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/RedirectHandler.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/RedirectHandler.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.web.handler;
+
+import org.apache.commons.monitoring.MonitoringException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public abstract class RedirectHandler implements Handler {
+    @Override
+    public Renderer handle(final HttpServletRequest request, final HttpServletResponse response) {
+        try {
+            response.sendRedirect(request.getRequestURI().substring(0, request.getRequestURI().length() - from().length()) + to());
+        } catch (final Exception e) {
+            throw new MonitoringException(e);
+        }
+        return null;
+    }
+
+    public abstract String from();
+    public abstract String to();
+}

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/Renderer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/Renderer.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/Renderer.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/Renderer.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.web.handler;
+
+import java.io.PrintWriter;
+import java.util.Map;
+
+public interface Renderer {
+    void render(PrintWriter writer, Map<String, ?> params);
+}

Copied: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ReportHandler.java (from r1507950, commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/MonitoringServlet.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ReportHandler.java?p2=commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ReportHandler.java&p1=commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/MonitoringServlet.java&r1=1507950&r2=1508066&rev=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/MonitoringServlet.java (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ReportHandler.java Mon Jul 29 13:47:39 2013
@@ -14,24 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-package org.apache.commons.monitoring.reporting.web;
+package org.apache.commons.monitoring.reporting.web.handler;
 
 import org.apache.commons.monitoring.reporting.format.Format;
-import org.apache.commons.monitoring.reporting.format.FormattingVisitor;
-import org.apache.commons.monitoring.reporting.format.RenderingContext;
-import org.apache.commons.monitoring.repositories.Repository;
+import org.apache.commons.monitoring.reporting.web.util.HttpUtils;
 
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 
-public class MonitoringServlet extends HttpServlet {
+public class ReportHandler implements Handler {
     private static Map<String, Format> extensions = new HashMap<String, Format>();
     private static Map<String, Format> formats = new HashMap<String, Format>();
 
@@ -54,15 +48,15 @@ public class MonitoringServlet extends H
     }
 
     @Override
-    protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+    public Renderer handle(final HttpServletRequest request, final HttpServletResponse response) {
         Format format = null;
 
-        final String path = req.getRequestURI();
+        final String path = request.getRequestURI();
         final int dot = path.lastIndexOf('.');
         if (dot >= 0) {
             format = extensions.get(path.substring(dot + 1).toLowerCase(Locale.ENGLISH));
         } else {
-            final String mime = HttpUtils.parseAccept(req.getHeader("Accept"));
+            final String mime = HttpUtils.parseAccept(request.getHeader("Accept"));
             if (mime != null) {
                 format = formats.get(mime);
             }
@@ -71,11 +65,7 @@ public class MonitoringServlet extends H
             format = Format.Defaults.CSV;
         }
 
-        RenderingContext.setBase(req.getContextPath());
-        try {
-            Repository.INSTANCE.accept(new FormattingVisitor(format, resp.getWriter()));
-        } finally {
-            RenderingContext.clear();
-        }
+        response.setContentType(format.type());
+        return format;
     }
 }

Added: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ResetHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ResetHandler.java?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ResetHandler.java (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/handler/ResetHandler.java Mon Jul 29 13:47:39 2013
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.reporting.web.handler;
+
+import org.apache.commons.monitoring.repositories.Repository;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ResetHandler extends RedirectHandler {
+    @Override
+    public Renderer handle(final HttpServletRequest request, final HttpServletResponse response) {
+        Repository.INSTANCE.reset();
+        return super.handle(request, response);
+    }
+
+    @Override
+    public String from() {
+        return "reset";
+    }
+
+    @Override
+    public String to() {
+        return "report";
+    }
+}

Copied: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/util/HttpUtils.java (from r1507950, commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/HttpUtils.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/util/HttpUtils.java?p2=commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/util/HttpUtils.java&p1=commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/HttpUtils.java&r1=1507950&r2=1508066&rev=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/HttpUtils.java (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/util/HttpUtils.java Mon Jul 29 13:47:39 2013
@@ -15,9 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.commons.monitoring.reporting.web;
+package org.apache.commons.monitoring.reporting.web.util;
 
-public class HttpUtils {
+public final class HttpUtils {
 
     public static String parseAccept(String header) {
         return getPrefered(header);
@@ -56,4 +56,7 @@ public class HttpUtils {
         return 1;
     }
 
+    private HttpUtils() {
+        // no-op
+    }
 }



Mime
View raw message