jetty-9 removed more AsyncConnection names

This commit is contained in:
Greg Wilkins 2012-08-02 18:10:29 +10:00
parent b63e09df61
commit 0865a9cfb0
18 changed files with 59 additions and 58 deletions

View File

@ -40,7 +40,7 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
/**
* An AsyncConnection that acts as an intercepter between an EndPoint providing SSL encrypted data
* A Connection that acts as an intercepter between an EndPoint providing SSL encrypted data
* and another consumer of an EndPoint (typically an {@link Connection} like HttpConnection) that
* wants unencrypted data.
* <p>

View File

@ -212,7 +212,7 @@ public class HttpConnection extends AbstractConnection
{
setCurrentConnection(this);
// TODO try to generalize this loop into AbstractAsyncConnection
// TODO try to generalize this loop into AbstractConnection
while (true)
{
// synchronized (_lock)

View File

@ -18,7 +18,7 @@ import java.nio.channels.SocketChannel;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
public interface AsyncConnectionFactory
public interface ConnectionFactory
{
public Connection newAsyncConnection(SocketChannel channel, EndPoint endPoint, Object attachment);
public Connection newConnection(SocketChannel channel, EndPoint endPoint, Object attachment);
}

View File

@ -87,7 +87,7 @@ public class NextProtoNegoClientAsyncConnection extends AbstractConnection imple
{
// Server does not support NPN, but this is a SPDY client, so hardcode SPDY
EndPoint endPoint = getEndPoint();
Connection connection = client.getDefaultAsyncConnectionFactory().newAsyncConnection(channel, endPoint, attachment);
Connection connection = client.getDefaultAsyncConnectionFactory().newConnection(channel, endPoint, attachment);
client.replaceAsyncConnection(endPoint, connection);
completed = true;
}
@ -99,7 +99,7 @@ public class NextProtoNegoClientAsyncConnection extends AbstractConnection imple
if (protocol == null)
return null;
EndPoint endPoint = getEndPoint();
Connection connection = client.getAsyncConnectionFactory(protocol).newAsyncConnection(channel, endPoint, attachment);
Connection connection = client.getAsyncConnectionFactory(protocol).newConnection(channel, endPoint, attachment);
client.replaceAsyncConnection(endPoint, connection);
completed = true;
return protocol;

View File

@ -76,9 +76,9 @@ public class NextProtoNegoServerAsyncConnection extends AbstractConnection imple
@Override
public void unsupported()
{
AsyncConnectionFactory asyncConnectionFactory = connector.getDefaultAsyncConnectionFactory();
ConnectionFactory asyncConnectionFactory = connector.getDefaultAsyncConnectionFactory();
EndPoint endPoint = getEndPoint();
Connection connection = asyncConnectionFactory.newAsyncConnection(channel, endPoint, connector);
Connection connection = asyncConnectionFactory.newConnection(channel, endPoint, connector);
connector.replaceAsyncConnection(endPoint, connection);
completed = true;
}
@ -92,9 +92,9 @@ public class NextProtoNegoServerAsyncConnection extends AbstractConnection imple
@Override
public void protocolSelected(String protocol)
{
AsyncConnectionFactory asyncConnectionFactory = connector.getAsyncConnectionFactory(protocol);
ConnectionFactory asyncConnectionFactory = connector.getAsyncConnectionFactory(protocol);
EndPoint endPoint = getEndPoint();
Connection connection = asyncConnectionFactory.newAsyncConnection(channel, endPoint, connector);
Connection connection = asyncConnectionFactory.newConnection(channel, endPoint, connector);
connector.replaceAsyncConnection(endPoint, connection);
completed = true;
}

View File

@ -49,8 +49,8 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
public class SPDYClient
{
private final Map<String, AsyncConnectionFactory> factories = new ConcurrentHashMap<>();
private final AsyncConnectionFactory defaultAsyncConnectionFactory = new ClientSPDYAsyncConnectionFactory();
private final Map<String, ConnectionFactory> factories = new ConcurrentHashMap<>();
private final ConnectionFactory defaultAsyncConnectionFactory = new ClientSPDYAsyncConnectionFactory();
private final short version;
private final Factory factory;
private volatile SocketAddress bindAddress;
@ -140,14 +140,14 @@ public class SPDYClient
return null;
}
public AsyncConnectionFactory getAsyncConnectionFactory(String protocol)
public ConnectionFactory getAsyncConnectionFactory(String protocol)
{
for (Map.Entry<String, AsyncConnectionFactory> entry : factories.entrySet())
for (Map.Entry<String, ConnectionFactory> entry : factories.entrySet())
{
if (protocol.equals(entry.getKey()))
return entry.getValue();
}
for (Map.Entry<String, AsyncConnectionFactory> entry : factory.factories.entrySet())
for (Map.Entry<String, ConnectionFactory> entry : factory.factories.entrySet())
{
if (protocol.equals(entry.getKey()))
return entry.getValue();
@ -155,17 +155,17 @@ public class SPDYClient
return null;
}
public void putAsyncConnectionFactory(String protocol, AsyncConnectionFactory factory)
public void putAsyncConnectionFactory(String protocol, ConnectionFactory factory)
{
factories.put(protocol, factory);
}
public AsyncConnectionFactory removeAsyncConnectionFactory(String protocol)
public ConnectionFactory removeAsyncConnectionFactory(String protocol)
{
return factories.remove(protocol);
}
public AsyncConnectionFactory getDefaultAsyncConnectionFactory()
public ConnectionFactory getDefaultAsyncConnectionFactory()
{
return defaultAsyncConnectionFactory;
}
@ -193,7 +193,7 @@ public class SPDYClient
public static class Factory extends AggregateLifeCycle
{
private final Map<String, AsyncConnectionFactory> factories = new ConcurrentHashMap<>();
private final Map<String, ConnectionFactory> factories = new ConcurrentHashMap<>();
private final Queue<Session> sessions = new ConcurrentLinkedQueue<>();
private final ByteBufferPool bufferPool = new StandardByteBufferPool();
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
@ -356,8 +356,8 @@ public class SPDYClient
}
else
{
AsyncConnectionFactory connectionFactory = new ClientSPDYAsyncConnectionFactory();
Connection connection = connectionFactory.newAsyncConnection(channel, endPoint, attachment);
ConnectionFactory connectionFactory = new ClientSPDYAsyncConnectionFactory();
Connection connection = connectionFactory.newConnection(channel, endPoint, attachment);
endPoint.setConnection(connection);
return connection;
}
@ -400,10 +400,10 @@ public class SPDYClient
}
}
private static class ClientSPDYAsyncConnectionFactory implements AsyncConnectionFactory
private static class ClientSPDYAsyncConnectionFactory implements ConnectionFactory
{
@Override
public Connection newAsyncConnection(SocketChannel channel, EndPoint endPoint, Object attachment)
public Connection newConnection(SocketChannel channel, EndPoint endPoint, Object attachment)
{
SessionPromise sessionPromise = (SessionPromise)attachment;
SPDYClient client = sessionPromise.client;

View File

@ -50,14 +50,14 @@ public class SPDYServerConnector extends SelectChannelConnector
private static final Logger logger = Log.getLogger(SPDYServerConnector.class);
// Order is important on server side, so we use a LinkedHashMap
private final Map<String, AsyncConnectionFactory> factories = new LinkedHashMap<>();
private final Map<String, ConnectionFactory> factories = new LinkedHashMap<>();
private final Queue<Session> sessions = new ConcurrentLinkedQueue<>();
private final ByteBufferPool bufferPool = new StandardByteBufferPool();
private final Executor executor = new LazyExecutor();
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
private final ServerSessionFrameListener listener;
private final SslContextFactory sslContextFactory;
private volatile AsyncConnectionFactory defaultConnectionFactory;
private volatile ConnectionFactory defaultConnectionFactory;
private volatile int initialWindowSize = 65536;
public SPDYServerConnector(ServerSessionFrameListener listener)
@ -123,7 +123,7 @@ public class SPDYServerConnector extends SelectChannelConnector
super.join();
}
public AsyncConnectionFactory getAsyncConnectionFactory(String protocol)
public ConnectionFactory getAsyncConnectionFactory(String protocol)
{
synchronized (factories)
{
@ -131,7 +131,7 @@ public class SPDYServerConnector extends SelectChannelConnector
}
}
public AsyncConnectionFactory putAsyncConnectionFactory(String protocol, AsyncConnectionFactory factory)
public ConnectionFactory putAsyncConnectionFactory(String protocol, ConnectionFactory factory)
{
synchronized (factories)
{
@ -139,7 +139,7 @@ public class SPDYServerConnector extends SelectChannelConnector
}
}
public AsyncConnectionFactory removeAsyncConnectionFactory(String protocol)
public ConnectionFactory removeAsyncConnectionFactory(String protocol)
{
synchronized (factories)
{
@ -147,7 +147,7 @@ public class SPDYServerConnector extends SelectChannelConnector
}
}
public Map<String, AsyncConnectionFactory> getAsyncConnectionFactories()
public Map<String, ConnectionFactory> getAsyncConnectionFactories()
{
synchronized (factories)
{
@ -171,12 +171,12 @@ public class SPDYServerConnector extends SelectChannelConnector
}
}
public AsyncConnectionFactory getDefaultAsyncConnectionFactory()
public ConnectionFactory getDefaultAsyncConnectionFactory()
{
return defaultConnectionFactory;
}
public void setDefaultAsyncConnectionFactory(AsyncConnectionFactory defaultConnectionFactory)
public void setDefaultAsyncConnectionFactory(ConnectionFactory defaultConnectionFactory)
{
this.defaultConnectionFactory = defaultConnectionFactory;
}
@ -209,8 +209,8 @@ public class SPDYServerConnector extends SelectChannelConnector
}
else
{
AsyncConnectionFactory connectionFactory = getDefaultAsyncConnectionFactory();
Connection connection = connectionFactory.newAsyncConnection(channel, endPoint, this);
ConnectionFactory connectionFactory = getDefaultAsyncConnectionFactory();
Connection connection = connectionFactory.newConnection(channel, endPoint, this);
endPoint.setConnection(connection);
return connection;
}

View File

@ -24,7 +24,7 @@ import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
import org.eclipse.jetty.spdy.generator.Generator;
import org.eclipse.jetty.spdy.parser.Parser;
public class ServerSPDYAsyncConnectionFactory implements AsyncConnectionFactory
public class ServerSPDYAsyncConnectionFactory implements ConnectionFactory
{
private final ByteBufferPool bufferPool;
private final Executor threadPool;
@ -52,7 +52,7 @@ public class ServerSPDYAsyncConnectionFactory implements AsyncConnectionFactory
}
@Override
public Connection newAsyncConnection(SocketChannel channel, EndPoint endPoint, Object attachment)
public Connection newConnection(SocketChannel channel, EndPoint endPoint, Object attachment)
{
CompressionFactory compressionFactory = new StandardCompressionFactory();
Parser parser = new Parser(compressionFactory.newDecompressor());

View File

@ -32,12 +32,12 @@ import org.eclipse.jetty.util.QuotedStringTokenizer;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.client.WebSocketClient.ConnectFuture;
import org.eclipse.jetty.websocket.io.WebSocketAsyncConnection;
import org.eclipse.jetty.websocket.io.AbstractWebSocketConnection;
/**
* Default Handshake Connection.
* <p>
* Results in a {@link WebSocketAsyncConnection} on successful handshake.
* Results in a {@link AbstractWebSocketConnection} on successful handshake.
*/
public class HandshakeConnection extends AbstractConnection implements Connection
{

View File

@ -7,13 +7,13 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.client.WebSocketClientFactory;
import org.eclipse.jetty.websocket.io.WebSocketAsyncConnection;
import org.eclipse.jetty.websocket.io.AbstractWebSocketConnection;
public class WebSocketClientAsyncConnection extends WebSocketAsyncConnection
public class WebSocketClientConnection extends AbstractWebSocketConnection
{
private final WebSocketClientFactory factory;
public WebSocketClientAsyncConnection(EndPoint endp, Executor executor, ScheduledExecutorService scheduler, WebSocketPolicy policy,
public WebSocketClientConnection(EndPoint endp, Executor executor, ScheduledExecutorService scheduler, WebSocketPolicy policy,
ByteBufferPool bufferPool, WebSocketClientFactory factory)
{
super(endp,executor,scheduler,policy,bufferPool);

View File

@ -32,11 +32,12 @@ import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.SelectorManager;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.api.WebSocketConnection;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.client.WebSocketClientFactory;
import org.eclipse.jetty.websocket.driver.WebSocketEventDriver;
import org.eclipse.jetty.websocket.io.WebSocketAsyncConnection;
import org.eclipse.jetty.websocket.io.AbstractWebSocketConnection;
public class WebSocketClientSelectorManager extends SelectorManager
{
@ -66,7 +67,7 @@ public class WebSocketClientSelectorManager extends SelectorManager
return sslContextFactory;
}
public Connection newAsyncConnection(SocketChannel channel, EndPoint endPoint, Object attachment)
public AbstractWebSocketConnection newWebSocketConnection(SocketChannel channel, EndPoint endPoint, Object attachment)
{
WebSocketClient.ConnectFuture confut = (WebSocketClient.ConnectFuture)attachment;
WebSocketClientFactory factory = confut.getFactory();
@ -77,7 +78,7 @@ public class WebSocketClientSelectorManager extends SelectorManager
ByteBufferPool bufferPool = factory.getBufferPool();
ScheduledExecutorService scheduler = factory.getScheduler();
WebSocketAsyncConnection connection = new WebSocketClientAsyncConnection(endPoint,executor,scheduler,policy,bufferPool,factory);
AbstractWebSocketConnection connection = new WebSocketClientConnection(endPoint,executor,scheduler,policy,bufferPool,factory);
endPoint.setConnection(connection);
connection.getParser().setIncomingFramesHandler(websocket);
@ -116,13 +117,13 @@ public class WebSocketClientSelectorManager extends SelectorManager
startHandshake(engine);
Connection connection = newAsyncConnection(channel,sslEndPoint,attachment);
Connection connection = newWebSocketConnection(channel,sslEndPoint,attachment);
endPoint.setConnection(connection);
return connection;
}
else
{
Connection connection = newAsyncConnection(channel,endPoint,attachment);
Connection connection = newWebSocketConnection(channel,endPoint,attachment);
endPoint.setConnection(connection);
return connection;
}

View File

@ -143,7 +143,7 @@ public class WebSocketClientTest
}
@Test
public void testAsyncConnectionRefused() throws Exception
public void testConnectionRefused() throws Exception
{
WebSocketClientFactory factory = new WebSocketClientFactory();
WebSocketClient client = factory.newWebSocketClient();

View File

@ -48,9 +48,9 @@ import org.eclipse.jetty.websocket.protocol.WebSocketFrame;
/**
* Provides the implementation of {@link WebSocketConnection} within the framework of the new {@link Connection} framework of jetty-io
*/
public abstract class WebSocketAsyncConnection extends AbstractConnection implements RawConnection, OutgoingFrames
public abstract class AbstractWebSocketConnection extends AbstractConnection implements RawConnection, OutgoingFrames
{
private static final Logger LOG = Log.getLogger(WebSocketAsyncConnection.class);
private static final Logger LOG = Log.getLogger(AbstractWebSocketConnection.class);
private static final Logger LOG_FRAMES = Log.getLogger("org.eclipse.jetty.websocket.io.Frames");
private final ByteBufferPool bufferPool;
@ -64,7 +64,7 @@ public abstract class WebSocketAsyncConnection extends AbstractConnection implem
private boolean flushing;
private AtomicLong writes;
public WebSocketAsyncConnection(EndPoint endp, Executor executor, ScheduledExecutorService scheduler, WebSocketPolicy policy, ByteBufferPool bufferPool)
public AbstractWebSocketConnection(EndPoint endp, Executor executor, ScheduledExecutorService scheduler, WebSocketPolicy policy, ByteBufferPool bufferPool)
{
super(endp,executor);
this.policy = policy;
@ -365,7 +365,7 @@ public abstract class WebSocketAsyncConnection extends AbstractConnection implem
return String.format("%s{g=%s,p=%s}",super.toString(),generator,parser);
}
private <C> void write(ByteBuffer buffer, WebSocketAsyncConnection webSocketAsyncConnection, FrameBytes<C> frameBytes)
private <C> void write(ByteBuffer buffer, AbstractWebSocketConnection webSocketConnection, FrameBytes<C> frameBytes)
{
EndPoint endpoint = getEndPoint();

View File

@ -25,7 +25,7 @@ public class ControlFrameBytes<C> extends FrameBytes<C>
{
private ByteBuffer buffer;
public ControlFrameBytes(WebSocketAsyncConnection connection, Callback<C> callback, C context, WebSocketFrame frame)
public ControlFrameBytes(AbstractWebSocketConnection connection, Callback<C> callback, C context, WebSocketFrame frame)
{
super(connection,callback,context,frame);
}

View File

@ -27,7 +27,7 @@ public class DataFrameBytes<C> extends FrameBytes<C>
private static final Logger LOG = Log.getLogger(DataFrameBytes.class);
private ByteBuffer buffer;
public DataFrameBytes(WebSocketAsyncConnection connection, Callback<C> callback, C context, WebSocketFrame frame)
public DataFrameBytes(AbstractWebSocketConnection connection, Callback<C> callback, C context, WebSocketFrame frame)
{
super(connection,callback,context,frame);
}

View File

@ -28,14 +28,14 @@ import org.eclipse.jetty.websocket.protocol.WebSocketFrame;
public abstract class FrameBytes<C> implements Callback<C>, Runnable
{
private final static Logger LOG = Log.getLogger(FrameBytes.class);
protected final WebSocketAsyncConnection connection;
protected final AbstractWebSocketConnection connection;
protected final Callback<C> callback;
protected final C context;
protected final WebSocketFrame frame;
// Task used to timeout the bytes
protected volatile ScheduledFuture<?> task;
protected FrameBytes(WebSocketAsyncConnection connection, Callback<C> callback, C context, WebSocketFrame frame)
protected FrameBytes(AbstractWebSocketConnection connection, Callback<C> callback, C context, WebSocketFrame frame)
{
this.connection = connection;
this.callback = callback;

View File

@ -6,14 +6,14 @@ import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.io.WebSocketAsyncConnection;
import org.eclipse.jetty.websocket.io.AbstractWebSocketConnection;
public class WebSocketServerAsyncConnection extends WebSocketAsyncConnection
public class WebSocketServerConnection extends AbstractWebSocketConnection
{
private final WebSocketServerFactory factory;
private boolean connected;
public WebSocketServerAsyncConnection(EndPoint endp, Executor executor, ScheduledExecutorService scheduler, WebSocketPolicy policy,
public WebSocketServerConnection(EndPoint endp, Executor executor, ScheduledExecutorService scheduler, WebSocketPolicy policy,
ByteBufferPool bufferPool, WebSocketServerFactory factory)
{
super(endp,executor,scheduler,policy,bufferPool);

View File

@ -356,7 +356,7 @@ public class WebSocketServerFactory extends AbstractLifeCycle implements WebSock
EndPoint endp = http.getEndPoint();
Executor executor = http.getConnector().getExecutor();
ByteBufferPool bufferPool = http.getConnector().getByteBufferPool();
WebSocketServerAsyncConnection connection = new WebSocketServerAsyncConnection(endp,executor,scheduler,websocket.getPolicy(),bufferPool,this);
WebSocketServerConnection connection = new WebSocketServerConnection(endp,executor,scheduler,websocket.getPolicy(),bufferPool,this);
// Tell jetty about the new connection
request.setAttribute(HttpConnection.UPGRADE_CONNECTION_ATTR,connection);