jetty-9 rudimentary connectionFactory impl

This commit is contained in:
Greg Wilkins 2012-08-02 17:44:29 +10:00
parent b52930be14
commit b63e09df61
28 changed files with 223 additions and 186 deletions

View File

@ -60,7 +60,7 @@ public class LikeJettyXml
SelectChannelConnector connector = new SelectChannelConnector(server);
connector.setPort(8080);
connector.setIdleTimeout(30000);
connector.getHttpConfig().setConfidentialPort(8443);
connector.getConnectionFactory().getHttpConfig().setConfidentialPort(8443);
// TODO connector.setStatsOn(false);
server.setConnectors(new Connector[]
@ -68,7 +68,7 @@ public class LikeJettyXml
SelectChannelConnector ssl_connector = new SelectChannelConnector(server,true);
ssl_connector.setPort(8443);
SslContextFactory cf = ssl_connector.getSslContextFactory();
SslContextFactory cf = ssl_connector.getConnectionFactory().getSslContextFactory();
cf.setKeyStorePath(jetty_home + "/etc/keystore");
cf.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
cf.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");

View File

@ -42,7 +42,7 @@ public class ManyConnectors
String jetty_home = System.getProperty("jetty.home","../jetty-distribution/target/distribution");
System.setProperty("jetty.home",jetty_home);
ssl_connector.setPort(8443);
SslContextFactory cf = ssl_connector.getSslContextFactory();
SslContextFactory cf = ssl_connector.getConnectionFactory().getSslContextFactory();
cf.setKeyStorePath(jetty_home + "/etc/keystore");
cf.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
cf.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");

View File

@ -57,11 +57,12 @@ public class DataConstraintsTest
_server = new Server();
_connector = new LocalConnector(_server);
_connector.setIdleTimeout(300000);
_connector.getHttpConfig().setIntegralPort(9998);
_connector.getHttpConfig().setIntegralScheme("FTP");
_connector.getHttpConfig().setConfidentialPort(9999);
_connector.getHttpConfig().setConfidentialScheme("SPDY");
_connectorS = new LocalConnector(_server,new HttpConfiguration(null,false)
_connector.getConnectionFactory().getHttpConfig().setIntegralPort(9998);
_connector.getConnectionFactory().getHttpConfig().setIntegralScheme("FTP");
_connector.getConnectionFactory().getHttpConfig().setConfidentialPort(9999);
_connector.getConnectionFactory().getHttpConfig().setConfidentialScheme("SPDY");
_connectorS = new LocalConnector(_server,
new HttpConfiguration(null,false)
{
@Override
public void customize(Request request) throws IOException
@ -82,7 +83,7 @@ public class DataConstraintsTest
{
return true;
}
},null,null,null,null,false,0);
});
_server.setConnectors(new Connector[]{_connector,_connectorS});
ContextHandler _context = new ContextHandler();

View File

@ -50,18 +50,12 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
protected final Logger LOG = Log.getLogger(getClass());
private final Statistics _stats = new ConnectionStatistics();
private final ConnectionFactory _connectionFactory;
private final Thread[] _acceptors;
private final Executor _executor;
private final ScheduledExecutorService _scheduler;
private final Server _server;
private final ByteBufferPool _byteBufferPool;
private final boolean _ssl;
private final SslContextFactory _sslContextFactory;
/**
* @deprecated Make this part of pluggable factory
*/
private final HttpConfiguration _httpConfig;
private volatile String _name;
private volatile int _acceptQueueSize = 128;
@ -69,41 +63,21 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
private volatile long _idleTimeout = 200000;
private volatile int _soLingerTime = -1;
public AbstractConnector(@Name("server") Server server)
{
this(server,null);
}
public AbstractConnector(Server server,SslContextFactory sslContextFactory)
{
this(server,null,null,null,null, sslContextFactory, sslContextFactory!=null, 0);
}
public AbstractConnector(Server server,boolean ssl)
{
this(server,null,null,null,null, ssl?new SslContextFactory():null, ssl, 0);
}
/* ------------------------------------------------------------ */
/**
* @param server The server this connector will be added to. Must not be null.
* @param httpConfig TODO
* @param connectionFactory ConnectionFactory or null for default
* @param executor An executor for this connector or null to use the servers executor
* @param scheduler A scheduler for this connector or null to use the servers scheduler
* @param pool A buffer pool for this connector or null to use a default {@link ByteBufferPool}
* @param sslContextFactory An SslContextFactory to use or null if no ssl is required or to use default {@link SslContextFactory}
* @param ssl If true, then new connections will assumed to be SSL. If false, connections can only become SSL if they upgrade and a SslContextFactory is passed.
* @param acceptors the number of acceptor threads to use, or 0 for a default value.
*/
public AbstractConnector(
Server server,
HttpConfiguration httpConfig,
ConnectionFactory connectionFactory,
Executor executor,
ScheduledExecutorService scheduler,
ByteBufferPool pool,
SslContextFactory sslContextFactory,
boolean ssl, int acceptors)
ByteBufferPool pool, int acceptors)
{
_server=server;
_executor=executor!=null?executor:_server.getThreadPool();
@ -117,25 +91,13 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
});
_byteBufferPool = pool!=null?pool:new StandardByteBufferPool();
_ssl=ssl;
_sslContextFactory=sslContextFactory!=null?sslContextFactory:(ssl?new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH):null);
// TODO make this pluggable
_httpConfig = httpConfig!=null?httpConfig:new HttpConfiguration(_sslContextFactory,ssl);
_connectionFactory=connectionFactory!=null?connectionFactory:new ConnectionFactory();
addBean(_server,false);
addBean(_executor,executor==null);
addBean(_scheduler,scheduler==null);
addBean(_byteBufferPool,pool==null);
if (_sslContextFactory!=null)
addBean(_sslContextFactory,sslContextFactory==null);
if (_sslContextFactory!=null)
{
addBean(_sslContextFactory,false);
setSoLingerTime(30000);
}
addBean(_httpConfig,httpConfig==null);
addBean(_connectionFactory,connectionFactory!=null);
if (acceptors<=0)
acceptors=Math.max(1,(Runtime.getRuntime().availableProcessors()) / 4);
@ -155,7 +117,13 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
{
return _server;
}
@Override
public ConnectionFactory getConnectionFactory()
{
return _connectionFactory;
}
@Override
public Executor getExecutor()
{
@ -168,33 +136,6 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
return _byteBufferPool;
}
@Override
public SslContextFactory getSslContextFactory()
{
return _sslContextFactory;
}
public HttpConfiguration getHttpConfig()
{
return _httpConfig;
}
protected Connection newConnection(EndPoint endp) throws IOException
{
// TODO make this a plugable configurable connection factory for HTTP, HTTPS, SPDY & Websocket
if (_ssl)
{
SSLEngine engine = _sslContextFactory.createSSLEngine(endp.getRemoteAddress());
SslConnection ssl_connection = new SslConnection(getByteBufferPool(), getExecutor(), endp, engine);
Connection http_connection = new HttpConnection(_httpConfig,this,ssl_connection.getDecryptedEndPoint());
ssl_connection.getDecryptedEndPoint().setConnection(http_connection);
return ssl_connection;
}
return new HttpConnection(_httpConfig,this,endp);
}
/**
* @return Returns the maxIdleTime.
*/

View File

@ -25,25 +25,9 @@ public abstract class AbstractNetConnector extends AbstractConnector implements
private volatile String _host;
private volatile int _port = 0;
public AbstractNetConnector(Server server, boolean ssl)
public AbstractNetConnector(Server server, ConnectionFactory connectionFactory, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool, int acceptors)
{
super(server,ssl);
}
public AbstractNetConnector(Server server, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool, SslContextFactory sslContextFactory,
boolean ssl, int acceptors)
{
super(server,null,executor,scheduler,pool,sslContextFactory,ssl, acceptors);
}
public AbstractNetConnector(Server server, SslContextFactory sslContextFactory)
{
super(server,sslContextFactory);
}
public AbstractNetConnector(Server server)
{
super(server);
super(server,connectionFactory,executor,scheduler,pool, acceptors);
}
public void setHost(String host)

View File

@ -0,0 +1,92 @@
// ========================================================================
// Copyright (c) 2004-2012 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 javax.net.ssl.SSLEngine;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.ssl.SslContextFactory;
// TODO This is just a place holder for a real factory
public class ConnectionFactory extends AggregateLifeCycle
{
private final boolean _ssl;
private final SslContextFactory _sslContextFactory;
// TODO Make this part of pluggable factory
private final HttpConfiguration _httpConfig;
ConnectionFactory()
{
this(null,false);
}
/* ------------------------------------------------------------ */
/**
* @param sslContextFactory An SslContextFactory to use or null if no ssl is required or to use default {@link SslContextFactory}
* @param ssl If true, then new connections will assumed to be SSL. If false, connections can only become SSL if they upgrade and a SslContextFactory is passed.
*/
ConnectionFactory(SslContextFactory sslContextFactory, boolean ssl)
{
this(null,sslContextFactory,ssl);
}
ConnectionFactory(HttpConfiguration httpConfig, SslContextFactory sslContextFactory, boolean ssl)
{
_ssl=ssl;
_sslContextFactory=sslContextFactory!=null?sslContextFactory:(ssl?new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH):null);
addBean(_sslContextFactory,sslContextFactory==null);
// TODO make this pluggable
_httpConfig = httpConfig!=null?httpConfig:new HttpConfiguration(_sslContextFactory,ssl);
addBean(_httpConfig,httpConfig==null);
}
protected Connection newConnection(Connector connector,EndPoint endp) throws IOException
{
if (_ssl)
{
SSLEngine engine = _sslContextFactory.createSSLEngine(endp.getRemoteAddress());
SslConnection ssl_connection = new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endp, engine);
Connection http_connection = new HttpConnection(_httpConfig,connector,ssl_connection.getDecryptedEndPoint());
ssl_connection.getDecryptedEndPoint().setConnection(http_connection);
return ssl_connection;
}
return new HttpConnection(_httpConfig,connector,endp);
}
public SslContextFactory getSslContextFactory()
{
return _sslContextFactory;
}
public HttpConfiguration getHttpConfig()
{
return _httpConfig;
}
}

View File

@ -1,3 +1,16 @@
// ========================================================================
// Copyright (c) 2004-2012 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.util.concurrent.atomic.AtomicLong;

View File

@ -1,5 +1,5 @@
// ========================================================================
// Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
// Copyright (c) 2004-2012 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
@ -43,6 +43,9 @@ public interface Connector extends LifeCycle
/* ------------------------------------------------------------ */
Server getServer();
/* ------------------------------------------------------------ */
ConnectionFactory getConnectionFactory();
/* ------------------------------------------------------------ */
Executor getExecutor();
@ -52,9 +55,6 @@ public interface Connector extends LifeCycle
/* ------------------------------------------------------------ */
ByteBufferPool getByteBufferPool();
/* ------------------------------------------------------------ */
SslContextFactory getSslContextFactory();
/* ------------------------------------------------------------ */
/**
* @return Max Idle time for connections in milliseconds

View File

@ -39,26 +39,31 @@ public class LocalConnector extends AbstractConnector
public LocalConnector(Server server)
{
super(server,null,null,null,null, null,false, -1);
this(server,null,null,null,null, -1);
}
public LocalConnector(Server server, boolean ssl)
{
super(server,ssl);
this(server,new ConnectionFactory(null,ssl),null,null,null,0);
manage(getConnectionFactory());
}
public LocalConnector(Server server, HttpConfiguration httpConfig, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool,
SslContextFactory sslContextFactory, boolean ssl, int acceptors)
public LocalConnector(Server server, HttpConfiguration httpConfig)
{
super(server,httpConfig,executor,scheduler,pool,sslContextFactory,ssl, acceptors);
this(server,new ConnectionFactory(httpConfig,null,false),null,null,null,0);
manage(getConnectionFactory());
}
public LocalConnector(Server server, SslContextFactory sslContextFactory)
{
super(server,sslContextFactory);
this(server,new ConnectionFactory(sslContextFactory,sslContextFactory!=null),null,null,null,0);
manage(getConnectionFactory());
}
public LocalConnector(Server server, ConnectionFactory connectionFactory, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool,
int acceptors)
{
super(server,connectionFactory,executor,scheduler,pool,acceptors);
setIdleTimeout(30000);
}
@ -158,7 +163,7 @@ public class LocalConnector extends AbstractConnector
{
LOG.debug("accepting {}",acceptorID);
LocalEndPoint endp = _connects.take();
Connection connection=newConnection(endp);
Connection connection=getConnectionFactory().newConnection(LocalConnector.this,endp);
endp.setConnection(connection);
endp.onOpen();
connection.onOpen();

View File

@ -66,21 +66,29 @@ public class SelectChannelConnector extends AbstractNetConnector
/* ------------------------------------------------------------ */
public SelectChannelConnector(Server server)
{
this(server,null,null,null,null,false,0,0);
this(server,null,null,null,null,0,0);
}
/* ------------------------------------------------------------ */
public SelectChannelConnector(Server server, boolean ssl)
{
this(server,null,null,null,null,ssl,0,0);
this(server,new ConnectionFactory(null,ssl));
manage(getConnectionFactory());
}
/* ------------------------------------------------------------ */
public SelectChannelConnector(Server server, SslContextFactory sslContextFactory)
{
this(server,null,null,null,sslContextFactory,sslContextFactory!=null,0,0);
this(server,new ConnectionFactory(sslContextFactory,sslContextFactory!=null));
manage(getConnectionFactory());
}
/* ------------------------------------------------------------ */
public SelectChannelConnector(Server server, ConnectionFactory connectionFactory)
{
this(server,connectionFactory,null,null,null,0,0);
}
/* ------------------------------------------------------------ */
/**
@ -88,23 +96,24 @@ public class SelectChannelConnector extends AbstractNetConnector
* @param executor An executor for this connector or null to use the servers executor
* @param scheduler A scheduler for this connector or null to use the servers scheduler
* @param pool A buffer pool for this connector or null to use a default {@link ByteBufferPool}
* @param sslContextFactory An SslContextFactory to use or null if no ssl is required or to use default {@link SslContextFactory}
* @param ssl If true, then new connections will assumed to be SSL. If false, connections can only become SSL if they upgrade and a SslContextFactory is passed.
* @param acceptors the number of acceptor threads to use, or 0 for a default value.
*/
public SelectChannelConnector(
@Name("server") Server server,
@Name("connectionFactory") ConnectionFactory connectionFactory,
@Name("executor") Executor executor,
@Name("scheduler") ScheduledExecutorService scheduler,
@Name("bufferPool") ByteBufferPool pool,
@Name("sslContextFactory") SslContextFactory sslContextFactory,
@Name("ssl") boolean ssl,
@Name("acceptors") int acceptors,
@Name("selectors") int selectors)
{
super(server,executor,scheduler,pool,sslContextFactory,ssl,acceptors);
super(server,connectionFactory,executor,scheduler,pool,acceptors);
_manager=new ConnectorSelectorManager(selectors!=0?selectors:Math.max(1,(Runtime.getRuntime().availableProcessors())/4));
addBean(_manager,true);
// TODO yuck
if (getConnectionFactory().getSslContextFactory()!=null)
setSoLingerTime(30000);
}
@ -287,7 +296,7 @@ public class SelectChannelConnector extends AbstractNetConnector
@Override
public Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment) throws IOException
{
return SelectChannelConnector.this.newConnection(endpoint);
return getConnectionFactory().newConnection(SelectChannelConnector.this,endpoint);
}
}
}

View File

@ -41,22 +41,6 @@ public class NetworkTrafficSelectChannelConnector extends SelectChannelConnector
{
private final List<NetworkTrafficListener> listeners = new CopyOnWriteArrayList<NetworkTrafficListener>();
public NetworkTrafficSelectChannelConnector(Server server, boolean ssl)
{
super(server,ssl);
}
public NetworkTrafficSelectChannelConnector(Server server, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool,
SslContextFactory sslContextFactory, boolean ssl, int acceptors, int selectors)
{
super(server,executor,scheduler,pool,sslContextFactory,ssl,acceptors,selectors);
}
public NetworkTrafficSelectChannelConnector(Server server, SslContextFactory sslContextFactory)
{
super(server,sslContextFactory);
}
public NetworkTrafficSelectChannelConnector(Server server)
{

View File

@ -96,7 +96,7 @@ public class CheckReverseProxyHeadersTest
LocalConnector connector = new LocalConnector(server);
// Activate reverse proxy headers checking
connector.getHttpConfig().setForwarded(true);
connector.getConnectionFactory().getHttpConfig().setForwarded(true);
server.setConnectors(new Connector[] {connector});
ValidationHandler validationHandler = new ValidationHandler(requestValidator);

View File

@ -61,8 +61,8 @@ public class HttpConnectionTest
server = new Server();
connector = new LocalConnector(server);
server.addConnector(connector);
connector.getHttpConfig().setRequestHeaderSize(1024);
connector.getHttpConfig().setResponseHeaderSize(1024);
connector.getConnectionFactory().getHttpConfig().setRequestHeaderSize(1024);
connector.getConnectionFactory().getHttpConfig().setResponseHeaderSize(1024);
server.setHandler(new DumpHandler());
server.start();
}

View File

@ -64,11 +64,11 @@ public class RequestTest
{
_server = new Server();
_connector = new LocalConnector(_server);
_connector.getHttpConfig().setRequestHeaderSize(512);
_connector.getHttpConfig().setRequestBufferSize(1024);
_connector.getHttpConfig().setResponseHeaderSize(512);
_connector.getHttpConfig().setResponseBufferSize(2048);
_connector.getHttpConfig().setForwarded(true);
_connector.getConnectionFactory().getHttpConfig().setRequestHeaderSize(512);
_connector.getConnectionFactory().getHttpConfig().setRequestBufferSize(1024);
_connector.getConnectionFactory().getHttpConfig().setResponseHeaderSize(512);
_connector.getConnectionFactory().getHttpConfig().setResponseBufferSize(2048);
_connector.getConnectionFactory().getHttpConfig().setForwarded(true);
_server.addConnector(_connector);
_handler = new RequestHandler();
_server.setHandler(_handler);

View File

@ -43,12 +43,12 @@ public class SlowClientWithPipelinedRequestTest
public void startServer(Handler handler) throws Exception
{
server = new Server();
connector = new SelectChannelConnector(server)
connector = new SelectChannelConnector(server,new ConnectionFactory()
{
@Override
protected Connection newConnection(EndPoint endpoint)
protected Connection newConnection(Connector connector,EndPoint endpoint)
{
return new HttpConnection(getHttpConfig(),this,endpoint)
return new HttpConnection(getHttpConfig(),connector,endpoint)
{
@Override
public synchronized void onFillable()
@ -58,7 +58,8 @@ public class SlowClientWithPipelinedRequestTest
}
};
}
};
},null,null,null,0,0);
server.addConnector(connector);
connector.setPort(0);
server.setHandler(handler);

View File

@ -86,7 +86,7 @@ public class StressTest
_threads.setMaxThreads(200);
_server = new Server(_threads);
_connector = new SelectChannelConnector(_server,null,null,null,null,false,1,1);
_connector = new SelectChannelConnector(_server,null,null,null,null,1,1);
_connector.setAcceptQueueSize(5000);
_connector.setIdleTimeout(30000);
_server.addConnector(_connector);

View File

@ -380,6 +380,7 @@ public class ContextHandlerTest
Assert.assertTrue(response.indexOf("Goodbye")>0);
Assert.assertTrue(response.indexOf("dead")<0);
Thread.sleep(100);
Assert.assertTrue(handler.error);
Assert.assertTrue(handler.throwable!=null);
}

View File

@ -78,9 +78,9 @@ public class SSLCloseTest extends TestCase
String keystore = System.getProperty("user.dir")+File.separator+"src"+File.separator+"test"+File.separator+"resources"+File.separator+"keystore";
connector.setPort(0);
connector.getSslContextFactory().setKeyStorePath(keystore);
connector.getSslContextFactory().setKeyStorePassword("storepwd");
connector.getSslContextFactory().setKeyManagerPassword("keypwd");
connector.getConnectionFactory().getSslContextFactory().setKeyStorePath(keystore);
connector.getConnectionFactory().getSslContextFactory().setKeyStorePassword("storepwd");
connector.getConnectionFactory().getSslContextFactory().setKeyManagerPassword("keypwd");
server.setConnectors(new Connector[]
{ connector });

View File

@ -94,12 +94,12 @@ public class SSLEngineTest
String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath();
connector.setPort(0);
SslContextFactory cf = connector.getSslContextFactory();
SslContextFactory cf = connector.getConnectionFactory().getSslContextFactory();
cf.setKeyStorePath(keystore);
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");
connector.getHttpConfig().setRequestBufferSize(512);
connector.getHttpConfig().setRequestHeaderSize(512);
connector.getConnectionFactory().getHttpConfig().setRequestBufferSize(512);
connector.getConnectionFactory().getHttpConfig().setRequestHeaderSize(512);
server.setConnectors(new Connector[]{connector });
}
@ -117,6 +117,7 @@ public class SSLEngineTest
{
server.setHandler(new HelloWorldHandler());
server.start();
server.dumpStdErr();
SSLContext ctx=SSLContext.getInstance("TLS");
ctx.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom());

View File

@ -56,7 +56,7 @@ public class SSLSelectChannelConnectorLoadTest
server.addConnector(connector);
String keystorePath = System.getProperty("basedir", ".") + "/src/test/resources/keystore";
SslContextFactory cf = connector.getSslContextFactory();
SslContextFactory cf = connector.getConnectionFactory().getSslContextFactory();
cf.setKeyStorePath(keystorePath);
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");
@ -68,7 +68,7 @@ public class SSLSelectChannelConnectorLoadTest
server.start();
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(new FileInputStream(connector.getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
keystore.load(new FileInputStream(connector.getConnectionFactory().getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keystore);
sslContext = SSLContext.getInstance("SSL");

View File

@ -25,6 +25,7 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import org.eclipse.jetty.server.HttpServerTestBase;
import org.eclipse.jetty.server.SelectChannelConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.BeforeClass;
import org.junit.Ignore;
@ -49,10 +50,10 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
@BeforeClass
public static void init() throws Exception
{
SslSelectChannelConnector connector = new SslSelectChannelConnector(_server);
SelectChannelConnector connector = new SelectChannelConnector(_server,true);
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
SslContextFactory cf = connector.getSslContextFactory();
SslContextFactory cf = connector.getConnectionFactory().getSslContextFactory();
cf.setKeyStorePath(keystorePath);
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");
@ -62,7 +63,7 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(new FileInputStream(connector.getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
keystore.load(new FileInputStream(connector.getConnectionFactory().getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keystore);
__sslContext = SSLContext.getInstance("TLS");

View File

@ -99,7 +99,7 @@ public class SslBytesServerTest extends SslBytesTest
connector.setPort(0);
File keyStore = MavenTestingUtils.getTestResourceFile("keystore");
SslContextFactory cf = connector.getSslContextFactory();
SslContextFactory cf = connector.getConnectionFactory().getSslContextFactory();
cf.setKeyStorePath(keyStore.getAbsolutePath());
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");

View File

@ -21,6 +21,7 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import org.eclipse.jetty.server.ConnectorTimeoutTest;
import org.eclipse.jetty.server.SelectChannelConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.BeforeClass;
@ -37,10 +38,10 @@ public class SslSelectChannelTimeoutTest extends ConnectorTimeoutTest
@BeforeClass
public static void init() throws Exception
{
SslSelectChannelConnector connector = new SslSelectChannelConnector(_server);
SelectChannelConnector connector = new SelectChannelConnector(_server,true);
connector.setIdleTimeout(MAX_IDLE_TIME); //250 msec max idle
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
SslContextFactory cf = connector.getSslContextFactory();
SslContextFactory cf = connector.getConnectionFactory().getSslContextFactory();
cf.setKeyStorePath(keystorePath);
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");
@ -49,7 +50,7 @@ public class SslSelectChannelTimeoutTest extends ConnectorTimeoutTest
startServer(connector);
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(new FileInputStream(connector.getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
keystore.load(new FileInputStream(connector.getConnectionFactory().getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keystore);
__sslContext = SSLContext.getInstance("SSL");

View File

@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.SelectChannelConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.IO;
@ -47,18 +48,18 @@ import org.junit.Test;
public class SslUploadTest
{
private static Server server;
private static SslSelectChannelConnector connector;
private static SelectChannelConnector connector;
private static int total;
@BeforeClass
public static void startServer() throws Exception
{
server = new Server();
connector = new SslSelectChannelConnector(server);
connector = new SelectChannelConnector(server,true);
server.addConnector(connector);
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
SslContextFactory cf = connector.getSslContextFactory();
SslContextFactory cf = connector.getConnectionFactory().getSslContextFactory();
cf.setKeyStorePath(keystorePath);
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");
@ -82,7 +83,7 @@ public class SslUploadTest
public void test() throws Exception
{
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(new FileInputStream(connector.getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
keystore.load(new FileInputStream(connector.getConnectionFactory().getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keystore);
SSLContext sslContext = SSLContext.getInstance("SSL");

View File

@ -23,7 +23,7 @@ import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.Callback;
public class EmptyEndPoint implements EndPoint
public class EmptyAsyncEndPoint implements EndPoint
{
private boolean checkForIdle;
private Connection connection;

View File

@ -1392,6 +1392,8 @@ public class SslContextFactory extends AbstractLifeCycle
/* ------------------------------------------------------------ */
public SSLEngine newSslEngine(String host,int port)
{
if (!isRunning())
throw new IllegalStateException("!STARTED");
SSLEngine sslEngine=isSessionCachingEnabled()
?_context.createSSLEngine(host, port)
:_context.createSSLEngine();
@ -1403,6 +1405,8 @@ public class SslContextFactory extends AbstractLifeCycle
/* ------------------------------------------------------------ */
public SSLEngine newSslEngine()
{
if (!isRunning())
throw new IllegalStateException("!STARTED");
SSLEngine sslEngine=_context.createSSLEngine();
customize(sslEngine);
return sslEngine;

View File

@ -98,7 +98,7 @@ public class WebSocketOverSSLTest
_server = new Server();
SelectChannelConnector connector = new SelectChannelConnector(_server,true);
_server.addConnector(connector);
SslContextFactory cf = connector.getSslContextFactory();
SslContextFactory cf = connector.getConnectionFactory().getSslContextFactory();
cf.setKeyStorePath(MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath());
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");

View File

@ -56,7 +56,12 @@ public class TestServer
String jetty_root = "..";
Server server = new Server();
// Setup Threadpool
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(100);
// Setup server
Server server = new Server(threadPool);
server.setSendDateHeader(true);
// Setup JMX
@ -65,30 +70,23 @@ public class TestServer
server.addBean(mbContainer);
mbContainer.addBean(Log.getLog());
// Setup Threadpool
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(100);
server.setThreadPool(threadPool);
// Setup Connectors
SelectChannelConnector connector0 = new SelectChannelConnector();
SelectChannelConnector connector0 = new SelectChannelConnector(server);
connector0.setPort(8080);
connector0.setMaxIdleTime(30000);
connector0.setConfidentialPort(8443);
connector0.setIdleTimeout(30000);
connector0.getConnectionFactory().getHttpConfig().setConfidentialPort(8443);
server.addConnector(connector0);
// Setup Connectors
SelectChannelConnector connector1 = new SelectChannelConnector();
SelectChannelConnector connector1 = new SelectChannelConnector(server);
connector1.setPort(8081);
connector1.setMaxIdleTime(30000);
connector1.setConfidentialPort(8443);
connector0.setIdleTimeout(30000);
connector1.getConnectionFactory().getHttpConfig().setConfidentialPort(8443);
server.addConnector(connector1);
SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector();
SelectChannelConnector ssl_connector = new SelectChannelConnector(server,true);
ssl_connector.setPort(8443);
SslContextFactory cf = ssl_connector.getSslContextFactory();
SslContextFactory cf = ssl_connector.getConnectionFactory().getSslContextFactory();
cf.setKeyStorePath(jetty_root + "/jetty-server/src/main/config/etc/keystore");
cf.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
cf.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");