You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ni...@apache.org on 2008/03/06 12:41:41 UTC

svn commit: r634228 [2/2] - in /commons/sandbox/monitoring/trunk: ./ src/main/java/org/apache/commons/monitoring/ src/main/java/org/apache/commons/monitoring/aop/ src/main/java/org/apache/commons/monitoring/impl/monitors/ src/main/java/org/apache/commo...

Added: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringFilter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringFilter.java?rev=634228&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringFilter.java (added)
+++ commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringFilter.java Thu Mar  6 03:41:35 2008
@@ -0,0 +1,166 @@
+/*
+ * 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.servlet;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.monitoring.Monitor;
+import org.apache.commons.monitoring.Repository;
+import org.apache.commons.monitoring.StopWatch;
+
+/**
+* A servlet Options to be configured in your WEB-INF/web.xml to intercept all
+ * incoming request.
+ *
+ * <pre>
+ *         &lt;filter&gt;
+ *         &lt;filter-name&gt;Monitoring&lt;/filter-name&gt;
+ *         &lt;filter-class&gt;org.apache.commons.monitoring.servlet.MonitoringFilter&lt;/filter-class&gt;
+ *         &lt;/filter&gt;
+ *         &lt;filter-mapping&gt;
+ *         &lt;filter-name&gt;Monitoring&lt;/filter-name&gt;
+ *         &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
+ *         &lt;/filter-mapping&gt;
+ * </pre>
+ *
+ * <p>
+ * A monitor will be created for each application URI. The requested resource extension
+ * is used to determine the category.
+ *
+ * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
+ */
+public class MonitoringFilter
+    implements Filter
+{
+
+    private Repository repository;
+
+    private Map<String, String> categories = new ConcurrentHashMap<String, String>();
+
+    public void registerCategoryForExtension( String extension, String category )
+    {
+        categories.put( extension, category );
+    }
+
+    /**
+     * Delegates to Http based doFilter. {@inheritDoc}
+     *
+     * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
+     * javax.servlet.ServletResponse, javax.servlet.FilterChain)
+     */
+    public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain )
+        throws IOException, ServletException
+    {
+        if ( request instanceof HttpServletRequest )
+        {
+            HttpServletRequest httpRequest = (HttpServletRequest) request;
+            HttpServletResponse httpResponse = (HttpServletResponse) response;
+            doFilter( httpRequest, httpResponse, chain );
+        }
+        else
+        {
+            // Not an HTTP request...
+            chain.doFilter( request, response );
+        }
+    }
+
+    public void doFilter( HttpServletRequest request, HttpServletResponse response,
+                          FilterChain chain )
+        throws IOException, ServletException
+    {
+        String uri = getRequestedUri( request );
+        String category = getCategory( uri );
+        Monitor monitor = repository.getMonitor( uri, category );
+
+        StopWatch stopWatch = repository.start( monitor );
+        try
+        {
+            chain.doFilter( request, response );
+        }
+        finally
+        {
+            stopWatch.stop();
+        }
+    }
+
+    /**
+     * @param request
+     * @return
+     */
+    protected String getRequestedUri( HttpServletRequest request )
+    {
+        String uri = request.getRequestURI();
+        String context = request.getContextPath();
+        uri = uri.substring( context.length() );
+        return uri;
+    }
+
+    /**
+     * @param uri
+     * @return
+     */
+    protected String getCategory( String uri )
+    {
+        int i = uri.lastIndexOf( "." );
+        if ( i > 0 )
+        {
+            return categories.get( uri.substring( i ) );
+        }
+        return categories.get( "other" );
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
+     */
+    public void init( FilterConfig config )
+        throws ServletException
+    {
+        repository = ServletContextUtil.getRepository( config.getServletContext() );
+        registerCategoryForExtension( ".do", "struts" );
+        registerCategoryForExtension( ".action", "struts2" );
+        registerCategoryForExtension( ".jsf", "jsf" );
+        registerCategoryForExtension( ".js", "static" );
+        registerCategoryForExtension( ".html", "static" );
+        registerCategoryForExtension( ".css", "static" );
+        registerCategoryForExtension( ".gif", "static" );
+        registerCategoryForExtension( ".png", "static" );
+        registerCategoryForExtension( ".jpg", "static" );
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see javax.servlet.Filter#destroy()
+     */
+    public void destroy()
+    {
+        // Nop
+    }
+
+}

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringListener.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringListener.java?rev=634228&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringListener.java (added)
+++ commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringListener.java Thu Mar  6 03:41:35 2008
@@ -0,0 +1,88 @@
+/*
+ * 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.servlet;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.commons.monitoring.Monitoring;
+import org.apache.commons.monitoring.Repository;
+import org.apache.commons.monitoring.impl.repositories.DefaultRepository;
+
+/**
+ * A Servlet Context Listener to configure Monitoring
+ *
+ * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
+ */
+public class MonitoringListener
+    implements ServletContextListener
+{
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
+     */
+    public void contextInitialized( ServletContextEvent event )
+    {
+        Repository repository;
+        String name = event.getServletContext().getInitParameter( ServletContextUtil.REPOSITORY_KEY );
+        if ( name != null )
+        {
+            try
+            {
+                Class repositoryClass = Class.forName( name );
+                if ( !Repository.class.isAssignableFrom( repositoryClass ) )
+                {
+                    throw new IllegalStateException( "The class " + name + " does not implements "
+                        + Repository.class.getName() );
+                }
+                repository = (Repository) repositoryClass.newInstance();
+            }
+            catch ( ClassNotFoundException e )
+            {
+                throw new IllegalStateException( "The repository class name " + name + " is not a valid class" );
+            }
+            catch ( InstantiationException e )
+            {
+                throw new IllegalStateException( "Failed to create repository instance from class " + name, e );
+            }
+            catch ( IllegalAccessException e )
+            {
+                throw new IllegalStateException( "Failed to create repository instance from class " + name, e );
+            }
+        }
+        else
+        {
+            repository = new DefaultRepository();
+        }
+        event.getServletContext().setAttribute( ServletContextUtil.REPOSITORY_KEY, repository );
+        Monitoring.setRepository( repository );
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
+     */
+    public void contextDestroyed( ServletContextEvent event )
+    {
+        // TODO Auto-generated method stub
+
+    }
+}

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/MonitoringListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/ServletContextUtil.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/ServletContextUtil.java?rev=634228&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/ServletContextUtil.java (added)
+++ commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/ServletContextUtil.java Thu Mar  6 03:41:35 2008
@@ -0,0 +1,55 @@
+/*
+ * 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.servlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.commons.monitoring.Monitoring;
+import org.apache.commons.monitoring.Repository;
+
+/**
+ *
+ * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
+ */
+public class ServletContextUtil
+{
+    /** key for Repository as ServletContext attribute */
+    public static final String REPOSITORY_KEY = Repository.class.getName();
+
+    public static Repository getRepository( ServletContext context )
+        throws ServletException
+    {
+        Object attribute = context.getAttribute( REPOSITORY_KEY );
+        if ( attribute != null )
+        {
+            if ( attribute instanceof Repository )
+            {
+                return (Repository) attribute;
+            }
+            else
+            {
+                throw new ServletException( "Attribute " + REPOSITORY_KEY + " in servletContext is not a Repository" );
+            }
+        }
+        else
+        {
+            return Monitoring.getRepository();
+        }
+    }
+}

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/ServletContextUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/ServletContextUtil.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/servlet/ServletContextUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/support/java13/java/util/_Collections.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/support/java13/java/util/_Collections.java?rev=634228&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/support/java13/java/util/_Collections.java (added)
+++ commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/support/java13/java/util/_Collections.java Thu Mar  6 03:41:35 2008
@@ -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.support.java13.java.util;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
+ */
+public class _Collections
+{
+    public static List emptyList()
+    {
+        return Collections.EMPTY_LIST;
+    }
+}

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/support/java13/java/util/_Collections.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/support/java13/java/util/_Collections.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/support/java13/java/util/_Collections.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/sandbox/monitoring/trunk/src/main/resources/commons-monitoring.css
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/resources/commons-monitoring.css?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/resources/commons-monitoring.css (original)
+++ commons/sandbox/monitoring/trunk/src/main/resources/commons-monitoring.css Thu Mar  6 03:41:35 2008
@@ -25,13 +25,15 @@
     background-color: #fff;
 }
 table {
-    font-family:arial;
+    border:none;
+    font-family: arial, sans-serif;
     background-color: #cdcdcd;
     text-align: left;
     border-spacing: 1px;
 }
 
 th, td {
+    border:none;
     font-size: 0.8em;
 }
 
@@ -67,3 +69,10 @@
 thead th.headerSortDown {
     background: #8dbdd8 no-repeat center right url( "desc.gif ");
 }
+
+.unit select {
+    color: #8dbdd8;
+    cursor: pointer;
+    border: solid 1px #8dbdd8;
+    font-size: 0.8em;
+}
\ No newline at end of file

Modified: commons/sandbox/monitoring/trunk/src/main/resources/commons-monitoring.js
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/resources/commons-monitoring.js?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/resources/commons-monitoring.js (original)
+++ commons/sandbox/monitoring/trunk/src/main/resources/commons-monitoring.js Thu Mar  6 03:41:35 2008
@@ -16,7 +16,14 @@
  */
 
 $(document).ready(function()
+{
+    $("#monitoring").tablesorter( { widgets: ['zebra'] } );
+    // TODO add a select unit feature, as ns are far too precise in many cases
+    /* $("#monitoring thead td .unit").each( function()
     {
-        $("#monitoring").tablesorter( { widgets: ['zebra'] } );
-    }
-);
\ No newline at end of file
+    	if ($(this).text() === "ns")
+    	{
+    		$(this).html( "<select><option>ns</option><option>µs</option><option>ms</option><option>s</option></select>" );
+    	}
+    } ); */
+} );
\ No newline at end of file

Modified: commons/sandbox/monitoring/trunk/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/webapp/WEB-INF/web.xml?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/webapp/WEB-INF/web.xml (original)
+++ commons/sandbox/monitoring/trunk/src/main/webapp/WEB-INF/web.xml Thu Mar  6 03:41:35 2008
@@ -20,6 +20,21 @@
 
 <web-app>
 
+    <filter>
+        <filter-name>Monitoring</filter-name>
+        <filter-class>org.apache.commons.monitoring.servlet.MonitoringFilter</filter-class>
+    </filter>
+
+    <filter-mapping>
+        <filter-name>Monitoring</filter-name>
+        <url-pattern>*.do</url-pattern>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>Monitoring</filter-name>
+        <url-pattern>*.action</url-pattern>
+    </filter-mapping>
+
     <servlet>
         <servlet-name>monitoring</servlet-name>
         <servlet-class>org.apache.commons.monitoring.reporting.web.WebUIServlet</servlet-class>

Added: commons/sandbox/monitoring/trunk/src/main/webapp/WEB-INF/webdefault.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/webapp/WEB-INF/webdefault.xml?rev=634228&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/webapp/WEB-INF/webdefault.xml (added)
+++ commons/sandbox/monitoring/trunk/src/main/webapp/WEB-INF/webdefault.xml Thu Mar  6 03:41:35 2008
@@ -0,0 +1,403 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- ===================================================================== -->
+<!-- This file contains the default descriptor for web applications.       -->
+<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+<!-- The intent of this descriptor is to include jetty specific or common  -->
+<!-- configuration for all webapps.   If a context has a webdefault.xml    -->
+<!-- descriptor, it is applied before the contexts own web.xml file        -->
+<!--                                                                       -->
+<!-- A context may be assigned a default descriptor by:                    -->
+<!--  + Calling WebApplicationContext.setDefaultsDescriptor                -->
+<!--  + Passed an arg to addWebApplications                                -->
+<!--                                                                       -->
+<!-- This file is used both as the resource within the jetty.jar (which is -->
+<!-- used as the default if no explicit defaults descriptor is set) and it -->
+<!-- is copied to the etc directory of the Jetty distro and explicitly     -->
+<!-- by the jetty.xml file.                                                -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+<web-app
+   xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+   metadata-complete="true"
+   version="2.5">
+
+  <description>
+    Default web.xml file.
+    This file is applied to a Web application before it's own WEB_INF/web.xml file
+  </description>
+
+
+  <!-- ==================================================================== -->
+  <!-- Context params to control Session Cookies                            -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <!-- UNCOMMENT TO ACTIVATE
+  <context-param>
+    <param-name>org.mortbay.jetty.servlet.SessionDomain</param-name>
+    <param-value>127.0.0.1</param-value>
+  </context-param>
+
+  <context-param>
+    <param-name>org.mortbay.jetty.servlet.SessionPath</param-name>
+    <param-value>/</param-value>
+  </context-param>
+
+  <context-param>
+    <param-name>org.mortbay.jetty.servlet.MaxAge</param-name>
+    <param-value>-1</param-value>
+  </context-param>
+  -->
+
+  <context-param>
+    <param-name>org.mortbay.jetty.webapp.NoTLDJarPattern</param-name>
+    <param-value>start.jar|ant-.*\.jar|dojo-.*\.jar|jetty-.*\.jar|jsp-api-.*\.jar|junit-.*\.jar|servlet-api-.*\.jar|dnsns\.jar|rt\.jar|jsse\.jar|tools\.jar|sunpkcs11\.jar|sunjce_provider\.jar|xerces.*\.jar</param-value>
+  </context-param>
+
+
+
+  <!-- ==================================================================== -->
+  <!-- The default servlet.                                                 -->
+  <!-- This servlet, normally mapped to /, provides the handling for static -->
+  <!-- content, OPTIONS and TRACE methods for the context.                  -->
+  <!-- The following initParameters are supported:                          -->
+  <!--                                                                      -->
+  <!--   acceptRanges     If true, range requests and responses are         -->
+  <!--                    supported                                         -->
+  <!--                                                                      -->
+  <!--   dirAllowed       If true, directory listings are returned if no    -->
+  <!--                    welcome file is found. Else 403 Forbidden.        -->
+  <!--                                                                      -->
+  <!--   redirectWelcome  If true, redirect welcome file requests           -->
+  <!--                    else use request dispatcher forwards              -->
+  <!--                                                                      -->
+  <!--   gzip             If set to true, then static content will be served-->
+  <!--                    as gzip content encoded if a matching resource is -->
+  <!--                    found ending with ".gz"                           -->
+  <!--                                                                      -->
+  <!--   resoureBase      Can be set to replace the context resource base   -->
+  <!--                                                                      -->
+  <!--   relativeResourceBase                                               -->
+  <!--                    Set with a pathname relative to the base of the   -->
+  <!--                    servlet context root. Useful for only serving     -->
+  <!--                    static content from only specific subdirectories. -->
+  <!--                                                                      -->
+  <!--   useFileMappedBuffer                                                -->
+  <!--                    If set to true (the default), a  memory mapped    -->
+  <!--                    file buffer will be used to serve static content  -->
+  <!--                    when using an NIO connector. Setting this value   -->
+  <!--                    to false means that a direct buffer will be used  -->
+  <!--                    instead. If you are having trouble with Windows   -->
+  <!--                    file locking, set this to false.                  -->
+  <!--                                                                      -->
+  <!--  cacheControl      If set, all static content will have this value   -->
+  <!--                    set as the cache-control header.                  -->
+  <!--                                                                      -->
+  <!--  maxCacheSize      Maximum size of the static resource cache         -->
+  <!--                                                                      -->
+  <!--  maxCachedFileSize Maximum size of any single file in the cache      -->
+  <!--                                                                      -->
+  <!--  maxCachedFiles    Maximum number of files in the cache              -->
+  <!--                                                                      -->
+  <!--  cacheType         "nio", "bio" or "both" to determine the type(s)   -->
+  <!--                    of resource cache. A bio cached buffer may be used-->
+  <!--                    by nio but is not as efficient as a nio buffer.   -->
+  <!--                    An nio cached buffer may not be used by bio.      -->
+  <!--                                                                      -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <servlet>
+    <servlet-name>default</servlet-name>
+    <servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class>
+    <init-param>
+      <param-name>acceptRanges</param-name>
+      <param-value>true</param-value>
+    </init-param>
+    <init-param>
+      <param-name>dirAllowed</param-name>
+      <param-value>true</param-value>
+    </init-param>
+    <init-param>
+      <param-name>redirectWelcome</param-name>
+      <param-value>false</param-value>
+    </init-param>
+    <init-param>
+      <param-name>maxCacheSize</param-name>
+      <param-value>4000000</param-value>
+    </init-param>
+    <init-param>
+      <param-name>maxCachedFileSize</param-name>
+      <param-value>254000</param-value>
+    </init-param>
+    <init-param>
+      <param-name>maxCachedFiles</param-name>
+      <param-value>1000</param-value>
+    </init-param>
+    <init-param>
+      <param-name>cacheType</param-name>
+      <param-value>both</param-value>
+    </init-param>
+    <init-param>
+      <param-name>gzip</param-name>
+      <param-value>true</param-value>
+    </init-param>
+    <init-param>
+      <!-- @see http://docs.codehaus.org/display/JETTY/Files+locked+on+Windows -->
+      <param-name>useFileMappedBuffer</param-name>
+      <param-value>false</param-value>
+    </init-param>
+    <!--
+    <init-param>
+      <param-name>cacheControl</param-name>
+      <param-value>max-age=3600,public</param-value>
+    </init-param>
+    -->
+    <load-on-startup>0</load-on-startup>
+  </servlet>
+
+  <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
+
+
+  <!-- ==================================================================== -->
+  <!-- JSP Servlet                                                          -->
+  <!-- This is the jasper JSP servlet from the jakarta project              -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <!-- The JSP page compiler and execution servlet, which is the mechanism  -->
+  <!-- used by Glassfish to support JSP pages.  Traditionally, this servlet -->
+  <!-- is mapped to URL patterh "*.jsp".  This servlet supports the         -->
+  <!-- following initialization parameters (default values are in square    -->
+  <!-- brackets):                                                           -->
+  <!--                                                                      -->
+  <!--   checkInterval       If development is false and reloading is true, -->
+  <!--                       background compiles are enabled. checkInterval -->
+  <!--                       is the time in seconds between checks to see   -->
+  <!--                       if a JSP page needs to be recompiled. [300]    -->
+  <!--                                                                      -->
+  <!--   compiler            Which compiler Ant should use to compile JSP   -->
+  <!--                       pages.  See the Ant documenation for more      -->
+  <!--                       information. [javac]                           -->
+  <!--                                                                      -->
+  <!--   classdebuginfo      Should the class file be compiled with         -->
+  <!--                       debugging information?  [true]                 -->
+  <!--                                                                      -->
+  <!--   classpath           What class path should I use while compiling   -->
+  <!--                       generated servlets?  [Created dynamically      -->
+  <!--                       based on the current web application]          -->
+  <!--                       Set to ? to make the container explicitly set  -->
+  <!--                       this parameter.                                -->
+  <!--                                                                      -->
+  <!--   development         Is Jasper used in development mode (will check -->
+  <!--                       for JSP modification on every access)?  [true] -->
+  <!--                                                                      -->
+  <!--   enablePooling       Determines whether tag handler pooling is      -->
+  <!--                       enabled  [true]                                -->
+  <!--                                                                      -->
+  <!--   fork                Tell Ant to fork compiles of JSP pages so that -->
+  <!--                       a separate JVM is used for JSP page compiles   -->
+  <!--                       from the one Tomcat is running in. [true]      -->
+  <!--                                                                      -->
+  <!--   ieClassId           The class-id value to be sent to Internet      -->
+  <!--                       Explorer when using <jsp:plugin> tags.         -->
+  <!--                       [clsid:8AD9C840-044E-11D1-B3E9-00805F499D93]   -->
+  <!--                                                                      -->
+  <!--   javaEncoding        Java file encoding to use for generating java  -->
+  <!--                       source files. [UTF-8]                          -->
+  <!--                                                                      -->
+  <!--   keepgenerated       Should we keep the generated Java source code  -->
+  <!--                       for each page instead of deleting it? [true]   -->
+  <!--                                                                      -->
+  <!--   logVerbosityLevel   The level of detailed messages to be produced  -->
+  <!--                       by this servlet.  Increasing levels cause the  -->
+  <!--                       generation of more messages.  Valid values are -->
+  <!--                       FATAL, ERROR, WARNING, INFORMATION, and DEBUG. -->
+  <!--                       [WARNING]                                      -->
+  <!--                                                                      -->
+  <!--   mappedfile          Should we generate static content with one     -->
+  <!--                       print statement per input line, to ease        -->
+  <!--                       debugging?  [false]                            -->
+  <!--                                                                      -->
+  <!--                                                                      -->
+  <!--   reloading           Should Jasper check for modified JSPs?  [true] -->
+  <!--                                                                      -->
+  <!--   suppressSmap        Should the generation of SMAP info for JSR45   -->
+  <!--                       debugging be suppressed?  [false]              -->
+  <!--                                                                      -->
+  <!--   dumpSmap            Should the SMAP info for JSR45 debugging be    -->
+  <!--                       dumped to a file? [false]                      -->
+  <!--                       False if suppressSmap is true                  -->
+  <!--                                                                      -->
+  <!--   scratchdir          What scratch directory should we use when      -->
+  <!--                       compiling JSP pages?  [default work directory  -->
+  <!--                       for the current web application]               -->
+  <!--                                                                      -->
+  <!--   tagpoolMaxSize      The maximum tag handler pool size  [5]         -->
+  <!--                                                                      -->
+  <!--   xpoweredBy          Determines whether X-Powered-By response       -->
+  <!--                       header is added by generated servlet  [false]  -->
+  <!--                                                                      -->
+  <!-- If you wish to use Jikes to compile JSP pages:                       -->
+  <!--   Set the init parameter "compiler" to "jikes".  Define              -->
+  <!--   the property "-Dbuild.compiler.emacs=true" when starting Jetty     -->
+  <!--   to cause Jikes to emit error messages in a format compatible with  -->
+  <!--   Jasper.                                                            -->
+  <!--   If you get an error reporting that jikes can't use UTF-8 encoding, -->
+  <!--   try setting the init parameter "javaEncoding" to "ISO-8859-1".     -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <servlet id="jsp">
+    <servlet-name>jsp</servlet-name>
+    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
+    <init-param>
+        <param-name>logVerbosityLevel</param-name>
+        <param-value>DEBUG</param-value>
+    </init-param>
+    <init-param>
+        <param-name>fork</param-name>
+        <param-value>false</param-value>
+    </init-param>
+    <init-param>
+        <param-name>xpoweredBy</param-name>
+        <param-value>false</param-value>
+    </init-param>
+    <!--
+    <init-param>
+        <param-name>classpath</param-name>
+        <param-value>?</param-value>
+    </init-param>
+    -->
+    <load-on-startup>0</load-on-startup>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>jsp</servlet-name>
+    <url-pattern>*.jsp</url-pattern>
+    <url-pattern>*.jspf</url-pattern>
+    <url-pattern>*.jspx</url-pattern>
+    <url-pattern>*.xsp</url-pattern>
+    <url-pattern>*.JSP</url-pattern>
+    <url-pattern>*.JSPF</url-pattern>
+    <url-pattern>*.JSPX</url-pattern>
+    <url-pattern>*.XSP</url-pattern>
+  </servlet-mapping>
+
+  <!-- ==================================================================== -->
+  <!-- Dynamic Servlet Invoker.                                             -->
+  <!-- This servlet invokes anonymous servlets that have not been defined   -->
+  <!-- in the web.xml or by other means. The first element of the pathInfo  -->
+  <!-- of a request passed to the envoker is treated as a servlet name for  -->
+  <!-- an existing servlet, or as a class name of a new servlet.            -->
+  <!-- This servlet is normally mapped to /servlet/*                        -->
+  <!-- This servlet support the following initParams:                       -->
+  <!--                                                                      -->
+  <!--  nonContextServlets       If false, the invoker can only load        -->
+  <!--                           servlets from the contexts classloader.    -->
+  <!--                           This is false by default and setting this  -->
+  <!--                           to true may have security implications.    -->
+  <!--                                                                      -->
+  <!--  verbose                  If true, log dynamic loads                 -->
+  <!--                                                                      -->
+  <!--  *                        All other parameters are copied to the     -->
+  <!--                           each dynamic servlet as init parameters    -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <!-- Uncomment for dynamic invocation
+  <servlet>
+    <servlet-name>invoker</servlet-name>
+    <servlet-class>org.mortbay.jetty.servlet.Invoker</servlet-class>
+    <init-param>
+      <param-name>verbose</param-name>
+      <param-value>false</param-value>
+    </init-param>
+    <init-param>
+      <param-name>nonContextServlets</param-name>
+      <param-value>false</param-value>
+    </init-param>
+    <init-param>
+      <param-name>dynamicParam</param-name>
+      <param-value>anyValue</param-value>
+    </init-param>
+    <load-on-startup>0</load-on-startup>
+  </servlet>
+
+  <servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping>
+  -->
+
+
+
+  <!-- ==================================================================== -->
+  <session-config>
+    <session-timeout>30</session-timeout>
+  </session-config>
+
+  <!-- ==================================================================== -->
+  <!-- Default MIME mappings                                                -->
+  <!-- The default MIME mappings are provided by the mime.properties        -->
+  <!-- resource in the org.mortbay.jetty.jar file.  Additional or modified  -->
+  <!-- mappings may be specified here                                       -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <!-- UNCOMMENT TO ACTIVATE
+  <mime-mapping>
+    <extension>mysuffix</extension>
+    <mime-type>mymime/type</mime-type>
+  </mime-mapping>
+  -->
+
+  <!-- ==================================================================== -->
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>index.htm</welcome-file>
+    <welcome-file>index.jsp</welcome-file>
+  </welcome-file-list>
+
+  <!-- ==================================================================== -->
+  <locale-encoding-mapping-list>
+    <locale-encoding-mapping><locale>ar</locale><encoding>ISO-8859-6</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>be</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>bg</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>ca</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>cs</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>da</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>de</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>el</locale><encoding>ISO-8859-7</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>en</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>es</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>et</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>fi</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>fr</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>hr</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>hu</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>is</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>it</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>iw</locale><encoding>ISO-8859-8</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>ja</locale><encoding>Shift_JIS</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>ko</locale><encoding>EUC-KR</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>lt</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>lv</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>mk</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>nl</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>no</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>pl</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>pt</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>ro</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>ru</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sh</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sk</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sl</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sq</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sr</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sv</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>tr</locale><encoding>ISO-8859-9</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>uk</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>zh</locale><encoding>GB2312</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>zh_TW</locale><encoding>Big5</encoding></locale-encoding-mapping>
+  </locale-encoding-mapping-list>
+
+  <security-constraint>
+    <web-resource-collection>
+      <web-resource-name>Disable TRACE</web-resource-name>
+      <url-pattern>/</url-pattern>
+      <http-method>TRACE</http-method>
+    </web-resource-collection>
+    <auth-constraint/>
+  </security-constraint>
+
+</web-app>
+

Propchange: commons/sandbox/monitoring/trunk/src/main/webapp/WEB-INF/webdefault.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/monitoring/trunk/src/main/webapp/WEB-INF/webdefault.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: commons/sandbox/monitoring/trunk/src/site/xdoc/instrumentation.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/site/xdoc/instrumentation.xml?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/site/xdoc/instrumentation.xml (original)
+++ commons/sandbox/monitoring/trunk/src/site/xdoc/instrumentation.xml Thu Mar  6 03:41:35 2008
@@ -106,10 +106,25 @@
             // Process a SOAP message
 
             // retrieve the custom Counter for the "byte" role
-            monitor.getCounter( "bytes" ).add( SOAPMessage.getSize() );
+            monitor.getCounter( "bytes" ).add( SOAPMessage.getSize(), Unit.BYTES );
         </pre>
       </p>
       </subsection>
+      <subsection name="Units">
+        <p>Counters and Gauge knows the data type they hold : when a first value is set/added to
+        a StatValue, it's internal Unit is set. Any other change/addition is checked for unit to
+        be compatible. "compatible" means the passed values can be converted to the same primary
+        unit. Units are defined using the <code>org.apache.commons.monitoring.Unit</code> class.
+        Any Unit has a primary unit, and the primary unit is its own primary. Two units are
+        compatible if they share the same primary unit. Units are for example <code>Unit.SECONDS</code>
+        that is compatible with <code>Unit.MILLIS</code> as they share the same primary unit
+        <code>Unit.NANOS</code>.
+        </p>
+        <p>
+        You can define your own units on the same basis, to ensure good usage of your monitors
+        and cleaner reporting.
+        </p>
+      </subsection>
       <subsection name="StopWatches">
       <p>Performance monitoring is first-class use case of Commons Monitoring. The
         <code>org.apache.commons.monitoring.StopWatch</code> class provides the necessary tooling
@@ -132,13 +147,6 @@
       <p>
         You can nest stopWatches, in many case by monitoring some high-level process (for example web
         request rendering time) and nested low-level service (remote service invocation, JDBC request...).
-        The StopWatch provides two methods for executed code performance :
-        <ul>
-            <li><code>getElapsedTime()</code> returns the time (in ns) elapsed between the stopWatch creation
-            and the moment it was stopped, including any other sub-process</li>
-            <li><code>getRunningTime()</code> returns same time MINUS time elapsed in StopWatches that
-            monitor sub-processes.</li>
-        </ul>
         The monitor maintains statistics about those informations as the PERFORMANCE and RESPONSE_TIME
         counters. First one only computes performance of the target code, not sub-processes.
       </p>

Added: commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml?rev=634228&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml (added)
+++ commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml Thu Mar  6 03:41:35 2008
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+
+<document>
+
+<properties>
+    <title>use in a web applications</title>
+  </properties>
+
+  <body>
+
+    <section name="Web application">
+      <p>
+        Monitoring provides support for servlet based web applications.
+      </p>
+      <subsection name="MonitoringFilter">
+      <p>
+        The monitoringFilter is a Servlet Filter to compute HTTP request serving performance. Simply add
+        the following configuration to your <tt>WEB-INF/web.xml</tt> :
+         <pre>
+    &lt;filter&gt;
+        &lt;filter-name&gt;Monitoring&lt;/filter-name&gt;
+        &lt;filter-class&gt;org.apache.commons.monitoring.servlet.MonitoringFilter&lt;/filter-class&gt;
+    &lt;/filter&gt;
+
+    &lt;filter-mapping&gt;
+        &lt;filter-name&gt;Monitoring&lt;/filter-name&gt;
+        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
+    &lt;/filter-mapping&gt;
+         </pre>
+        Any incoming request will then be monitored and added to the repository.
+        The monitor name is the requested URI path, and the extension is used to select a category.
+      </p>
+      </subsection>
+      <subsection name="MonitoringServlet">
+      <p>
+        The monitoring serlvet give you access to the active repository. Using a selector path, you
+        can select a set of monitors and get it rendered in any supported format (HTML, XML, JSON, ...).
+        The selector path is a simple String to point to the expected objects :
+        <ul>
+          <li><tt>/monitors</tt> will select all monitors in the repository.</li>
+          <li><tt>/monitorsFromCategory/services</tt> will select all monitors for the category "services".</li>
+          <li><tt>/monitorsFromSubsystem/admin</tt> will select all monitors for the subsystem "admin".</li>
+        </ul>
+      </p>
+      <p>
+        The monitoring serlvet also accepts parameter to filter the result :
+        <ul>
+          <li>Adding <tt>?format=html</tt> will force the output to be formatted in HTML. By default the
+          user-agent <tt>accept</tt> header is used to find a valid renderer, but this may produce</li>
+          <li>Adding <tt>?role=performances</tt> will select the "performances" counter to get included in
+          the output. By default all roles are displayed. If some <tt>role</tt> parameter is set in the
+          URI, only those roles are displayed</li>
+          <li>Addind <tt>?performances.value=false</tt> will remove the "current value" column from the
+          output.</li>
+          <li>Adding <tt>?performances.unit=ms</tt> will format the "performances" counter values to use
+          milliseconds as data unit. The parameter value must be a valid derived unit from the counter unit.
+          For time based counters, this includes <tt>ns</tt> (nanoseconds), <tt>µs</tt> (microseconds),
+          <tt>ms</tt> (milliseconds), <tt>s</tt> (seconds) ... Please refer to the
+          <code>org.apache.commons.monitoring.Unit</code> javadoc for more infos on units.</li>
+        </ul>
+        By combining the request URI path and parameters, you can filter what is relevant for you. Bookmark
+        the valuable URIs ! Example :
+        <tt>http://myserver/monitoring/monitors?performances.unit=ms&performances.value=false&performances.sum=false</tt>
+      </p>
+      </subsection>
+      <subsection name="Web UI">
+      <p>
+        The WebUI Servlet extends the monitoring serlvet and the HtmlRenderer to provide a simple
+        Web UI. It uses the same URI filtering as MonitoringServlet, but also includes some
+        CSS to render nicer and <a href="http://www.jquery.com">JQuery</a> to sort data.
+      </p>
+      </subsection>
+    </section>
+
+  </body>
+
+</document>

Propchange: commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/MonitoringTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/MonitoringTest.java?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/MonitoringTest.java (original)
+++ commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/MonitoringTest.java Thu Mar  6 03:41:35 2008
@@ -68,8 +68,8 @@
                     for ( int j = 0; j < loops; j++ )
                     {
                         Monitor monitor = Monitoring.getMonitor( "MonitoringTest.testMultiThreading", "test", "utils" );
-                        monitor.getCounter( "COUNTER" ).add( 1 );
-                        monitor.getGauge( "GAUGE" ).increment();
+                        monitor.getCounter( "COUNTER" ).add( 1, Unit.NONE );
+                        monitor.getGauge( "GAUGE" ).increment(Unit.NONE);
                     }
                     try
                     {

Added: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/UnitTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/UnitTest.java?rev=634228&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/UnitTest.java (added)
+++ commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/UnitTest.java Thu Mar  6 03:41:35 2008
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
+ */
+public class UnitTest
+    extends TestCase
+{
+    public void testScales()
+        throws Exception
+    {
+        assertEquals( Unit.NANOS, Unit.HOUR.getPrimary() );
+        assertEquals( Unit.NANOS, Unit.NANOS.getDerived( "ns" ) );
+        assertEquals( Unit.MICROS, Unit.NANOS.getDerived( "µs" ) );
+        assertEquals( Unit.MILLIS, Unit.NANOS.getDerived( "ms" ) );
+        assertEquals( Unit.SECOND, Unit.NANOS.getDerived( "s" ) );
+    }
+}

Propchange: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/UnitTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/UnitTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/UnitTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/CompositeValuesMonitorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/CompositeValuesMonitorTest.java?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/CompositeValuesMonitorTest.java (original)
+++ commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/CompositeValuesMonitorTest.java Thu Mar  6 03:41:35 2008
@@ -21,6 +21,7 @@
 import org.apache.commons.monitoring.Counter;
 import org.apache.commons.monitoring.Gauge;
 import org.apache.commons.monitoring.Monitor;
+import org.apache.commons.monitoring.Unit;
 import org.apache.commons.monitoring.impl.monitors.CompositeValuesMonitor;
 
 import junit.framework.TestCase;
@@ -40,7 +41,7 @@
     {
         Monitor monitor = new CompositeValuesMonitor( new Monitor.Key( "MonitorTest.testReset", "test", "utils" ) );
         Counter counter = monitor.getCounter( Monitor.PERFORMANCES );
-        counter.add( 1 );
+        counter.add( 1, Unit.NANOS );
         assertEquals( 1, counter.get() );
 
         monitor.reset();
@@ -54,22 +55,22 @@
         Counter counter = monitor.getCounter( "COUNTER" );
         Composite<Counter> composite = (Composite<Counter>) counter;
 
-        counter.add( 1 );
+        counter.add( 1, Unit.NANOS );
         assertEquals( 1, counter.get() );
 
         Counter secondary = composite.createSecondary();
         assertEquals( 0, secondary.get() );
 
-        counter.add( 1 );
+        counter.add( 1, Unit.NANOS );
         assertEquals( 2, counter.get() );
         assertEquals( 1, secondary.get() );
 
-        counter.set( 3 );
+        counter.set( 3, Unit.NANOS );
         assertEquals( 3, counter.get() );
         assertEquals( 3, secondary.get() );
 
         composite.removeSecondary( secondary );
-        counter.add( 1 );
+        counter.add( 1, Unit.NANOS );
         assertEquals( 4, counter.get() );
         assertEquals( 3, secondary.get() );
     }
@@ -81,33 +82,33 @@
         Gauge gauge = monitor.getGauge( "GAUGE" );
         Composite<Gauge> composite = (Composite<Gauge>) gauge;
 
-        gauge.increment();
+        gauge.increment(Unit.NONE);
         assertEquals( 1, gauge.get() );
         Gauge secondary = composite.createSecondary();
         assertEquals( 1, secondary.get() );
 
-        gauge.increment();
+        gauge.increment(Unit.NONE);
         assertEquals( 2, gauge.get() );
         assertEquals( 2, secondary.get() );
 
-        gauge.set( 3 );
+        gauge.set( 3, Unit.NONE );
         assertEquals( 3, gauge.get() );
         assertEquals( 3, secondary.get() );
 
-        gauge.add( 2 );
+        gauge.add( 2, Unit.NONE );
         assertEquals( 5, gauge.get() );
         assertEquals( 5, secondary.get() );
 
-        gauge.increment();
+        gauge.increment(Unit.NONE);
         assertEquals( 6, gauge.get() );
         assertEquals( 6, secondary.get() );
 
-        gauge.decrement();
+        gauge.decrement(Unit.NONE);
         assertEquals( 5, gauge.get() );
         assertEquals( 5, secondary.get() );
 
         composite.removeSecondary( secondary );
-        gauge.decrement();
+        gauge.decrement(Unit.NONE);
         assertEquals( 4, gauge.get() );
         assertEquals( 5, secondary.get() );
     }

Modified: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/ThreadSafeCounterTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/ThreadSafeCounterTest.java?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/ThreadSafeCounterTest.java (original)
+++ commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/ThreadSafeCounterTest.java Thu Mar  6 03:41:35 2008
@@ -20,6 +20,7 @@
 import junit.framework.TestCase;
 
 import org.apache.commons.monitoring.Counter;
+import org.apache.commons.monitoring.Unit;
 import org.apache.commons.monitoring.impl.values.ThreadSafeCounter;
 
 public class ThreadSafeCounterTest
@@ -31,17 +32,17 @@
     {
         Counter counter = new ThreadSafeCounter( "test" );
 
-        counter.set( 1 );
+        counter.set( 1, Unit.NONE );
         assertEquals( 1, counter.getMin() );
         assertEquals( 1, counter.getMax() );
         assertEquals( 1, counter.get() );
 
-        counter.add( 10 );
+        counter.add( 10, Unit.NONE );
         assertEquals( 1, counter.getMin() );
         assertEquals( 10, counter.getMax() );
         assertEquals( 11, counter.get() );
 
-        counter.add( -2 );
+        counter.add( -2, Unit.NONE );
         assertEquals( -2, counter.getMin() );
         assertEquals( 10, counter.getMax() );
         assertEquals( 9, counter.get() );
@@ -50,5 +51,28 @@
         assertEquals( 3.0D, counter.getMean(), 0D );
     }
 
+
+    public void testUnits()
+        throws Exception
+    {
+        Counter counter = new ThreadSafeCounter( "test" );
+        assertNull( counter.getUnit() );
+        counter.set( 10, Unit.NANOS );
+        assertEquals( Unit.NANOS, counter.getUnit() );
+        assertEquals( 10, counter.get() );
+        counter.set( 10, Unit.SECOND );
+        assertEquals( Unit.NANOS, counter.getUnit() );
+        assertEquals( 10000000000L, counter.get() );
+
+        try
+        {
+            counter.add( 1, Unit.NONE );
+            fail( "incompatible unit not detected" );
+        }
+        catch (IllegalArgumentException e)
+        {
+            // Expected
+        }
+    }
 
 }

Modified: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/ThreadSafeGaugeTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/ThreadSafeGaugeTest.java?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/ThreadSafeGaugeTest.java (original)
+++ commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/impl/ThreadSafeGaugeTest.java Thu Mar  6 03:41:35 2008
@@ -20,6 +20,7 @@
 import junit.framework.TestCase;
 
 import org.apache.commons.monitoring.Gauge;
+import org.apache.commons.monitoring.Unit;
 import org.apache.commons.monitoring.impl.values.ThreadSafeGauge;
 
 public class ThreadSafeGaugeTest
@@ -32,18 +33,18 @@
     {
         Gauge gauge = new ThreadSafeGauge( "test" );
 
-        gauge.set( 1 );
+        gauge.set( 1, Unit.NONE );
         assertEquals( 1, gauge.getMin() );
         assertEquals( 1, gauge.getMax() );
         assertEquals( 1, gauge.get() );
 
-        gauge.increment();
+        gauge.increment(Unit.NONE);
         assertEquals( 1, gauge.getMin() );
         assertEquals( 2, gauge.getMax() );
         assertEquals( 2, gauge.get() );
 
-        gauge.decrement();
-        gauge.decrement();
+        gauge.decrement(Unit.NONE);
+        gauge.decrement(Unit.NONE);
         assertEquals( 0, gauge.getMin() );
         assertEquals( 2, gauge.getMax() );
         assertEquals( 0, gauge.get() );
@@ -72,14 +73,14 @@
         Gauge gauge = new MockTimeGauge( "test" );
 
         time = 0;
-        gauge.increment();
+        gauge.increment(Unit.NONE);
         time++;
-        gauge.increment();
+        gauge.increment(Unit.NONE);
         time++;
         time++;
-        gauge.decrement();
+        gauge.decrement(Unit.NONE);
         time++;
-        gauge.decrement();
+        gauge.decrement(Unit.NONE);
 
         assertEquals( 0, gauge.get() );
         assertEquals( 1.5D, gauge.getMean(), 0D );

Modified: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/listener/SecondaryReposioryTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/listener/SecondaryReposioryTest.java?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/listener/SecondaryReposioryTest.java (original)
+++ commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/listener/SecondaryReposioryTest.java Thu Mar  6 03:41:35 2008
@@ -18,6 +18,7 @@
 package org.apache.commons.monitoring.listener;
 
 import org.apache.commons.monitoring.Repository;
+import org.apache.commons.monitoring.Unit;
 import org.apache.commons.monitoring.impl.repositories.DefaultRepository;
 import org.apache.commons.monitoring.listeners.SecondaryRepository;
 
@@ -34,8 +35,8 @@
         throws Exception
     {
         Repository.Observable primary = new DefaultRepository();
-        primary.getMonitor( "test" ).getCounter( "COUNTER" ).add( 10 );
-        primary.getMonitor( "test" ).getGauge( "GAUGE" ).set( 5 );
+        primary.getMonitor( "test" ).getCounter( "COUNTER" ).add( 10, Unit.NONE );
+        primary.getMonitor( "test" ).getGauge( "GAUGE" ).set( 5, Unit.NONE );
 
         SecondaryRepository secondary = new SecondaryRepository( primary );
         assertNotNull( secondary.getMonitor( "test" ) );
@@ -44,19 +45,19 @@
         assertEquals( 0, secondary.getMonitor( "test" ).getCounter( "COUNTER" ).get() );
         assertEquals( 5, secondary.getMonitor( "test" ).getGauge( "GAUGE" ).get() );
 
-        primary.getMonitor( "test" ).getCounter( "COUNTER" ).add( 10 );
-        primary.getMonitor( "test" ).getGauge( "GAUGE" ).increment();
+        primary.getMonitor( "test" ).getCounter( "COUNTER" ).add( 10, Unit.NONE );
+        primary.getMonitor( "test" ).getGauge( "GAUGE" ).increment(Unit.NONE);
         assertEquals( 10, secondary.getMonitor( "test" ).getCounter( "COUNTER" ).get() );
         assertEquals( 6, secondary.getMonitor( "test" ).getGauge( "GAUGE" ).get() );
 
-        primary.getMonitor( "new" ).getCounter( "COUNTER" ).add( 10 );
+        primary.getMonitor( "new" ).getCounter( "COUNTER" ).add( 10, Unit.NONE );
         assertEquals( 10, secondary.getMonitor( "new" ).getCounter( "COUNTER" ).get() );
 
         secondary.detach();
 
-        primary.getMonitor( "anotherone" ).getCounter( "COUNTER" ).add( 10 );
-        primary.getMonitor( "test" ).getCounter( "COUNTER" ).add( 10 );
-        primary.getMonitor( "test" ).getGauge( "GAUGE" ).increment();
+        primary.getMonitor( "anotherone" ).getCounter( "COUNTER" ).add( 10, Unit.NONE );
+        primary.getMonitor( "test" ).getCounter( "COUNTER" ).add( 10, Unit.NONE );
+        primary.getMonitor( "test" ).getGauge( "GAUGE" ).increment(Unit.NONE);
         assertNull( secondary.getMonitor( "anotherone" ) );
         assertEquals( 30, primary.getMonitor( "test" ).getCounter( "COUNTER" ).get() );
         assertEquals( 10, secondary.getMonitor( "test" ).getCounter( "COUNTER" ).get() );

Modified: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/listener/ThresholdListenerTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/listener/ThresholdListenerTest.java?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/listener/ThresholdListenerTest.java (original)
+++ commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/listener/ThresholdListenerTest.java Thu Mar  6 03:41:35 2008
@@ -22,6 +22,7 @@
 import org.apache.commons.monitoring.Counter;
 import org.apache.commons.monitoring.Monitor;
 import org.apache.commons.monitoring.StatValue;
+import org.apache.commons.monitoring.Unit;
 import org.apache.commons.monitoring.impl.monitors.CreateValuesOnDemandMonitor;
 import org.apache.commons.monitoring.listeners.ThresholdListener;
 
@@ -41,13 +42,13 @@
         TestListener listener = new TestListener( monitor );
         counter.addListener( listener );
 
-        counter.add( 1 );
+        counter.add( 1, Unit.NONE );
         assertEquals( "unexpected listener notification", 0, listener.count );
-        counter.add( 10 );
+        counter.add( 10, Unit.NONE );
         assertEquals( "listener didn't get notified", 1, listener.count );
 
         counter.removeListener( listener );
-        counter.add( 10 );
+        counter.add( 10, Unit.NONE );
         assertEquals( "removed listener was notified", 1, listener.count );
     }
 

Modified: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/reporting/RendererTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/reporting/RendererTest.java?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/reporting/RendererTest.java (original)
+++ commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/reporting/RendererTest.java Thu Mar  6 03:41:35 2008
@@ -26,8 +26,13 @@
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.monitoring.Counter;
 import org.apache.commons.monitoring.Monitor;
+import org.apache.commons.monitoring.StatValue;
+import org.apache.commons.monitoring.Unit;
 import org.apache.commons.monitoring.impl.monitors.CreateValuesOnDemandMonitor;
+import org.apache.commons.monitoring.impl.values.ThreadSafeCounter;
+import org.apache.commons.monitoring.reporting.Renderer.Options;
 
 public class RendererTest
     extends TestCase
@@ -40,13 +45,13 @@
     {
         monitors = new LinkedList<Monitor>();
         Monitor m1 = new CreateValuesOnDemandMonitor( new Monitor.Key( "JsonRendererTest.setUp", "test", "reporting" ) );
-        m1.getCounter( Monitor.PERFORMANCES ).add( 10 );
+        m1.getCounter( Monitor.PERFORMANCES ).add( 10, Unit.NANOS );
         m1.getGauge( Monitor.CONCURRENCY );
         monitors.add( m1 );
 
         Monitor m2 = new CreateValuesOnDemandMonitor( new Monitor.Key( "TestCase", "test", "junit" ) );
         m2.getCounter( Monitor.PERFORMANCES );
-        m2.getGauge( Monitor.CONCURRENCY ).increment();
+        m2.getGauge( Monitor.CONCURRENCY ).increment(Unit.NONE);
         monitors.add( m2 );
     }
 
@@ -72,6 +77,26 @@
         throws Exception
     {
         assertExpectedRendering( new HtmlRenderer(), "html" );
+    }
+
+    public void testOptions()
+        throws Exception
+    {
+        Options options = new OptionsSupport()
+        {
+            public Unit unitFor( StatValue value )
+            {
+                return Unit.MICROS;
+            }
+        };
+
+        AbstractRenderer renderer = new XmlRenderer();
+        Counter counter = new ThreadSafeCounter( "test" );
+        counter.add( 1, Unit.MILLIS );
+        counter.add( 1, Unit.MICROS );
+        StringWriter writer = new StringWriter();
+        renderer.render( new PrintWriter( writer ), counter, "mean", counter.getMean(), options );
+        assertEquals( " mean=\"500.5\"", writer.toString() );
     }
 
     protected void assertExpectedRendering( Renderer renderer, String format )

Modified: commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/reporting/SelectorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/reporting/SelectorTest.java?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/reporting/SelectorTest.java (original)
+++ commons/sandbox/monitoring/trunk/src/test/java/org/apache/commons/monitoring/reporting/SelectorTest.java Thu Mar  6 03:41:35 2008
@@ -24,6 +24,7 @@
 import org.apache.commons.monitoring.Counter;
 import org.apache.commons.monitoring.Monitor;
 import org.apache.commons.monitoring.Repository;
+import org.apache.commons.monitoring.Unit;
 import org.apache.commons.monitoring.impl.repositories.DefaultRepository;
 
 /**
@@ -38,7 +39,7 @@
         Repository repository = new DefaultRepository();
         Selector selector = new Selector( "monitor/test/counter/performances" );
 
-        repository.getMonitor( "test" ).getCounter( Monitor.PERFORMANCES ).add( 1234 );
+        repository.getMonitor( "test" ).getCounter( Monitor.PERFORMANCES ).add( 1234, Unit.NANOS );
 
         Object value = selector.select( repository );
         assertTrue( value instanceof Counter );
@@ -46,13 +47,28 @@
         assertEquals( 1234L, counter.get() );
     }
 
+    public void testCollectionPath()
+        throws Exception
+    {
+        Repository repository = new DefaultRepository();
+        Selector selector = new Selector( "monitors" );
+
+        repository.getMonitor( "test" ).getCounter( Monitor.PERFORMANCES ).add( 1234, Unit.NANOS );
+
+        Object value = selector.select( repository );
+        assertTrue( value instanceof Collection );
+        Collection collection = (Collection) value;
+        assertEquals( 1, collection.size() );
+        assertTrue( collection.iterator().next() instanceof Monitor );
+    }
+
     public void testSinglePathGet()
         throws Exception
     {
         Repository repository = new DefaultRepository();
         Selector selector = new Selector( "monitor/test/counter/performances/" );
 
-        repository.getMonitor( "test" ).getCounter( Monitor.PERFORMANCES ).add( 1234 );
+        repository.getMonitor( "test" ).getCounter( Monitor.PERFORMANCES ).add( 1234, Unit.NANOS );
 
         Object value = selector.select( repository );
         assertEquals( "1234", value.toString() );
@@ -63,8 +79,8 @@
         Repository repository = new DefaultRepository();
         Selector selector = new Selector( "monitors/counter/performances/" );
 
-        repository.getMonitor( "one" ).getCounter( Monitor.PERFORMANCES ).add( 1234 );
-        repository.getMonitor( "two" ).getCounter( Monitor.PERFORMANCES ).add( 5678 );
+        repository.getMonitor( "one" ).getCounter( Monitor.PERFORMANCES ).add( 1234, Unit.NANOS );
+        repository.getMonitor( "two" ).getCounter( Monitor.PERFORMANCES ).add( 5678, Unit.NANOS );
 
         Object value = selector.select( repository );
         assertTrue( value instanceof Collection );

Modified: commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.html
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.html?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.html (original)
+++ commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.html Thu Mar  6 03:41:35 2008
@@ -1,24 +1,31 @@
-<html><body>
-<table>
+<html>
+<body>
+<table border='1'>
 <thead>
-<tr><th rowspan='2'>name</th><th rowspan='2'>category</th>
-<th rowspan='2'>subsystem</th><th colspan='5'>concurrency</th><th colspan='7'>performances</th></tr>
-<tr>
-<th>value</th><th>min</th><th>max</th><th>mean</th><th>dev.</th>
-<th>value</th><th>min</th><th>max</th><th>mean</th><th>dev.</th><th>sum</th><th>hits</th>
+<tr><th rowspan='2'>name</th><th rowspan='2'>category</th><th rowspan='2'>subsystem</th>
+<td colspan='5'>concurrency</td>
+<td colspan='7'>performances (ns)</td>
+</tr>
+<tr><th>min</th><th>max</th><th>mean</th><th>deviation</th><th>value</th>
+<th>hits</th><th>sum</th><th>min</th><th>max</th><th>mean</th><th>deviation</th><th>value</th>
 </tr>
 </thead>
+
 <tbody>
+
 <tr>
 <td>JsonRendererTest.setUp</td><td>test</td><td>reporting</td>
-<td title='concurrency'>0</td><td>0</td><td>0</td><td>NaN</td><td>NaN</td>
-<td title='performances'>10</td><td>10</td><td>10</td><td>10.0</td><td>NaN</td><td>10</td><td>1</td>
+<td>0</td><td>0</td><td>-</td><td>-</td><td>0</td>
+<td>1</td><td>10</td><td>10</td><td>10</td><td>10</td><td>-</td><td>10</td>
 </tr>
 
-<tr><td>TestCase</td><td>test</td><td>junit</td>
-<td title='concurrency'>1</td><td>1</td><td>1</td><td>0.0</td><td>NaN</td>
-<td title='performances'>0</td><td>0</td><td>0</td><td>NaN</td><td>NaN</td><td>0</td><td>0</td>
+<tr>
+<td>TestCase</td><td>test</td><td>junit</td>
+<td>1</td><td>1</td><td>0</td><td>-</td><td>1</td>
+<td>0</td><td>0</td><td>0</td><td>0</td><td>-</td><td>-</td><td>0</td>
 </tr>
 
-</tbody></table>
-</body></html>
\ No newline at end of file
+</tbody>
+</table>
+</body>
+</html>

Modified: commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.js
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.js?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.js (original)
+++ commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.js Thu Mar  6 03:41:35 2008
@@ -1,7 +1,15 @@
-[{concurrency:{value:"0",min:"0",max:"0",mean:"NaN",stdDev:"NaN"},
-performances:{value:"10",min:"10",max:"10",mean:"10.0",stdDev:"NaN",total:"10",hits:"1"},
-key:{name:"JsonRendererTest.setUp",category:"test",subsystem:"reporting"}},
-{concurrency:{value:"1",min:"1",max:"1",mean:"0.0",stdDev:"NaN"},
-performances:{value:"0",min:"0",max:"0",mean:"NaN",stdDev:"NaN",total:"0",hits:"0"},
-key:{name:"TestCase",category:"test",subsystem:"junit"}}
-]
\ No newline at end of file
+[
+
+{
+concurrency:{min:"0",max:"0",mean:"-",deviation:"-",value:"0"},
+performances:{hits:"1",sum:"10",min:"10",max:"10",mean:"10",deviation:"-",value:"10"},
+key:{name:"JsonRendererTest.setUp",category:"test",subsystem:"reporting"}
+},
+
+{
+concurrency:{min:"1",max:"1",mean:"0",deviation:"-",value:"1"},
+performances:{hits:"0",sum:"0",min:"0",max:"0",mean:"-",deviation:"-",value:"0"},
+key:{name:"TestCase",category:"test",subsystem:"junit"}
+}
+
+]

Modified: commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.txt
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.txt?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.txt (original)
+++ commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.txt Thu Mar  6 03:41:35 2008
@@ -4,19 +4,20 @@
 subsystem=reporting
 --------------------------------------------------------------------------------
 concurrency
-    value  : 0
-    min    : 0
-    max    : 0
-    mean   : NaN
-    stdDev : NaN
+    min : 0
+    max : 0
+    mean : -
+    deviation : -
+    value : 0
+
 performances
-    value  : 10
-    min    : 10
-    max    : 10
-    mean   : 10.0
-    stdDev : NaN
-    total  : 10
-    hits   : 1
+    hits : 1
+    sum : 10
+    min : 10
+    max : 10
+    mean : 10
+    deviation : -
+    value : 10
 
 --------------------------------------------------------------------------------
 name=TestCase
@@ -24,16 +25,17 @@
 subsystem=junit
 --------------------------------------------------------------------------------
 concurrency
-    value  : 1
-    min    : 1
-    max    : 1
-    mean   : 0.0
-    stdDev : NaN
+    min : 1
+    max : 1
+    mean : 0
+    deviation : -
+    value : 1
+
 performances
-    value  : 0
-    min    : 0
-    max    : 0
-    mean   : NaN
-    stdDev : NaN
-    total  : 0
-    hits   : 0
\ No newline at end of file
+    hits : 0
+    sum : 0
+    min : 0
+    max : 0
+    mean : -
+    deviation : -
+    value : 0
\ No newline at end of file

Modified: commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.xml?rev=634228&r1=634227&r2=634228&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.xml (original)
+++ commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.xml Thu Mar  6 03:41:35 2008
@@ -1,10 +1,13 @@
 <monitors>
+
 <monitor name="JsonRendererTest.setUp" category="test" subsystem="reporting">
-<concurrency value="0" min="0" max="0" mean="NaN" stdDev="NaN"/>
-<performances value="10" min="10" max="10" mean="10.0" stdDev="NaN" total="10" hits="1"/>
+<concurrency min="0" max="0" mean="-" deviation="-" value="0"/>
+<performances hits="1" sum="10" min="10" max="10" mean="10" deviation="-" value="10"/>
 </monitor>
+
 <monitor name="TestCase" category="test" subsystem="junit">
-<concurrency value="1" min="1" max="1" mean="0.0" stdDev="NaN"/>
-<performances value="0" min="0" max="0" mean="NaN" stdDev="NaN" total="0" hits="0"/>
+<concurrency min="1" max="1" mean="0" deviation="-" value="1"/>
+<performances hits="0" sum="0" min="0" max="0" mean="-" deviation="-" value="0"/>
 </monitor>
+
 </monitors>