FELIX-3181 Applied JMX statistcs patch (thanks Justin Edelson)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1187495 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
index 096191f..1dd1c8a 100644
--- a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
+++ b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
@@ -25,6 +25,7 @@
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.bio.SocketConnector;
+import org.mortbay.jetty.handler.StatisticsHandler;
 import org.mortbay.jetty.nio.SelectChannelConnector;
 import org.mortbay.jetty.servlet.*;
 import org.apache.felix.http.base.internal.DispatcherServlet;
@@ -153,12 +154,6 @@
             // HTTP/1.1 requires Date header if possible (it is)
             this.server.setSendDateHeader(true);
 
-            if (this.config.isRegisterMBeans())
-            {
-                this.mbeanServerTracker = new MBeanServerTracker(this.context, this.server);
-                this.mbeanServerTracker.open();
-            }
-
             this.server.addUserRealm(realm);
 
             if (this.config.isUseHttp())
@@ -177,6 +172,13 @@
             context.addEventListener(eventDispatcher);
             context.getSessionHandler().addEventListener(eventDispatcher);
             context.addServlet(new ServletHolder(this.dispatcher), "/*");
+            
+            if (this.config.isRegisterMBeans())
+            {
+                this.mbeanServerTracker = new MBeanServerTracker(this.context, this.server);
+                this.mbeanServerTracker.open();
+                context.addHandler(new StatisticsHandler());
+            }
 
             this.server.start();
             SystemLogger.info(message.toString());