diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientConnection.java index e1cab1e7825..7e49588d68b 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientConnection.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientConnection.java @@ -87,8 +87,8 @@ public class NextProtoNegoClientConnection extends AbstractConnection implements { // Server does not support NPN, but this is a SPDY client, so hardcode SPDY EndPoint endPoint = getEndPoint(); - Connection connection = client.getDefaultAsyncConnectionFactory().newConnection(channel, endPoint, attachment); - client.replaceAsyncConnection(endPoint, connection); + Connection connection = client.getDefaultConnectionFactory().newConnection(channel, endPoint, attachment); + client.replaceConnection(endPoint, connection); completed = true; } @@ -99,8 +99,8 @@ public class NextProtoNegoClientConnection extends AbstractConnection implements if (protocol == null) return null; EndPoint endPoint = getEndPoint(); - Connection connection = client.getAsyncConnectionFactory(protocol).newConnection(channel, endPoint, attachment); - client.replaceAsyncConnection(endPoint, connection); + Connection connection = client.getConnectionFactory(protocol).newConnection(channel, endPoint, attachment); + client.replaceConnection(endPoint, connection); completed = true; return protocol; } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoServerConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoServerConnection.java index b78611f9210..4bf2fa4914b 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoServerConnection.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoServerConnection.java @@ -93,9 +93,9 @@ public class NextProtoNegoServerConnection extends AbstractConnection implements @Override public void protocolSelected(String protocol) { - ConnectionFactory ConnectionFactory = connector.getConnectionFactory(protocol); + ConnectionFactory connectionFactory = connector.getConnectionFactory(protocol); EndPoint endPoint = getEndPoint(); - Connection connection = ConnectionFactory.newConnection(channel, endPoint, connector); + Connection connection = connectionFactory.newConnection(channel, endPoint, connector); connector.replaceConnection(endPoint, connection); completed = true; } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java index 160715b1f53..4c68587b166 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java @@ -52,7 +52,7 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool; public class SPDYClient { private final Map factories = new ConcurrentHashMap<>(); - private final ConnectionFactory defaultAsyncConnectionFactory = new ClientSPDYAsyncConnectionFactory(); + private final ConnectionFactory defaultConnectionFactory = new ClientSPDYConnectionFactory(); private final short version; private final Factory factory; private volatile SocketAddress bindAddress; @@ -142,7 +142,7 @@ public class SPDYClient return null; } - public ConnectionFactory getAsyncConnectionFactory(String protocol) + public ConnectionFactory getConnectionFactory(String protocol) { for (Map.Entry entry : factories.entrySet()) { @@ -157,19 +157,19 @@ public class SPDYClient return null; } - public void putAsyncConnectionFactory(String protocol, ConnectionFactory factory) + public void putConnectionFactory(String protocol, ConnectionFactory factory) { factories.put(protocol, factory); } - public ConnectionFactory removeAsyncConnectionFactory(String protocol) + public ConnectionFactory removeConnectionFactory(String protocol) { return factories.remove(protocol); } - public ConnectionFactory getDefaultAsyncConnectionFactory() + public ConnectionFactory getDefaultConnectionFactory() { - return defaultAsyncConnectionFactory; + return defaultConnectionFactory; } protected SSLEngine newSSLEngine(SslContextFactory sslContextFactory, SocketChannel channel) @@ -186,7 +186,7 @@ public class SPDYClient return FlowControlStrategyFactory.newFlowControlStrategy(version); } - public void replaceAsyncConnection(EndPoint endPoint, Connection connection) + public void replaceConnection(EndPoint endPoint, Connection connection) { Connection oldConnection = endPoint.getConnection(); endPoint.setConnection(connection); @@ -202,33 +202,21 @@ public class SPDYClient private final Executor threadPool; private final SslContextFactory sslContextFactory; private final SelectorManager selector; - private final long defaultTimeout = 30000; private final long idleTimeout; - //TODO: Replace with Builder?! public Factory() { - this(null, null, 30000); + this(null, null); } public Factory(SslContextFactory sslContextFactory) { - this(null, sslContextFactory, 30000); - } - - public Factory(SslContextFactory sslContextFactory, long idleTimeout) - { - this(null, sslContextFactory, idleTimeout); + this(null, sslContextFactory); } public Factory(Executor threadPool) { - this(threadPool, null, 30000); - } - - public Factory(Executor threadPool, long idleTimeout) - { - this(threadPool, null, idleTimeout); + this(threadPool, null); } public Factory(Executor threadPool, SslContextFactory sslContextFactory) @@ -251,7 +239,7 @@ public class SPDYClient selector = new ClientSelectorManager(); addBean(selector); - factories.put("spdy/2", new ClientSPDYAsyncConnectionFactory()); + factories.put("spdy/2", new ClientSPDYConnectionFactory()); } public SPDYClient newSPDYClient(short version) @@ -315,9 +303,8 @@ public class SPDYClient long clientIdleTimeout = attachment.client.getIdleTimeout(); if (clientIdleTimeout < 0) clientIdleTimeout = idleTimeout; - EndPoint result = new SelectChannelEndPoint(channel, selectSet, key, scheduler, clientIdleTimeout); - return result; + return new SelectChannelEndPoint(channel, selectSet, key, scheduler, clientIdleTimeout); } @Override @@ -358,7 +345,7 @@ public class SPDYClient } else { - ConnectionFactory connectionFactory = new ClientSPDYAsyncConnectionFactory(); + ConnectionFactory connectionFactory = new ClientSPDYConnectionFactory(); Connection connection = connectionFactory.newConnection(channel, endPoint, attachment); endPoint.setConnection(connection); return connection; @@ -402,7 +389,7 @@ public class SPDYClient } } - private static class ClientSPDYAsyncConnectionFactory implements ConnectionFactory + private static class ClientSPDYConnectionFactory implements ConnectionFactory { @Override public Connection newConnection(SocketChannel channel, EndPoint endPoint, Object attachment) @@ -416,7 +403,6 @@ public class SPDYClient Generator generator = new Generator(factory.bufferPool, compressionFactory.newCompressor()); SPDYConnection connection = new ClientSPDYConnection(endPoint, factory.bufferPool, parser, factory); - endPoint.setConnection(connection); FlowControlStrategy flowControlStrategy = client.newFlowControlStrategy(); diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java index fa22a5a48ab..d98c5422671 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java @@ -53,8 +53,8 @@ public class SPDYServerConnector extends SelectChannelConnector super(server, sslContextFactory); this.listener = listener; setInitialWindowSize(65536); - putConnectionFactory("spdy/3", new ServerSPDYAsyncConnectionFactory(SPDY.V3, getByteBufferPool(), getExecutor(), getScheduler(), listener)); - putConnectionFactory("spdy/2", new ServerSPDYAsyncConnectionFactory(SPDY.V2, getByteBufferPool(), getExecutor(), getScheduler(), listener)); + putConnectionFactory("spdy/3", new ServerSPDYConnectionFactory(SPDY.V3, getByteBufferPool(), getExecutor(), getScheduler(), listener)); + putConnectionFactory("spdy/2", new ServerSPDYConnectionFactory(SPDY.V2, getByteBufferPool(), getExecutor(), getScheduler(), listener)); setDefaultConnectionFactory(getConnectionFactory("spdy/2")); } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYConnectionFactory.java similarity index 90% rename from jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java rename to jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYConnectionFactory.java index 12624d8bd01..0046c2aed8f 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYConnectionFactory.java @@ -25,7 +25,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 ConnectionFactory +public class ServerSPDYConnectionFactory implements ConnectionFactory { private final ByteBufferPool bufferPool; private final Executor threadPool; @@ -33,12 +33,12 @@ public class ServerSPDYAsyncConnectionFactory implements ConnectionFactory private final short version; private final ServerSessionFrameListener listener; - public ServerSPDYAsyncConnectionFactory(short version, ByteBufferPool bufferPool, Executor threadPool, ScheduledExecutorService scheduler) + public ServerSPDYConnectionFactory(short version, ByteBufferPool bufferPool, Executor threadPool, ScheduledExecutorService scheduler) { this(version, bufferPool, threadPool, scheduler, null); } - public ServerSPDYAsyncConnectionFactory(short version, ByteBufferPool bufferPool, Executor threadPool, ScheduledExecutorService scheduler, ServerSessionFrameListener listener) + public ServerSPDYConnectionFactory(short version, ByteBufferPool bufferPool, Executor threadPool, ScheduledExecutorService scheduler, ServerSessionFrameListener listener) { this.version = version; this.bufferPool = bufferPool; @@ -63,7 +63,6 @@ public class ServerSPDYAsyncConnectionFactory implements ConnectionFactory ServerSessionFrameListener listener = provideServerSessionFrameListener(endPoint, attachment); SPDYConnection connection = new ServerSPDYConnection(endPoint, bufferPool, parser, listener, connector); - endPoint.setConnection(connection); FlowControlStrategy flowControlStrategy = connector.newFlowControlStrategy(version); diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java index 412a69b50b5..3c348701639 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java @@ -61,7 +61,7 @@ public abstract class AbstractTest connector = newSPDYServerConnector(listener); if (listener == null) listener = connector.getServerSessionFrameListener(); - connector.setDefaultConnectionFactory(new ServerSPDYAsyncConnectionFactory(version, connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), listener)); + connector.setDefaultConnectionFactory(new ServerSPDYConnectionFactory(version, connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), listener)); connector.setPort(0); server.addConnector(connector); server.start();