diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/NetworkTrafficServerConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/NetworkTrafficServerConnector.java
new file mode 100644
index 00000000000..24ac7e47446
--- /dev/null
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/NetworkTrafficServerConnector.java
@@ -0,0 +1,93 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.server;
+
+import java.io.IOException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.Executor;
+
+import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.io.NetworkTrafficListener;
+import org.eclipse.jetty.io.NetworkTrafficSelectChannelEndPoint;
+import org.eclipse.jetty.io.SelectChannelEndPoint;
+import org.eclipse.jetty.io.SelectorManager;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.eclipse.jetty.util.thread.Scheduler;
+
+/**
+ *
A specialized version of {@link ServerConnector} that supports {@link NetworkTrafficListener}s.
+ * {@link NetworkTrafficListener}s can be added and removed dynamically before and after this connector has
+ * been started without causing {@link java.util.ConcurrentModificationException}s.
+ */
+public class NetworkTrafficServerConnector extends ServerConnector
+{
+ private final List listeners = new CopyOnWriteArrayList<>();
+
+ public NetworkTrafficServerConnector(Server server)
+ {
+ this(server, null, null, null, 0, 0, new HttpConnectionFactory());
+ }
+
+ public NetworkTrafficServerConnector(Server server, ConnectionFactory connectionFactory, SslContextFactory sslContextFactory)
+ {
+ super(server, sslContextFactory, connectionFactory);
+ }
+
+ public NetworkTrafficServerConnector(Server server, ConnectionFactory connectionFactory)
+ {
+ super(server, connectionFactory);
+ }
+
+ public NetworkTrafficServerConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, int selectors, ConnectionFactory... factories)
+ {
+ super(server, executor, scheduler, pool, acceptors, selectors, factories);
+ }
+
+ public NetworkTrafficServerConnector(Server server, SslContextFactory sslContextFactory)
+ {
+ super(server, sslContextFactory);
+ }
+
+ /**
+ * @param listener the listener to add
+ */
+ public void addNetworkTrafficListener(NetworkTrafficListener listener)
+ {
+ listeners.add(listener);
+ }
+
+ /**
+ * @param listener the listener to remove
+ */
+ public void removeNetworkTrafficListener(NetworkTrafficListener listener)
+ {
+ listeners.remove(listener);
+ }
+
+ @Override
+ protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectorManager.ManagedSelector selectSet, SelectionKey key) throws IOException
+ {
+ NetworkTrafficSelectChannelEndPoint endPoint = new NetworkTrafficSelectChannelEndPoint(channel, selectSet, key, getScheduler(), getIdleTimeout(), listeners);
+ endPoint.notifyOpened();
+ return endPoint;
+ }
+}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java
index 56c661d5a7c..f4c595834a8 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java
@@ -18,83 +18,43 @@
package org.eclipse.jetty.server.nio;
-import java.io.IOException;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.SocketChannel;
-import java.util.ConcurrentModificationException;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import org.eclipse.jetty.io.ByteBufferPool;
-import org.eclipse.jetty.io.NetworkTrafficListener;
-import org.eclipse.jetty.io.NetworkTrafficSelectChannelEndPoint;
-import org.eclipse.jetty.io.SelectChannelEndPoint;
-import org.eclipse.jetty.io.SelectorManager;
import org.eclipse.jetty.server.ConnectionFactory;
-import org.eclipse.jetty.server.HttpConnectionFactory;
+import org.eclipse.jetty.server.NetworkTrafficServerConnector;
import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;
/**
- * A specialized version of {@link ServerConnector} that supports {@link NetworkTrafficListener}s.
- * {@link NetworkTrafficListener}s can be added and removed dynamically before and after this connector has
- * been started without causing {@link ConcurrentModificationException}s.
+ * @deprecated use {@link org.eclipse.jetty.server.NetworkTrafficServerConnector} instead.
*/
-public class NetworkTrafficSelectChannelConnector extends ServerConnector
+@Deprecated
+public class NetworkTrafficSelectChannelConnector extends NetworkTrafficServerConnector
{
- private final List listeners = new CopyOnWriteArrayList();
-
public NetworkTrafficSelectChannelConnector(Server server)
{
- this(server,null,null,null,0,0,new HttpConnectionFactory());
+ super(server);
}
public NetworkTrafficSelectChannelConnector(Server server, ConnectionFactory connectionFactory, SslContextFactory sslContextFactory)
{
- super(server,sslContextFactory,connectionFactory);
+ super(server, connectionFactory, sslContextFactory);
}
public NetworkTrafficSelectChannelConnector(Server server, ConnectionFactory connectionFactory)
{
- super(server,connectionFactory);
+ super(server, connectionFactory);
}
- public NetworkTrafficSelectChannelConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, int selectors,
- ConnectionFactory... factories)
+ public NetworkTrafficSelectChannelConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, int selectors, ConnectionFactory... factories)
{
- super(server,executor,scheduler,pool,acceptors,selectors,factories);
+ super(server, executor, scheduler, pool, acceptors, selectors, factories);
}
public NetworkTrafficSelectChannelConnector(Server server, SslContextFactory sslContextFactory)
{
- super(server,sslContextFactory);
+ super(server, sslContextFactory);
}
-
- /**
- * @param listener the listener to add
- */
- public void addNetworkTrafficListener(NetworkTrafficListener listener)
- {
- listeners.add(listener);
- }
-
- /**
- * @param listener the listener to remove
- */
- public void removeNetworkTrafficListener(NetworkTrafficListener listener)
- {
- listeners.remove(listener);
- }
-
- @Override
- protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectorManager.ManagedSelector selectSet, SelectionKey key) throws IOException
- {
- NetworkTrafficSelectChannelEndPoint endPoint = new NetworkTrafficSelectChannelEndPoint(channel, selectSet, key, getScheduler(), getIdleTimeout(), listeners);
- endPoint.notifyOpened();
- return endPoint;
- }
-
}
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/NetworkTrafficListenerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/NetworkTrafficListenerTest.java
index 744806e4db7..679df516243 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/NetworkTrafficListenerTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/NetworkTrafficListenerTest.java
@@ -18,9 +18,6 @@
package org.eclipse.jetty.server;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -31,7 +28,6 @@ import java.nio.charset.StandardCharsets;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
@@ -39,25 +35,27 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.io.NetworkTrafficListener;
import org.eclipse.jetty.server.handler.AbstractHandler;
-import org.eclipse.jetty.server.nio.NetworkTrafficSelectChannelConnector;
import org.eclipse.jetty.util.BufferUtil;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
@Ignore
public class NetworkTrafficListenerTest
{
private static final byte END_OF_CONTENT = '~';
private Server server;
- private NetworkTrafficSelectChannelConnector connector;
+ private NetworkTrafficServerConnector connector;
public void initConnector(Handler handler) throws Exception
{
server = new Server();
- connector = new NetworkTrafficSelectChannelConnector(server);
+ connector = new NetworkTrafficServerConnector(server);
connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendDateHeader(false);
connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendServerVersion(false);
server.addConnector(connector);
@@ -121,9 +119,9 @@ public class NetworkTrafficListenerTest
}
});
- final AtomicReference incomingData = new AtomicReference();
+ final AtomicReference incomingData = new AtomicReference<>();
final CountDownLatch incomingLatch = new CountDownLatch(1);
- final AtomicReference outgoingData = new AtomicReference("");
+ final AtomicReference outgoingData = new AtomicReference<>("");
final CountDownLatch outgoingLatch = new CountDownLatch(1);
connector.addNetworkTrafficListener(new NetworkTrafficListener.Adapter()
{
@@ -186,9 +184,9 @@ public class NetworkTrafficListenerTest
}
});
- final AtomicReference incomingData = new AtomicReference();
+ final AtomicReference incomingData = new AtomicReference<>();
final CountDownLatch incomingLatch = new CountDownLatch(1);
- final AtomicReference outgoingData = new AtomicReference("");
+ final AtomicReference outgoingData = new AtomicReference<>("");
final CountDownLatch outgoingLatch = new CountDownLatch(2);
connector.addNetworkTrafficListener(new NetworkTrafficListener.Adapter()
{
@@ -253,9 +251,9 @@ public class NetworkTrafficListenerTest
}
});
- final AtomicReference incomingData = new AtomicReference();
+ final AtomicReference incomingData = new AtomicReference<>();
final CountDownLatch incomingLatch = new CountDownLatch(1);
- final AtomicReference outgoingData = new AtomicReference("");
+ final AtomicReference outgoingData = new AtomicReference<>("");
final CountDownLatch outgoingLatch = new CountDownLatch(4);
connector.addNetworkTrafficListener(new NetworkTrafficListener.Adapter()
{
@@ -319,9 +317,9 @@ public class NetworkTrafficListenerTest
}
});
- final AtomicReference incomingData = new AtomicReference();
+ final AtomicReference incomingData = new AtomicReference<>();
final CountDownLatch incomingLatch = new CountDownLatch(1);
- final AtomicReference outgoingData = new AtomicReference("");
+ final AtomicReference outgoingData = new AtomicReference<>("");
final CountDownLatch outgoingLatch = new CountDownLatch(1);
connector.addNetworkTrafficListener(new NetworkTrafficListener.Adapter()
{
@@ -393,8 +391,8 @@ public class NetworkTrafficListenerTest
}
});
- final AtomicReference incomingData = new AtomicReference("");
- final AtomicReference outgoingData = new AtomicReference("");
+ final AtomicReference incomingData = new AtomicReference<>("");
+ final AtomicReference outgoingData = new AtomicReference<>("");
final CountDownLatch outgoingLatch = new CountDownLatch(1);
connector.addNetworkTrafficListener(new NetworkTrafficListener.Adapter()
{