diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java
index 4c0203d835cc..214dc7f7d2bf 100644
--- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java
+++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java
@@ -29,6 +29,7 @@
import org.eclipse.jetty.deploy.bindings.DebugListenerBinding;
import org.eclipse.jetty.deploy.providers.WebAppProvider;
import org.eclipse.jetty.http.HttpVersion;
+import org.eclipse.jetty.io.ConnectionStatistics;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.rewrite.handler.MsieSslRule;
import org.eclipse.jetty.rewrite.handler.RewriteHandler;
@@ -43,7 +44,6 @@
import org.eclipse.jetty.server.LowResourceMonitor;
import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnectionStatistics;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
@@ -180,7 +180,7 @@ public static Server createServer(int port, int securePort, boolean addDebugList
StatisticsHandler stats = new StatisticsHandler();
stats.setHandler(server.getHandler());
server.setHandler(stats);
- ServerConnectionStatistics.addToAllConnectors(server);
+ server.addBeanToAllConnectors(new ConnectionStatistics());
// === Rewrite Handler
RewriteHandler rewrite = new RewriteHandler();
diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneServletContextJmxStats.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneServletContextJmxStats.java
index a471da5ed11f..8e9cbeeb55d8 100644
--- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneServletContextJmxStats.java
+++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneServletContextJmxStats.java
@@ -20,9 +20,9 @@
import java.lang.management.ManagementFactory;
+import org.eclipse.jetty.io.ConnectionStatistics;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnectionStatistics;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
@@ -45,7 +45,7 @@ public static Server createServer(int port)
context.addServlet(DefaultServlet.class, "/");
// Add Connector Statistics tracking to all connectors
- ServerConnectionStatistics.addToAllConnectors(server);
+ server.addBeanToAllConnectors(new ConnectionStatistics());
return server;
}
diff --git a/jetty-server/src/main/config/etc/jetty-stats.xml b/jetty-server/src/main/config/etc/jetty-stats.xml
index bc8a649c81a3..aade73419864 100644
--- a/jetty-server/src/main/config/etc/jetty-stats.xml
+++ b/jetty-server/src/main/config/etc/jetty-stats.xml
@@ -8,7 +8,9 @@
-
-
+
+
+
+
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ConnectorStatistics.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ConnectorStatistics.java
index 489e356f4b1e..47cfa974ee1a 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ConnectorStatistics.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ConnectorStatistics.java
@@ -41,7 +41,7 @@
* Adding an instance of this class as with {@link AbstractConnector#addBean(Object)}
* will register the listener with all connections accepted by that connector.
*
- * @deprecated use {@link ServerConnectionStatistics} instead.
+ * @deprecated use {@link org.eclipse.jetty.io.ConnectionStatistics} instead.
*/
@Deprecated
@ManagedObject("Connector Statistics")
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
index 31fd92146029..ae3ab7df2a50 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
@@ -42,6 +42,7 @@
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.PreEncodedHttpField;
+import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ErrorHandler;
import org.eclipse.jetty.server.handler.HandlerWrapper;
@@ -224,8 +225,8 @@ public void addConnector(Connector connector)
if (connector.getServer() != this)
throw new IllegalArgumentException("Connector " + connector +
" cannot be shared among server " + connector.getServer() + " and server " + this);
- if (_connectors.add(connector))
- addBean(connector);
+ _connectors.add(connector);
+ addBean(connector);
}
/**
@@ -265,6 +266,20 @@ public void setConnectors(Connector[] connectors)
_connectors.addAll(Arrays.asList(connectors));
}
+ /**
+ * Add a bean to all connectors on the server.
+ * If the bean is an instance of {@link Connection.Listener} it will also be
+ * registered as a listener on all connections accepted by the connectors.
+ * @param bean the bean to be added.
+ */
+ public void addBeanToAllConnectors(Object bean)
+ {
+ for (Connector connector : getConnectors())
+ {
+ connector.addBean(bean);
+ }
+ }
+
/**
* @return Returns the threadPool.
*/
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnectionStatistics.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnectionStatistics.java
index 27feaf9b0aed..bbce7dcca666 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnectionStatistics.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnectionStatistics.java
@@ -19,16 +19,19 @@
package org.eclipse.jetty.server;
import org.eclipse.jetty.io.ConnectionStatistics;
-import org.eclipse.jetty.util.component.Container;
+@Deprecated
public class ServerConnectionStatistics extends ConnectionStatistics
{
+ /**
+ * @param server the server to use to add {@link ConnectionStatistics} to all Connectors.
+ * @deprecated use {@link Server#addBeanToAllConnectors(Object)} instead.
+ */
public static void addToAllConnectors(Server server)
{
for (Connector connector : server.getConnectors())
{
- if (connector instanceof Container)
- connector.addBean(new ConnectionStatistics());
+ connector.addBean(new ConnectionStatistics());
}
}
}