diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/AsyncWebSocketConnection.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketAsyncConnection.java similarity index 94% rename from jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/AsyncWebSocketConnection.java rename to jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketAsyncConnection.java index 7e366067273..fe7e52a9fcf 100644 --- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/AsyncWebSocketConnection.java +++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketAsyncConnection.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.concurrent.Executor; import org.eclipse.jetty.io.AbstractAsyncConnection; +import org.eclipse.jetty.io.AsyncConnection; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.RuntimeIOException; @@ -30,18 +31,20 @@ import org.eclipse.jetty.websocket.generator.Generator; import org.eclipse.jetty.websocket.parser.Parser; import org.eclipse.jetty.websocket.server.callbacks.WebSocketCloseCallback; -// TODO: implement WebSocket.Connection (for API access)? -public class AsyncWebSocketConnection extends AbstractAsyncConnection implements WebSocketConnection +/** + * Provides the implementation of {@link WebSocketConnection} within the framework of the new {@link AsyncConnection} framework of jetty-io + */ +public class WebSocketAsyncConnection extends AbstractAsyncConnection implements WebSocketConnection { - private static final Logger LOG = Log.getLogger(AsyncWebSocketConnection.class); - private static final ThreadLocal CURRENT_CONNECTION = new ThreadLocal(); + private static final Logger LOG = Log.getLogger(WebSocketAsyncConnection.class); + private static final ThreadLocal CURRENT_CONNECTION = new ThreadLocal(); - public static AsyncWebSocketConnection getCurrentConnection() + public static WebSocketAsyncConnection getCurrentConnection() { return CURRENT_CONNECTION.get(); } - protected static void setCurrentConnection(AsyncWebSocketConnection connection) + protected static void setCurrentConnection(WebSocketAsyncConnection connection) { CURRENT_CONNECTION.set(connection); } @@ -55,7 +58,7 @@ public class AsyncWebSocketConnection extends AbstractAsyncConnection implements // TODO: are extensions going to layer the connection? private List extensions; - public AsyncWebSocketConnection(AsyncEndPoint endp, Executor executor, WebSocketPolicy policy) + public WebSocketAsyncConnection(AsyncEndPoint endp, Executor executor, WebSocketPolicy policy) { super(endp,executor); this.policy = policy; diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java index dbc57091bca..33474f5b323 100644 --- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java +++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java @@ -51,7 +51,7 @@ import org.eclipse.jetty.websocket.server.handshake.HandshakeRFC6455; public class WebSocketServerFactory extends AbstractLifeCycle implements WebSocketCreator { private static final Logger LOG = Log.getLogger(WebSocketServerFactory.class); - private final Queue connections = new ConcurrentLinkedQueue(); + private final Queue connections = new ConcurrentLinkedQueue(); // TODO: replace with ExtensionRegistry in websocket-core private final Map> extensionClasses = new HashMap<>(); @@ -122,14 +122,14 @@ public class WebSocketServerFactory extends AbstractLifeCycle implements WebSock return upgrade(sockreq,sockresp,websocket); } - protected boolean addConnection(AsyncWebSocketConnection connection) + protected boolean addConnection(WebSocketAsyncConnection connection) { return isRunning() && connections.add(connection); } protected void closeConnections() { - for (AsyncWebSocketConnection connection : connections) + for (WebSocketAsyncConnection connection : connections) { connection.getEndPoint().close(); } @@ -280,7 +280,7 @@ public class WebSocketServerFactory extends AbstractLifeCycle implements WebSock methodsCache.register(websocketClass); } - protected boolean removeConnection(AsyncWebSocketConnection connection) + protected boolean removeConnection(WebSocketAsyncConnection connection) { return connections.remove(connection); } @@ -338,7 +338,7 @@ public class WebSocketServerFactory extends AbstractLifeCycle implements WebSock HttpConnection http = HttpConnection.getCurrentConnection(); AsyncEndPoint endp = http.getEndPoint(); Executor executor = http.getConnector().findExecutor(); - AsyncWebSocketConnection connection = new AsyncWebSocketConnection(endp,executor,websocket.getPolicy()); + WebSocketAsyncConnection connection = new WebSocketAsyncConnection(endp,executor,websocket.getPolicy()); endp.setAsyncConnection(connection); connection.getParser().addListener(websocket); diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/callbacks/WebSocketCloseCallback.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/callbacks/WebSocketCloseCallback.java index 9cca3d5839f..c582e67eb5f 100644 --- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/callbacks/WebSocketCloseCallback.java +++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/callbacks/WebSocketCloseCallback.java @@ -3,20 +3,20 @@ package org.eclipse.jetty.websocket.server.callbacks; import java.nio.ByteBuffer; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.websocket.server.AsyncWebSocketConnection; +import org.eclipse.jetty.websocket.server.WebSocketAsyncConnection; public class WebSocketCloseCallback implements Callback { - private AsyncWebSocketConnection conn; + private WebSocketAsyncConnection conn; private ByteBuffer buf; - public WebSocketCloseCallback(AsyncWebSocketConnection conn) + public WebSocketCloseCallback(WebSocketAsyncConnection conn) { this.conn = conn; this.buf = null; } - public WebSocketCloseCallback(AsyncWebSocketConnection conn, ByteBuffer buf) + public WebSocketCloseCallback(WebSocketAsyncConnection conn, ByteBuffer buf) { this.conn = conn; this.buf = buf;