Renaming AsyncWebSocketConnection to WebSocketAsyncConnection per discussion
This commit is contained in:
parent
e60001fab8
commit
beca3f9bd0
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.AbstractAsyncConnection;
|
import org.eclipse.jetty.io.AbstractAsyncConnection;
|
||||||
|
import org.eclipse.jetty.io.AsyncConnection;
|
||||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||||
import org.eclipse.jetty.io.ByteBufferPool;
|
import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.io.RuntimeIOException;
|
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.parser.Parser;
|
||||||
import org.eclipse.jetty.websocket.server.callbacks.WebSocketCloseCallback;
|
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 Logger LOG = Log.getLogger(WebSocketAsyncConnection.class);
|
||||||
private static final ThreadLocal<AsyncWebSocketConnection> CURRENT_CONNECTION = new ThreadLocal<AsyncWebSocketConnection>();
|
private static final ThreadLocal<WebSocketAsyncConnection> CURRENT_CONNECTION = new ThreadLocal<WebSocketAsyncConnection>();
|
||||||
|
|
||||||
public static AsyncWebSocketConnection getCurrentConnection()
|
public static WebSocketAsyncConnection getCurrentConnection()
|
||||||
{
|
{
|
||||||
return CURRENT_CONNECTION.get();
|
return CURRENT_CONNECTION.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void setCurrentConnection(AsyncWebSocketConnection connection)
|
protected static void setCurrentConnection(WebSocketAsyncConnection connection)
|
||||||
{
|
{
|
||||||
CURRENT_CONNECTION.set(connection);
|
CURRENT_CONNECTION.set(connection);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +58,7 @@ public class AsyncWebSocketConnection extends AbstractAsyncConnection implements
|
||||||
// TODO: are extensions going to layer the connection?
|
// TODO: are extensions going to layer the connection?
|
||||||
private List<ExtensionConfig> extensions;
|
private List<ExtensionConfig> extensions;
|
||||||
|
|
||||||
public AsyncWebSocketConnection(AsyncEndPoint endp, Executor executor, WebSocketPolicy policy)
|
public WebSocketAsyncConnection(AsyncEndPoint endp, Executor executor, WebSocketPolicy policy)
|
||||||
{
|
{
|
||||||
super(endp,executor);
|
super(endp,executor);
|
||||||
this.policy = policy;
|
this.policy = policy;
|
|
@ -51,7 +51,7 @@ import org.eclipse.jetty.websocket.server.handshake.HandshakeRFC6455;
|
||||||
public class WebSocketServerFactory extends AbstractLifeCycle implements WebSocketCreator
|
public class WebSocketServerFactory extends AbstractLifeCycle implements WebSocketCreator
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(WebSocketServerFactory.class);
|
private static final Logger LOG = Log.getLogger(WebSocketServerFactory.class);
|
||||||
private final Queue<AsyncWebSocketConnection> connections = new ConcurrentLinkedQueue<AsyncWebSocketConnection>();
|
private final Queue<WebSocketAsyncConnection> connections = new ConcurrentLinkedQueue<WebSocketAsyncConnection>();
|
||||||
|
|
||||||
// TODO: replace with ExtensionRegistry in websocket-core
|
// TODO: replace with ExtensionRegistry in websocket-core
|
||||||
private final Map<String, Class<? extends Extension>> extensionClasses = new HashMap<>();
|
private final Map<String, Class<? extends Extension>> extensionClasses = new HashMap<>();
|
||||||
|
@ -122,14 +122,14 @@ public class WebSocketServerFactory extends AbstractLifeCycle implements WebSock
|
||||||
return upgrade(sockreq,sockresp,websocket);
|
return upgrade(sockreq,sockresp,websocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean addConnection(AsyncWebSocketConnection connection)
|
protected boolean addConnection(WebSocketAsyncConnection connection)
|
||||||
{
|
{
|
||||||
return isRunning() && connections.add(connection);
|
return isRunning() && connections.add(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void closeConnections()
|
protected void closeConnections()
|
||||||
{
|
{
|
||||||
for (AsyncWebSocketConnection connection : connections)
|
for (WebSocketAsyncConnection connection : connections)
|
||||||
{
|
{
|
||||||
connection.getEndPoint().close();
|
connection.getEndPoint().close();
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,7 @@ public class WebSocketServerFactory extends AbstractLifeCycle implements WebSock
|
||||||
methodsCache.register(websocketClass);
|
methodsCache.register(websocketClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean removeConnection(AsyncWebSocketConnection connection)
|
protected boolean removeConnection(WebSocketAsyncConnection connection)
|
||||||
{
|
{
|
||||||
return connections.remove(connection);
|
return connections.remove(connection);
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ public class WebSocketServerFactory extends AbstractLifeCycle implements WebSock
|
||||||
HttpConnection http = HttpConnection.getCurrentConnection();
|
HttpConnection http = HttpConnection.getCurrentConnection();
|
||||||
AsyncEndPoint endp = http.getEndPoint();
|
AsyncEndPoint endp = http.getEndPoint();
|
||||||
Executor executor = http.getConnector().findExecutor();
|
Executor executor = http.getConnector().findExecutor();
|
||||||
AsyncWebSocketConnection connection = new AsyncWebSocketConnection(endp,executor,websocket.getPolicy());
|
WebSocketAsyncConnection connection = new WebSocketAsyncConnection(endp,executor,websocket.getPolicy());
|
||||||
endp.setAsyncConnection(connection);
|
endp.setAsyncConnection(connection);
|
||||||
connection.getParser().addListener(websocket);
|
connection.getParser().addListener(websocket);
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,20 @@ package org.eclipse.jetty.websocket.server.callbacks;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.Callback;
|
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<Void>
|
public class WebSocketCloseCallback implements Callback<Void>
|
||||||
{
|
{
|
||||||
private AsyncWebSocketConnection conn;
|
private WebSocketAsyncConnection conn;
|
||||||
private ByteBuffer buf;
|
private ByteBuffer buf;
|
||||||
|
|
||||||
public WebSocketCloseCallback(AsyncWebSocketConnection conn)
|
public WebSocketCloseCallback(WebSocketAsyncConnection conn)
|
||||||
{
|
{
|
||||||
this.conn = conn;
|
this.conn = conn;
|
||||||
this.buf = null;
|
this.buf = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebSocketCloseCallback(AsyncWebSocketConnection conn, ByteBuffer buf)
|
public WebSocketCloseCallback(WebSocketAsyncConnection conn, ByteBuffer buf)
|
||||||
{
|
{
|
||||||
this.conn = conn;
|
this.conn = conn;
|
||||||
this.buf = buf;
|
this.buf = buf;
|
||||||
|
|
Loading…
Reference in New Issue