jetty-9 factoring out HTTP dependencies from connectors
This commit is contained in:
parent
acabe78101
commit
7bee81fa82
|
@ -200,9 +200,10 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
* @param endpoint the endpoint
|
||||
* @param attachment the attachment
|
||||
* @return a new connection
|
||||
* @throws IOException
|
||||
* @see #newEndPoint(SocketChannel, ManagedSelector, SelectionKey)
|
||||
*/
|
||||
public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment);
|
||||
public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment) throws IOException;
|
||||
|
||||
/**
|
||||
* <p>Callback method invoked when a non-blocking connect cannot be completed.</p>
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
|
||||
import org.eclipse.jetty.http.PathMap;
|
||||
import org.eclipse.jetty.server.HttpChannel;
|
||||
import org.eclipse.jetty.server.HttpConnector;
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
|
@ -355,7 +355,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
|
|||
return true;
|
||||
}
|
||||
|
||||
HttpConnector connector = HttpChannel.getCurrentHttpChannel().getHttpConnector();
|
||||
HttpConfiguration connector = HttpChannel.getCurrentHttpChannel().getHttpConfiguration();
|
||||
|
||||
if (dataConstraint == UserDataConstraint.Integral)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
|
||||
import org.eclipse.jetty.security.authentication.FormAuthenticator;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
|
@ -55,7 +55,7 @@ public class ConstraintTest
|
|||
{
|
||||
private static final String TEST_REALM = "TestRealm";
|
||||
private static Server _server;
|
||||
private static LocalHttpConnector _connector;
|
||||
private static LocalConnector _connector;
|
||||
private static SessionHandler _session;
|
||||
private ConstraintSecurityHandler _security;
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class ConstraintTest
|
|||
public static void startServer()
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector = new LocalConnector(_server);
|
||||
_server.setConnectors(new Connector[]{_connector});
|
||||
|
||||
ContextHandler _context = new ContextHandler();
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.jetty.http.HttpMethod;
|
|||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
|
@ -44,8 +44,8 @@ import static org.junit.matchers.JUnitMatchers.containsString;
|
|||
public class DataConstraintsTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalHttpConnector _connectorS;
|
||||
private LocalConnector _connector;
|
||||
private LocalConnector _connectorS;
|
||||
private SessionHandler _session;
|
||||
private ConstraintSecurityHandler _security;
|
||||
|
||||
|
@ -53,13 +53,13 @@ public class DataConstraintsTest
|
|||
public void startServer()
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector = new LocalConnector(_server);
|
||||
_connector.setIdleTimeout(300000);
|
||||
_connector.setIntegralPort(9998);
|
||||
_connector.setIntegralScheme("FTP");
|
||||
_connector.setConfidentialPort(9999);
|
||||
_connector.setConfidentialScheme("SPDY");
|
||||
_connectorS = new LocalHttpConnector()
|
||||
_connector.getHttpConfig().setIntegralPort(9998);
|
||||
_connector.getHttpConfig().setIntegralScheme("FTP");
|
||||
_connector.getHttpConfig().setConfidentialPort(9999);
|
||||
_connector.getHttpConfig().setConfidentialScheme("SPDY");
|
||||
_connectorS = new LocalConnector(_server)
|
||||
{
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,15 +16,23 @@ package org.eclipse.jetty.server;
|
|||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import org.eclipse.jetty.io.AsyncConnection;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.StandardByteBufferPool;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
/**
|
||||
* Abstract Connector implementation. This abstract implementation of the Connector interface provides:
|
||||
|
@ -43,22 +51,96 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
|
||||
private final Statistics _stats = new ConnectionStatistics();
|
||||
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 Server _server;
|
||||
private volatile Executor _executor;
|
||||
private volatile int _acceptQueueSize = 128;
|
||||
private volatile boolean _reuseAddress = true;
|
||||
private volatile ByteBufferPool _byteBufferPool;
|
||||
private volatile long _idleTimeout = 200000;
|
||||
private volatile int _soLingerTime = -1;
|
||||
|
||||
public AbstractConnector()
|
||||
public AbstractConnector(@Name("server") Server server)
|
||||
{
|
||||
this(Math.max(1, (Runtime.getRuntime().availableProcessors()) / 4));
|
||||
this(server,null);
|
||||
}
|
||||
|
||||
public AbstractConnector(@Name("acceptors") int acceptors)
|
||||
public AbstractConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("sslContextFactory") SslContextFactory sslContextFactory)
|
||||
{
|
||||
this(server,null,null,null,sslContextFactory, sslContextFactory!=null, 0);
|
||||
}
|
||||
|
||||
public AbstractConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("ssl") boolean ssl)
|
||||
{
|
||||
this(server,null,null,null,ssl?new SslContextFactory():null, ssl, 0);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param server The server this connector will be added to. Must not be null.
|
||||
* @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,
|
||||
Executor executor,
|
||||
ScheduledExecutorService scheduler,
|
||||
ByteBufferPool pool,
|
||||
SslContextFactory sslContextFactory,
|
||||
boolean ssl,
|
||||
int acceptors)
|
||||
{
|
||||
_server=server;
|
||||
_executor=executor!=null?executor:_server.getThreadPool();
|
||||
_scheduler=scheduler!=null?scheduler:Executors.newSingleThreadScheduledExecutor(new ThreadFactory()
|
||||
{
|
||||
@Override
|
||||
public Thread newThread(Runnable r)
|
||||
{
|
||||
return new Thread(r, "Timer-" + getName());
|
||||
}
|
||||
});
|
||||
_byteBufferPool = pool!=null?pool:new StandardByteBufferPool();
|
||||
|
||||
_ssl=ssl;
|
||||
_sslContextFactory=sslContextFactory!=null?sslContextFactory:(ssl?new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH):null);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// TODO make this pluggable
|
||||
_httpConfig = new HttpConfiguration(_sslContextFactory,ssl);
|
||||
|
||||
if (acceptors<=0)
|
||||
acceptors=Math.max(1,(Runtime.getRuntime().availableProcessors()) / 4);
|
||||
if (acceptors > 2 * Runtime.getRuntime().availableProcessors())
|
||||
LOG.warn("Acceptors should be <= 2*availableProcessors: " + this);
|
||||
_acceptors = new Thread[acceptors];
|
||||
|
@ -76,42 +158,43 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
return _server;
|
||||
}
|
||||
|
||||
public void setServer(Server server)
|
||||
{
|
||||
_server = server;
|
||||
}
|
||||
|
||||
public Executor findExecutor()
|
||||
{
|
||||
if (_executor == null && getServer() != null)
|
||||
return getServer().getThreadPool();
|
||||
return _executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getExecutor()
|
||||
{
|
||||
return _executor;
|
||||
}
|
||||
|
||||
public void setExecutor(Executor executor)
|
||||
{
|
||||
removeBean(_executor);
|
||||
_executor = executor;
|
||||
addBean(_executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBufferPool getByteBufferPool()
|
||||
{
|
||||
return _byteBufferPool;
|
||||
}
|
||||
|
||||
public void setByteBufferPool(ByteBufferPool byteBufferPool)
|
||||
@Override
|
||||
public SslContextFactory getSslContextFactory()
|
||||
{
|
||||
removeBean(byteBufferPool);
|
||||
_byteBufferPool = byteBufferPool;
|
||||
addBean(_byteBufferPool);
|
||||
return _sslContextFactory;
|
||||
}
|
||||
|
||||
public HttpConfiguration getHttpConfig()
|
||||
{
|
||||
return _httpConfig;
|
||||
}
|
||||
|
||||
protected AsyncConnection newConnection(AsyncEndPoint 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);
|
||||
|
||||
AsyncConnection http_connection = new HttpConnection(_httpConfig,this,ssl_connection.getSslEndPoint());
|
||||
ssl_connection.getSslEndPoint().setAsyncConnection(http_connection);
|
||||
return ssl_connection;
|
||||
}
|
||||
return new HttpConnection(_httpConfig,this,endp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,18 +273,13 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
if (_server == null)
|
||||
throw new IllegalStateException("No server");
|
||||
|
||||
_byteBufferPool = new StandardByteBufferPool();
|
||||
|
||||
super.doStart();
|
||||
|
||||
// Start selector thread
|
||||
synchronized (this)
|
||||
{
|
||||
for (int i = 0; i < _acceptors.length; i++)
|
||||
findExecutor().execute(new Acceptor(i));
|
||||
getExecutor().execute(new Acceptor(i));
|
||||
}
|
||||
|
||||
LOG.info("Started {}", this);
|
||||
|
@ -352,4 +430,9 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
{
|
||||
_reuseAddress = reuseAddress;
|
||||
}
|
||||
|
||||
public ScheduledExecutorService getScheduler()
|
||||
{
|
||||
return _scheduler;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,19 +14,36 @@
|
|||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
public abstract class AbstractNetConnector extends AbstractConnector implements Connector.NetConnector
|
||||
{
|
||||
private volatile String _host;
|
||||
private volatile int _port = 0;
|
||||
|
||||
protected AbstractNetConnector()
|
||||
public AbstractNetConnector(Server server, boolean ssl)
|
||||
{
|
||||
super(server,ssl);
|
||||
}
|
||||
|
||||
protected AbstractNetConnector(int acceptors)
|
||||
public AbstractNetConnector(Server server, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool, SslContextFactory sslContextFactory,
|
||||
boolean ssl, int acceptors)
|
||||
{
|
||||
super(acceptors);
|
||||
super(server,executor,scheduler,pool,sslContextFactory,ssl,acceptors);
|
||||
}
|
||||
|
||||
public AbstractNetConnector(Server server, SslContextFactory sslContextFactory)
|
||||
{
|
||||
super(server,sslContextFactory);
|
||||
}
|
||||
|
||||
public AbstractNetConnector(Server server)
|
||||
{
|
||||
super(server);
|
||||
}
|
||||
|
||||
public void setHost(String host)
|
||||
|
@ -34,6 +51,7 @@ public abstract class AbstractNetConnector extends AbstractConnector implements
|
|||
_host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost()
|
||||
{
|
||||
return _host;
|
||||
|
@ -44,11 +62,13 @@ public abstract class AbstractNetConnector extends AbstractConnector implements
|
|||
_port = port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort()
|
||||
{
|
||||
return _port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLocalPort()
|
||||
{
|
||||
return -1;
|
||||
|
@ -81,10 +101,12 @@ public abstract class AbstractNetConnector extends AbstractConnector implements
|
|||
super.doStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() throws IOException
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,9 +15,11 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
/** HTTP Connector.
|
||||
* Implementations of this interface provide connectors for the HTTP protocol.
|
||||
|
@ -41,15 +43,18 @@ public interface Connector extends LifeCycle
|
|||
/* ------------------------------------------------------------ */
|
||||
Server getServer();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
Executor findExecutor();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
Executor getExecutor();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
ScheduledExecutorService getScheduler();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
ByteBufferPool getByteBufferPool();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
SslContextFactory getSslContextFactory();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Max Idle time for connections in milliseconds
|
||||
|
|
|
@ -330,7 +330,7 @@ public abstract class HttpChannel
|
|||
if (_state.isInitial())
|
||||
{
|
||||
_request.setDispatcherType(DispatcherType.REQUEST);
|
||||
getHttpConnector().customize(_request);
|
||||
getHttpConfiguration().customize(_request);
|
||||
getServer().handle(this);
|
||||
}
|
||||
else
|
||||
|
@ -790,7 +790,9 @@ public abstract class HttpChannel
|
|||
}
|
||||
}
|
||||
|
||||
public abstract HttpConnector getHttpConnector();
|
||||
public abstract Connector getConnector();
|
||||
|
||||
public abstract HttpConfiguration getHttpConfiguration();
|
||||
|
||||
protected abstract int write(ByteBuffer content) throws IOException;
|
||||
|
||||
|
|
|
@ -3,25 +3,37 @@ package org.eclipse.jetty.server;
|
|||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.server.ssl.SslCertificates;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
|
||||
public abstract class HttpConnector extends AbstractNetConnector
|
||||
public class HttpConfiguration extends AggregateLifeCycle
|
||||
{
|
||||
static final Logger LOG = Log.getLogger(HttpConfiguration.class);
|
||||
|
||||
private final SslContextFactory _sslContextFactory;
|
||||
private final boolean _ssl;
|
||||
|
||||
private String _integralScheme = HttpScheme.HTTPS.asString();
|
||||
private int _integralPort = 0;
|
||||
private String _confidentialScheme = HttpScheme.HTTPS.asString();
|
||||
private int _confidentialPort = 0;
|
||||
private boolean _forwarded;
|
||||
private String _hostHeader;
|
||||
private ScheduledExecutorService _scheduler;
|
||||
private boolean _shutdownScheduler;
|
||||
private String _forwardedHostHeader = HttpHeader.X_FORWARDED_HOST.toString();
|
||||
private String _forwardedServerHeader = HttpHeader.X_FORWARDED_SERVER.toString();
|
||||
private String _forwardedForHeader = HttpHeader.X_FORWARDED_FOR.toString();
|
||||
|
@ -33,50 +45,22 @@ public abstract class HttpConnector extends AbstractNetConnector
|
|||
private int _responseHeaderSize=6*1024;
|
||||
private int _responseBufferSize=16*1024;
|
||||
|
||||
public HttpConnector()
|
||||
public HttpConfiguration(SslContextFactory sslContextFactory,boolean ssl)
|
||||
{
|
||||
_sslContextFactory=sslContextFactory!=null?sslContextFactory:ssl?new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH):null;
|
||||
_ssl=ssl;
|
||||
if (_sslContextFactory!=null)
|
||||
addBean(_sslContextFactory,sslContextFactory==null);
|
||||
}
|
||||
|
||||
public HttpConnector(int acceptors)
|
||||
public SslContextFactory getSslContextFactory()
|
||||
{
|
||||
super(acceptors);
|
||||
return _sslContextFactory;
|
||||
}
|
||||
|
||||
public ScheduledExecutorService getScheduler()
|
||||
public boolean isSecure()
|
||||
{
|
||||
return _scheduler;
|
||||
}
|
||||
|
||||
public void setScheduler(ScheduledExecutorService scheduler)
|
||||
{
|
||||
_scheduler = scheduler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
super.doStart();
|
||||
if (_scheduler == null)
|
||||
{
|
||||
_scheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory()
|
||||
{
|
||||
@Override
|
||||
public Thread newThread(Runnable r)
|
||||
{
|
||||
return new Thread(r, "Timer-" + HttpConnector.this.getName());
|
||||
}
|
||||
});
|
||||
_shutdownScheduler = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
if (_shutdownScheduler)
|
||||
_scheduler.shutdownNow();
|
||||
_scheduler = null;
|
||||
super.doStop();
|
||||
return _ssl;
|
||||
}
|
||||
|
||||
public int getRequestHeaderSize()
|
||||
|
@ -120,8 +104,37 @@ public abstract class HttpConnector extends AbstractNetConnector
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Allow the Listener a chance to customise the request. before the server
|
||||
* does its stuff. <br>
|
||||
* This allows the required attributes to be set for SSL requests. <br>
|
||||
* The requirements of the Servlet specs are:
|
||||
* <ul>
|
||||
* <li> an attribute named "javax.servlet.request.ssl_session_id" of type
|
||||
* String (since Servlet Spec 3.0).</li>
|
||||
* <li> an attribute named "javax.servlet.request.cipher_suite" of type
|
||||
* String.</li>
|
||||
* <li> an attribute named "javax.servlet.request.key_size" of type Integer.</li>
|
||||
* <li> an attribute named "javax.servlet.request.X509Certificate" of type
|
||||
* java.security.cert.X509Certificate[]. This is an array of objects of type
|
||||
* X509Certificate, the order of this array is defined as being in ascending
|
||||
* order of trust. The first certificate in the chain is the one set by the
|
||||
* client, the next is the one used to authenticate the first, and so on.
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
public void customize(Request request) throws IOException
|
||||
{
|
||||
if (isSecure())
|
||||
{
|
||||
request.setScheme(HttpScheme.HTTPS.asString());
|
||||
SslConnection.SslEndPoint ssl_endp = (SslConnection.SslEndPoint)request.getHttpChannel().getEndPoint();
|
||||
SslConnection sslConnection = ssl_endp.getSslConnection();
|
||||
SSLEngine sslEngine=sslConnection.getSSLEngine();
|
||||
SslCertificates.customize(sslEngine,request);
|
||||
}
|
||||
|
||||
request.setTimeStamp(System.currentTimeMillis());
|
||||
if (isForwarded())
|
||||
checkForwardedHeaders(request);
|
||||
}
|
||||
|
@ -230,12 +243,23 @@ public abstract class HttpConnector extends AbstractNetConnector
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server .Request)
|
||||
/**
|
||||
* The request is integral IFF it is secure AND the server port
|
||||
* matches any configured {@link #getIntegralPort()}.
|
||||
* This allows separation of listeners providing INTEGRAL versus
|
||||
* CONFIDENTIAL constraints, such as one SSL listener configured to require
|
||||
* client certs providing CONFIDENTIAL, whereas another SSL listener not
|
||||
* requiring client certs providing mere INTEGRAL constraints.
|
||||
* <p>
|
||||
* The request is secure if it is SSL or it {@link #isForwarded()} is true
|
||||
* and the scheme matches {@link #getIntegralScheme()()}
|
||||
*/
|
||||
public boolean isIntegral(Request request)
|
||||
{
|
||||
return false;
|
||||
boolean https = isSecure() || _forwarded && _integralScheme.equalsIgnoreCase(request.getScheme());
|
||||
int iPort=getIntegralPort();
|
||||
boolean port = iPort<=0||iPort==request.getServerPort();
|
||||
return https && port;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -257,12 +281,23 @@ public abstract class HttpConnector extends AbstractNetConnector
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server.Request)
|
||||
/**
|
||||
* The request is confidential IFF it is secure AND the server port
|
||||
* matches any configured {@link #getConfidentialPort()}.
|
||||
* This allows separation of listeners providing INTEGRAL versus
|
||||
* CONFIDENTIAL constraints, such as one SSL listener configured to require
|
||||
* client certs providing CONFIDENTIAL, whereas another SSL listener not
|
||||
* requiring client certs providing mere INTEGRAL constraints.
|
||||
* <p>
|
||||
* The request is secure if it is SSL or it {@link #isForwarded()} is true
|
||||
* and the scheme matches {@link #getConfidentialScheme()}
|
||||
*/
|
||||
public boolean isConfidential(Request request)
|
||||
{
|
||||
return _forwarded && request.getScheme().equalsIgnoreCase(HttpScheme.HTTPS.toString());
|
||||
boolean https = isSecure() || _forwarded && _confidentialScheme.equalsIgnoreCase(request.getScheme());
|
||||
int confidentialPort=getConfidentialPort();
|
||||
boolean port = confidentialPort<=0||confidentialPort==request.getServerPort();
|
||||
return https && port;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -478,4 +513,30 @@ public abstract class HttpConnector extends AbstractNetConnector
|
|||
{
|
||||
_forwardedSslSessionIdHeader = forwardedSslSessionId;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
if (_sslContextFactory!=null)
|
||||
{
|
||||
_sslContextFactory.checkKeyStore();
|
||||
|
||||
super.doStart();
|
||||
|
||||
SSLEngine sslEngine = _sslContextFactory.newSslEngine();
|
||||
|
||||
sslEngine.setUseClientMode(false);
|
||||
|
||||
SSLSession sslSession = sslEngine.getSession();
|
||||
|
||||
if (getRequestHeaderSize()<sslSession.getApplicationBufferSize())
|
||||
setRequestHeaderSize(sslSession.getApplicationBufferSize());
|
||||
if (getRequestBufferSize()<sslSession.getApplicationBufferSize())
|
||||
setRequestBufferSize(sslSession.getApplicationBufferSize());
|
||||
}
|
||||
else
|
||||
super.doStart();
|
||||
}
|
||||
}
|
|
@ -46,7 +46,8 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
public static final String UPGRADE_CONNECTION_ATTR = "org.eclispe.jetty.server.HttpConnection.UPGRADE";
|
||||
|
||||
private final Server _server;
|
||||
private final HttpConnector _connector;
|
||||
private final HttpConfiguration _httpConfig;
|
||||
private final Connector _connector;
|
||||
private final HttpParser _parser;
|
||||
private final HttpGenerator _generator;
|
||||
private final HttpChannel _channel;
|
||||
|
@ -74,17 +75,18 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public HttpConnection(HttpConnector connector, AsyncEndPoint endpoint, Server server)
|
||||
public HttpConnection(HttpConfiguration config, Connector connector, AsyncEndPoint endpoint)
|
||||
{
|
||||
super(endpoint,connector.findExecutor());
|
||||
super(endpoint,connector.getExecutor());
|
||||
|
||||
_httpConfig=config;
|
||||
_connector = connector;
|
||||
_bufferPool=_connector.getByteBufferPool();
|
||||
|
||||
_server = server;
|
||||
_server = connector.getServer();
|
||||
|
||||
_httpInput = new HttpHttpInput();
|
||||
_channel = new HttpChannelOverHttp(server);
|
||||
_channel = new HttpChannelOverHttp(connector.getServer());
|
||||
|
||||
_parser = new HttpParser(_channel.getEventHandler());
|
||||
_generator = new HttpGenerator();
|
||||
|
@ -220,7 +222,7 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
if (BufferUtil.isEmpty(_requestBuffer))
|
||||
{
|
||||
if (_requestBuffer==null)
|
||||
_requestBuffer=_bufferPool.acquire(_connector.getRequestHeaderSize(),false);
|
||||
_requestBuffer=_bufferPool.acquire(_httpConfig.getRequestHeaderSize(),false);
|
||||
|
||||
int filled=getEndPoint().fill(_requestBuffer);
|
||||
|
||||
|
@ -280,7 +282,7 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
if (getEndPoint().getAsyncConnection()!=this)
|
||||
return;
|
||||
}
|
||||
else if (_headerBytes>= _connector.getRequestHeaderSize())
|
||||
else if (_headerBytes>= _httpConfig.getRequestHeaderSize())
|
||||
{
|
||||
_parser.reset();
|
||||
_parser.close();
|
||||
|
@ -346,7 +348,7 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
{
|
||||
if (_responseBuffer!=null && _responseBuffer.capacity()>=size)
|
||||
return;
|
||||
if (_responseBuffer==null && _connector.getResponseBufferSize()>=size)
|
||||
if (_responseBuffer==null && _httpConfig.getResponseBufferSize()>=size)
|
||||
return;
|
||||
|
||||
ByteBuffer r=_bufferPool.acquire(size,false);
|
||||
|
@ -365,15 +367,19 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
if (buffer!=null)
|
||||
return buffer.capacity();
|
||||
|
||||
return _connector.getResponseBufferSize();
|
||||
return _httpConfig.getResponseBufferSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpConnector getHttpConnector()
|
||||
public Connector getConnector()
|
||||
{
|
||||
return _connector;
|
||||
}
|
||||
|
||||
public HttpConfiguration getHttpConfiguration()
|
||||
{
|
||||
return _httpConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void flushResponse() throws IOException
|
||||
{
|
||||
|
@ -522,15 +528,15 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
_info=_channel.getEventHandler().commit();
|
||||
LOG.debug("{} Gcommit {}",this,_info);
|
||||
if (_responseHeader==null)
|
||||
_responseHeader=_bufferPool.acquire(_connector.getResponseHeaderSize(),false);
|
||||
_responseHeader=_bufferPool.acquire(_httpConfig.getResponseHeaderSize(),false);
|
||||
continue;
|
||||
|
||||
case NEED_HEADER:
|
||||
_responseHeader=_bufferPool.acquire(_connector.getResponseHeaderSize(),false);
|
||||
_responseHeader=_bufferPool.acquire(_httpConfig.getResponseHeaderSize(),false);
|
||||
continue;
|
||||
|
||||
case NEED_BUFFER:
|
||||
_responseBuffer=_bufferPool.acquire(_connector.getResponseBufferSize(),false);
|
||||
_responseBuffer=_bufferPool.acquire(_httpConfig.getResponseBufferSize(),false);
|
||||
continue;
|
||||
|
||||
case NEED_CHUNK:
|
||||
|
@ -625,15 +631,15 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
case NEED_INFO:
|
||||
_info=_channel.getEventHandler().commit();
|
||||
if (_responseHeader==null)
|
||||
_responseHeader=_bufferPool.acquire(_connector.getResponseHeaderSize(),false);
|
||||
_responseHeader=_bufferPool.acquire(_httpConfig.getResponseHeaderSize(),false);
|
||||
break;
|
||||
|
||||
case NEED_HEADER:
|
||||
_responseHeader=_bufferPool.acquire(_connector.getResponseHeaderSize(),false);
|
||||
_responseHeader=_bufferPool.acquire(_httpConfig.getResponseHeaderSize(),false);
|
||||
break;
|
||||
|
||||
case NEED_BUFFER:
|
||||
_responseBuffer=_bufferPool.acquire(_connector.getResponseBufferSize(),false);
|
||||
_responseBuffer=_bufferPool.acquire(_httpConfig.getResponseBufferSize(),false);
|
||||
break;
|
||||
|
||||
case NEED_CHUNK:
|
||||
|
@ -694,7 +700,7 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
@Override
|
||||
protected void execute(Runnable task)
|
||||
{
|
||||
_connector.findExecutor().execute(task);
|
||||
_connector.getExecutor().execute(task);
|
||||
}
|
||||
|
||||
private FutureCallback<Void> write(ByteBuffer b0,ByteBuffer b1,ByteBuffer b2)
|
||||
|
@ -767,7 +773,7 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
|
||||
// We will need a buffer to read into
|
||||
if (_requestBuffer==null)
|
||||
_requestBuffer=_bufferPool.acquire(_connector.getRequestBufferSize(),false);
|
||||
_requestBuffer=_bufferPool.acquire(_httpConfig.getRequestBufferSize(),false);
|
||||
|
||||
int filled=getEndPoint().fill(_requestBuffer);
|
||||
LOG.debug("{} block filled {}",this,filled);
|
||||
|
|
|
@ -23,20 +23,25 @@ import java.util.concurrent.Phaser;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.io.AsyncByteArrayEndPoint;
|
||||
import org.eclipse.jetty.io.AsyncConnection;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
public class LocalHttpConnector extends HttpConnector
|
||||
public class LocalConnector extends AbstractConnector
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(LocalHttpConnector.class);
|
||||
private static final Logger LOG = Log.getLogger(LocalConnector.class);
|
||||
|
||||
private final BlockingQueue<LocalEndPoint> _connects = new LinkedBlockingQueue<>();
|
||||
private volatile LocalExecutor _executor;
|
||||
|
||||
public LocalHttpConnector()
|
||||
// TODO this sux
|
||||
private final LocalExecutor _executor;
|
||||
|
||||
public LocalConnector(Server server)
|
||||
{
|
||||
super(server,new LocalExecutor(server.getThreadPool()),null,null,null, false,-1);
|
||||
_executor=(LocalExecutor)getExecutor();
|
||||
setIdleTimeout(30000);
|
||||
}
|
||||
|
||||
|
@ -99,7 +104,7 @@ public class LocalHttpConnector extends HttpConnector
|
|||
{
|
||||
LOG.debug("accepting {}",acceptorID);
|
||||
LocalEndPoint endp = _connects.take();
|
||||
HttpConnection connection=new HttpConnection(this,endp,getServer());
|
||||
AsyncConnection connection=newConnection(endp);
|
||||
endp.setAsyncConnection(connection);
|
||||
endp.onOpen();
|
||||
connection.onOpen();
|
||||
|
@ -107,27 +112,7 @@ public class LocalHttpConnector extends HttpConnector
|
|||
_executor._phaser.arriveAndDeregister(); // arrive for the register done in getResponses
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
super.doStart();
|
||||
_executor=new LocalExecutor(findExecutor());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
super.doStop();
|
||||
_executor=null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor findExecutor()
|
||||
{
|
||||
return _executor==null?super.findExecutor():_executor;
|
||||
}
|
||||
|
||||
private class LocalExecutor implements Executor
|
||||
private static class LocalExecutor implements Executor
|
||||
{
|
||||
private final Phaser _phaser=new Phaser()
|
||||
{
|
||||
|
@ -173,7 +158,7 @@ public class LocalHttpConnector extends HttpConnector
|
|||
|
||||
public LocalEndPoint()
|
||||
{
|
||||
super(getScheduler(), LocalHttpConnector.this.getIdleTimeout());
|
||||
super(getScheduler(), LocalConnector.this.getIdleTimeout());
|
||||
setGrowOutput(true);
|
||||
}
|
||||
|
|
@ -1358,7 +1358,7 @@ public class Request implements HttpServletRequest
|
|||
@Override
|
||||
public boolean isSecure()
|
||||
{
|
||||
return _channel.getHttpConnector().isConfidential(this);
|
||||
return _channel.getHttpConfiguration().isConfidential(this);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -16,17 +16,23 @@ package org.eclipse.jetty.server;
|
|||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.nio.channels.Channel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import org.eclipse.jetty.continuation.Continuation;
|
||||
import org.eclipse.jetty.io.AsyncConnection;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.SelectorManager;
|
||||
import org.eclipse.jetty.io.SelectorManager.ManagedSelector;
|
||||
import org.eclipse.jetty.server.Connector.NetConnector;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
/**
|
||||
* Selecting NIO connector.
|
||||
|
@ -51,29 +57,78 @@ import org.eclipse.jetty.server.Connector.NetConnector;
|
|||
* associated object of the Continuation instance.
|
||||
* </p>
|
||||
*/
|
||||
public class SelectChannelConnector extends HttpConnector implements NetConnector
|
||||
public class SelectChannelConnector extends AbstractNetConnector
|
||||
{
|
||||
private final SelectorManager _manager;
|
||||
protected ServerSocketChannel _acceptChannel;
|
||||
protected boolean _inheritChannel;
|
||||
private int _localPort=-1;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*/
|
||||
public SelectChannelConnector()
|
||||
/* ------------------------------------------------------------ */
|
||||
public SelectChannelConnector(Server server)
|
||||
{
|
||||
this(Math.max(1,(Runtime.getRuntime().availableProcessors())/4),
|
||||
Math.max(1,(Runtime.getRuntime().availableProcessors())/4));
|
||||
this(server,null,null,null,null,false,0,0);
|
||||
}
|
||||
|
||||
public SelectChannelConnector(int acceptors, int selectors)
|
||||
/* ------------------------------------------------------------ */
|
||||
public SelectChannelConnector(Server server, boolean ssl)
|
||||
{
|
||||
super(acceptors);
|
||||
_manager=new ConnectorSelectorManager(selectors);
|
||||
this(server,null,null,null,null,ssl,0,0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public SelectChannelConnector(Server server, SslContextFactory sslContextFactory)
|
||||
{
|
||||
this(server,null,null,null,sslContextFactory,sslContextFactory!=null,0,0);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param server The server this connector will be added to. Must not be null.
|
||||
* @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("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);
|
||||
_manager=new ConnectorSelectorManager(selectors!=0?selectors:Math.max(1,(Runtime.getRuntime().availableProcessors())/4));
|
||||
addBean(_manager,true);
|
||||
}
|
||||
|
||||
|
||||
public boolean isInheritChannel()
|
||||
{
|
||||
return _inheritChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* If true, the connector first tries to inherit from a channel provided by the system.
|
||||
* If there is no inherited channel available, or if the inherited channel provided not usable,
|
||||
* then it will fall back upon normal ServerSocketChannel creation.
|
||||
* <p>
|
||||
* Use it with xinetd/inetd, to launch an instance of Jetty on demand. The port
|
||||
* used to access pages on the Jetty instance is the same as the port used to
|
||||
* launch Jetty.
|
||||
*
|
||||
*/
|
||||
public void setInheritChannel(boolean inheritChannel)
|
||||
{
|
||||
_inheritChannel = inheritChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(int acceptorID) throws IOException
|
||||
{
|
||||
|
@ -109,13 +164,6 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(Request request) throws IOException
|
||||
{
|
||||
request.setTimeStamp(System.currentTimeMillis());
|
||||
super.customize(request);
|
||||
}
|
||||
|
||||
public SelectorManager getSelectorManager()
|
||||
{
|
||||
return _manager;
|
||||
|
@ -141,12 +189,21 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
{
|
||||
synchronized(this)
|
||||
{
|
||||
if (_acceptChannel == null)
|
||||
{
|
||||
if (_inheritChannel)
|
||||
{
|
||||
Channel channel = System.inheritedChannel();
|
||||
if ( channel instanceof ServerSocketChannel )
|
||||
_acceptChannel = (ServerSocketChannel)channel;
|
||||
else
|
||||
LOG.warn("Unable to use System.inheritedChannel() [" +channel+ "]. Trying a new ServerSocketChannel at " + getHost() + ":" + getPort());
|
||||
}
|
||||
|
||||
if (_acceptChannel == null)
|
||||
{
|
||||
// Create a new server socket
|
||||
_acceptChannel = ServerSocketChannel.open();
|
||||
// Set to blocking mode
|
||||
_acceptChannel.configureBlocking(true);
|
||||
|
||||
// Bind the server socket to the local host and port
|
||||
_acceptChannel.socket().setReuseAddress(getReuseAddress());
|
||||
|
@ -159,8 +216,13 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
|
||||
addBean(_acceptChannel);
|
||||
}
|
||||
|
||||
_acceptChannel.configureBlocking(true);
|
||||
addBean(_acceptChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jetty.server.server.AbstractConnector#doStart()
|
||||
|
@ -181,12 +243,6 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
connectionClosed(endpoint.getAsyncConnection());
|
||||
}
|
||||
|
||||
protected AsyncConnection newConnection(SocketChannel channel,final AsyncEndPoint endpoint)
|
||||
{
|
||||
return new HttpConnection(SelectChannelConnector.this,endpoint,getServer());
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private final class ConnectorSelectorManager extends SelectorManager
|
||||
{
|
||||
|
@ -198,7 +254,7 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
@Override
|
||||
protected void execute(Runnable task)
|
||||
{
|
||||
findExecutor().execute(task);
|
||||
getExecutor().execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -230,9 +286,9 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
}
|
||||
|
||||
@Override
|
||||
public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment)
|
||||
public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment) throws IOException
|
||||
{
|
||||
return SelectChannelConnector.this.newConnection(channel, endpoint);
|
||||
return SelectChannelConnector.this.newConnection(endpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
|
||||
private final Container _container=new Container();
|
||||
private final AttributesMap _attributes = new AttributesMap();
|
||||
private ThreadPool _threadPool;
|
||||
private final ThreadPool _threadPool;
|
||||
private Connector[] _connectors;
|
||||
private SessionIdManager _sessionIdManager;
|
||||
private boolean _sendServerVersion = true; //send Server: header
|
||||
|
@ -81,7 +81,7 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
/* ------------------------------------------------------------ */
|
||||
public Server()
|
||||
{
|
||||
setServer(this);
|
||||
this((ThreadPool)null);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -90,9 +90,8 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
*/
|
||||
public Server(int port)
|
||||
{
|
||||
setServer(this);
|
||||
|
||||
SelectChannelConnector connector=new SelectChannelConnector();
|
||||
this((ThreadPool)null);
|
||||
SelectChannelConnector connector=new SelectChannelConnector(this);
|
||||
connector.setPort(port);
|
||||
setConnectors(new Connector[]{connector});
|
||||
}
|
||||
|
@ -103,15 +102,23 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
*/
|
||||
public Server(InetSocketAddress addr)
|
||||
{
|
||||
setServer(this);
|
||||
|
||||
SelectChannelConnector connector=new SelectChannelConnector();
|
||||
this((ThreadPool)null);
|
||||
SelectChannelConnector connector=new SelectChannelConnector(this);
|
||||
connector.setHost(addr.getHostName());
|
||||
connector.setPort(addr.getPort());
|
||||
setConnectors(new Connector[]{connector});
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Server(ThreadPool pool)
|
||||
{
|
||||
_threadPool=pool!=null?pool:new QueuedThreadPool();
|
||||
addBean(_threadPool,pool==null);
|
||||
setServer(this);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static String getVersion()
|
||||
{
|
||||
|
@ -189,9 +196,8 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
{
|
||||
for (int i=0;i<connectors.length;i++)
|
||||
{
|
||||
// TODO review
|
||||
if (connectors[i] instanceof AbstractConnector)
|
||||
((AbstractConnector)connectors[i]).setServer(this);
|
||||
if (connectors[i].getServer()!=this)
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,20 +214,6 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
return _threadPool;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param threadPool The threadPool to set.
|
||||
*/
|
||||
public void setThreadPool(ThreadPool threadPool)
|
||||
{
|
||||
if (_threadPool!=null)
|
||||
removeBean(_threadPool);
|
||||
_container.update(this, _threadPool, threadPool, "threadpool",false);
|
||||
_threadPool = threadPool;
|
||||
if (_threadPool!=null)
|
||||
addBean(_threadPool);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if {@link #dumpStdErr()} is called after starting
|
||||
*/
|
||||
|
@ -267,9 +259,6 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
HttpGenerator.setServerVersion(__version);
|
||||
MultiException mex=new MultiException();
|
||||
|
||||
if (_threadPool==null)
|
||||
setThreadPool(new QueuedThreadPool());
|
||||
|
||||
try
|
||||
{
|
||||
super.doStart();
|
||||
|
|
|
@ -904,7 +904,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
|||
// Check the connector
|
||||
if (_connectors != null && _connectors.size() > 0)
|
||||
{
|
||||
String connector = HttpChannel.getCurrentHttpChannel().getHttpConnector().getName();
|
||||
String connector = HttpChannel.getCurrentHttpChannel().getConnector().getName();
|
||||
if (connector == null || !_connectors.contains(connector))
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2008-2009 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.nio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.Channel;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* An implementation of the SelectChannelConnector which first tries to
|
||||
* inherit from a channel provided by the system. If there is no inherited
|
||||
* channel available, or if the inherited channel provided not usable, then
|
||||
* it will fall back upon normal ServerSocketChannel creation.
|
||||
* <p>
|
||||
* Note that System.inheritedChannel() is only available from Java 1.5 onwards.
|
||||
* Trying to use this class under Java 1.4 will be the same as using a normal
|
||||
* SelectChannelConnector.
|
||||
* <p>
|
||||
* Use it with xinetd/inetd, to launch an instance of Jetty on demand. The port
|
||||
* used to access pages on the Jetty instance is the same as the port used to
|
||||
* launch Jetty.
|
||||
*
|
||||
* @author athena
|
||||
*/
|
||||
public class InheritedChannelConnector extends SelectChannelConnector
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(InheritedChannelConnector.class);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void open() throws IOException
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
try
|
||||
{
|
||||
Channel channel = System.inheritedChannel();
|
||||
if ( channel instanceof ServerSocketChannel )
|
||||
_acceptChannel = (ServerSocketChannel)channel;
|
||||
else
|
||||
LOG.warn("Unable to use System.inheritedChannel() [" +channel+ "]. Trying a new ServerSocketChannel at " + getHost() + ":" + getPort());
|
||||
|
||||
if ( _acceptChannel != null )
|
||||
_acceptChannel.configureBlocking(true);
|
||||
}
|
||||
catch(NoSuchMethodError e)
|
||||
{
|
||||
LOG.warn("Need at least Java 5 to use socket inherited from xinetd/inetd.");
|
||||
}
|
||||
|
||||
if (_acceptChannel == null)
|
||||
super.open();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -19,13 +19,18 @@ import java.nio.channels.SocketChannel;
|
|||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.NetworkTrafficListener;
|
||||
import org.eclipse.jetty.io.NetworkTrafficSelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.SelectorManager;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
/**
|
||||
* <p>A specialized version of {@link SelectChannelConnector} that supports {@link NetworkTrafficListener}s.</p>
|
||||
|
@ -36,6 +41,28 @@ 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)
|
||||
{
|
||||
super(server);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param listener the listener to add
|
||||
*/
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package org.eclipse.jetty.server.nio;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link org.eclipse.jetty.server.SelectChannelConnector}
|
||||
*/
|
||||
public class SelectChannelConnector extends org.eclipse.jetty.server.SelectChannelConnector
|
||||
{
|
||||
}
|
|
@ -29,7 +29,8 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
|||
/** The interface for SSL connectors and their configuration methods.
|
||||
*
|
||||
*/
|
||||
public interface SslConnector extends Connector.NetConnector
|
||||
@Deprecated
|
||||
interface SslConnector
|
||||
{
|
||||
@Deprecated
|
||||
public static final String DEFAULT_KEYSTORE_ALGORITHM=(Security.getProperty("ssl.KeyManagerFactory.algorithm")==null?"SunX509":Security.getProperty("ssl.KeyManagerFactory.algorithm"));
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.jetty.io.RuntimeIOException;
|
|||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
|
@ -34,586 +35,15 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
|||
/**
|
||||
* SslSelectChannelConnector.
|
||||
*
|
||||
* @deprecated use SelectChannelConnector with {@link SslContextFactory}
|
||||
* @org.apache.xbean.XBean element="sslConnector" description="Creates an NIO ssl connector"
|
||||
*/
|
||||
public class SslSelectChannelConnector extends SelectChannelConnector implements SslConnector
|
||||
public class SslSelectChannelConnector extends SelectChannelConnector
|
||||
{
|
||||
private final SslContextFactory _sslContextFactory;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public SslSelectChannelConnector()
|
||||
public SslSelectChannelConnector(Server server)
|
||||
{
|
||||
this(new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH));
|
||||
setSoLingerTime(30000);
|
||||
super(server,true);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Construct with explicit SslContextFactory.
|
||||
* The SslContextFactory passed is added via {@link #addBean(Object)} so that
|
||||
* it's lifecycle may be managed with {@link AggregateLifeCycle}.
|
||||
* @param sslContextFactory
|
||||
*/
|
||||
public SslSelectChannelConnector(SslContextFactory sslContextFactory)
|
||||
{
|
||||
_sslContextFactory = sslContextFactory;
|
||||
addBean(_sslContextFactory);
|
||||
setSoLingerTime(30000);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Allow the Listener a chance to customise the request. before the server
|
||||
* does its stuff. <br>
|
||||
* This allows the required attributes to be set for SSL requests. <br>
|
||||
* The requirements of the Servlet specs are:
|
||||
* <ul>
|
||||
* <li> an attribute named "javax.servlet.request.ssl_session_id" of type
|
||||
* String (since Servlet Spec 3.0).</li>
|
||||
* <li> an attribute named "javax.servlet.request.cipher_suite" of type
|
||||
* String.</li>
|
||||
* <li> an attribute named "javax.servlet.request.key_size" of type Integer.</li>
|
||||
* <li> an attribute named "javax.servlet.request.X509Certificate" of type
|
||||
* java.security.cert.X509Certificate[]. This is an array of objects of type
|
||||
* X509Certificate, the order of this array is defined as being in ascending
|
||||
* order of trust. The first certificate in the chain is the one set by the
|
||||
* client, the next is the one used to authenticate the first, and so on.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @param request
|
||||
* HttpRequest to be customised.
|
||||
*/
|
||||
@Override
|
||||
public void customize(Request request) throws IOException
|
||||
{
|
||||
request.setScheme(HttpScheme.HTTPS.asString());
|
||||
super.customize(request);
|
||||
|
||||
SslConnection.SslEndPoint ssl_endp = (SslConnection.SslEndPoint)request.getHttpChannel().getEndPoint();
|
||||
SslConnection sslConnection = ssl_endp.getSslConnection();
|
||||
SSLEngine sslEngine=sslConnection.getSSLEngine();
|
||||
SslCertificates.customize(sslEngine,request);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return True if SSL re-negotiation is allowed (default false)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isAllowRenegotiate()
|
||||
{
|
||||
return _sslContextFactory.isAllowRenegotiate();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Set if SSL re-negotiation is allowed. CVE-2009-3555 discovered
|
||||
* a vulnerability in SSL/TLS with re-negotiation. If your JVM
|
||||
* does not have CVE-2009-3555 fixed, then re-negotiation should
|
||||
* not be allowed. CVE-2009-3555 was fixed in Sun java 1.6 with a ban
|
||||
* of renegotiate in u19 and with RFC5746 in u22.
|
||||
* @param allowRenegotiate true if re-negotiation is allowed (default false)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAllowRenegotiate(boolean allowRenegotiate)
|
||||
{
|
||||
_sslContextFactory.setAllowRenegotiate(allowRenegotiate);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getExcludeCipherSuites()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String[] getExcludeCipherSuites()
|
||||
{
|
||||
return _sslContextFactory.getExcludeCipherSuites();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setExcludeCipherSuites(java.lang.String[])
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setExcludeCipherSuites(String[] cipherSuites)
|
||||
{
|
||||
_sslContextFactory.setExcludeCipherSuites(cipherSuites);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getExcludeCipherSuites()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String[] getIncludeCipherSuites()
|
||||
{
|
||||
return _sslContextFactory.getIncludeCipherSuites();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setExcludeCipherSuites(java.lang.String[])
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setIncludeCipherSuites(String[] cipherSuites)
|
||||
{
|
||||
_sslContextFactory.setIncludeCipherSuites(cipherSuites);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setPassword(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPassword(String password)
|
||||
{
|
||||
_sslContextFactory.setKeyStorePassword(password);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setTrustPassword(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTrustPassword(String password)
|
||||
{
|
||||
_sslContextFactory.setTrustStorePassword(password);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setKeyPassword(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setKeyPassword(String password)
|
||||
{
|
||||
_sslContextFactory.setKeyManagerPassword(password);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Unsupported.
|
||||
*
|
||||
* TODO: we should remove this as it is no longer an overridden method from SslConnector (like it was in the past)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getAlgorithm()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Unsupported.
|
||||
*
|
||||
* TODO: we should remove this as it is no longer an overridden method from SslConnector (like it was in the past)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAlgorithm(String algorithm)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getProtocol()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getProtocol()
|
||||
{
|
||||
return _sslContextFactory.getProtocol();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setProtocol(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setProtocol(String protocol)
|
||||
{
|
||||
_sslContextFactory.setProtocol(protocol);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setKeystore(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setKeystore(String keystore)
|
||||
{
|
||||
_sslContextFactory.setKeyStorePath(keystore);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getKeystore()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getKeystore()
|
||||
{
|
||||
return _sslContextFactory.getKeyStorePath();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getKeystoreType()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getKeystoreType()
|
||||
{
|
||||
return _sslContextFactory.getKeyStoreType();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getNeedClientAuth()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getNeedClientAuth()
|
||||
{
|
||||
return _sslContextFactory.getNeedClientAuth();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getWantClientAuth()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getWantClientAuth()
|
||||
{
|
||||
return _sslContextFactory.getWantClientAuth();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setNeedClientAuth(boolean)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setNeedClientAuth(boolean needClientAuth)
|
||||
{
|
||||
_sslContextFactory.setNeedClientAuth(needClientAuth);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setWantClientAuth(boolean)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setWantClientAuth(boolean wantClientAuth)
|
||||
{
|
||||
_sslContextFactory.setWantClientAuth(wantClientAuth);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setKeystoreType(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setKeystoreType(String keystoreType)
|
||||
{
|
||||
_sslContextFactory.setKeyStoreType(keystoreType);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getProvider()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getProvider()
|
||||
{
|
||||
return _sslContextFactory.getProvider();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getSecureRandomAlgorithm()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getSecureRandomAlgorithm()
|
||||
{
|
||||
return _sslContextFactory.getSecureRandomAlgorithm();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getSslKeyManagerFactoryAlgorithm()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getSslKeyManagerFactoryAlgorithm()
|
||||
{
|
||||
return _sslContextFactory.getSslKeyManagerFactoryAlgorithm();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getSslTrustManagerFactoryAlgorithm()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getSslTrustManagerFactoryAlgorithm()
|
||||
{
|
||||
return _sslContextFactory.getTrustManagerFactoryAlgorithm();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getTruststore()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getTruststore()
|
||||
{
|
||||
return _sslContextFactory.getTrustStore();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getTruststoreType()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String getTruststoreType()
|
||||
{
|
||||
return _sslContextFactory.getTrustStoreType();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setProvider(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setProvider(String provider)
|
||||
{
|
||||
_sslContextFactory.setProvider(provider);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setSecureRandomAlgorithm(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSecureRandomAlgorithm(String algorithm)
|
||||
{
|
||||
_sslContextFactory.setSecureRandomAlgorithm(algorithm);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setSslKeyManagerFactoryAlgorithm(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSslKeyManagerFactoryAlgorithm(String algorithm)
|
||||
{
|
||||
_sslContextFactory.setSslKeyManagerFactoryAlgorithm(algorithm);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setSslTrustManagerFactoryAlgorithm(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSslTrustManagerFactoryAlgorithm(String algorithm)
|
||||
{
|
||||
_sslContextFactory.setTrustManagerFactoryAlgorithm(algorithm);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setTruststore(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTruststore(String truststore)
|
||||
{
|
||||
_sslContextFactory.setTrustStore(truststore);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setTruststoreType(java.lang.String)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTruststoreType(String truststoreType)
|
||||
{
|
||||
_sslContextFactory.setTrustStoreType(truststoreType);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setSslContext(javax.net.ssl.SSLContext)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSslContext(SSLContext sslContext)
|
||||
{
|
||||
_sslContextFactory.setSslContext(sslContext);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#setSslContext(javax.net.ssl.SSLContext)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public SSLContext getSslContext()
|
||||
{
|
||||
return _sslContextFactory.getSslContext();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.ssl.SslConnector#getSslContextFactory()
|
||||
*/
|
||||
public SslContextFactory getSslContextFactory()
|
||||
{
|
||||
return _sslContextFactory;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* By default, we're confidential, given we speak SSL. But, if we've been
|
||||
* told about an confidential port, and said port is not our port, then
|
||||
* we're not. This allows separation of listeners providing INTEGRAL versus
|
||||
* CONFIDENTIAL constraints, such as one SSL listener configured to require
|
||||
* client certs providing CONFIDENTIAL, whereas another SSL listener not
|
||||
* requiring client certs providing mere INTEGRAL constraints.
|
||||
*/
|
||||
@Override
|
||||
public boolean isConfidential(Request request)
|
||||
{
|
||||
final int confidentialPort=getConfidentialPort();
|
||||
return confidentialPort==0||confidentialPort==request.getServerPort();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* By default, we're integral, given we speak SSL. But, if we've been told
|
||||
* about an integral port, and said port is not our port, then we're not.
|
||||
* This allows separation of listeners providing INTEGRAL versus
|
||||
* CONFIDENTIAL constraints, such as one SSL listener configured to require
|
||||
* client certs providing CONFIDENTIAL, whereas another SSL listener not
|
||||
* requiring client certs providing mere INTEGRAL constraints.
|
||||
*/
|
||||
@Override
|
||||
public boolean isIntegral(Request request)
|
||||
{
|
||||
final int integralPort=getIntegralPort();
|
||||
return integralPort==0||integralPort==request.getServerPort();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
@Override
|
||||
protected AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint)
|
||||
{
|
||||
try
|
||||
{
|
||||
SSLEngine engine = createSSLEngine(channel);
|
||||
SslConnection connection = newSslConnection(endpoint, engine);
|
||||
AsyncConnection delegate = newPlainConnection(channel, connection.getSslEndPoint());
|
||||
connection.getSslEndPoint().setAsyncConnection(delegate);
|
||||
return connection;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected AsyncConnection newPlainConnection(SocketChannel channel, AsyncEndPoint endPoint)
|
||||
{
|
||||
return super.newConnection(channel, endPoint);
|
||||
}
|
||||
|
||||
protected SslConnection newSslConnection(AsyncEndPoint endpoint, SSLEngine engine)
|
||||
{
|
||||
return new SslConnection(getByteBufferPool(), findExecutor(), endpoint, engine);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param channel A channel which if passed is used as to extract remote
|
||||
* host and port for the purposes of SSL session caching
|
||||
* @return A SSLEngine for a new or cached SSL Session
|
||||
* @throws IOException if the SSLEngine cannot be created
|
||||
*/
|
||||
protected SSLEngine createSSLEngine(SocketChannel channel) throws IOException
|
||||
{
|
||||
SSLEngine engine;
|
||||
if (channel != null)
|
||||
{
|
||||
String peerHost = channel.socket().getInetAddress().getHostAddress();
|
||||
int peerPort = channel.socket().getPort();
|
||||
engine = _sslContextFactory.newSslEngine(peerHost, peerPort);
|
||||
}
|
||||
else
|
||||
{
|
||||
engine = _sslContextFactory.newSslEngine();
|
||||
}
|
||||
|
||||
engine.setUseClientMode(false);
|
||||
return engine;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.SelectChannelConnector#doStart()
|
||||
*/
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
_sslContextFactory.checkKeyStore();
|
||||
_sslContextFactory.start();
|
||||
|
||||
SSLEngine sslEngine = _sslContextFactory.newSslEngine();
|
||||
|
||||
sslEngine.setUseClientMode(false);
|
||||
|
||||
SSLSession sslSession = sslEngine.getSession();
|
||||
|
||||
if (getRequestHeaderSize()<sslSession.getApplicationBufferSize())
|
||||
setRequestHeaderSize(sslSession.getApplicationBufferSize());
|
||||
if (getRequestBufferSize()<sslSession.getApplicationBufferSize())
|
||||
setRequestBufferSize(sslSession.getApplicationBufferSize());
|
||||
|
||||
super.doStart();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.SelectChannelConnector#doStop()
|
||||
*/
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
super.doStop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class AsyncRequestReadTest
|
|||
public static void startServer() throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector();
|
||||
connector = new SelectChannelConnector(server);
|
||||
connector.setIdleTimeout(10000);
|
||||
server.addConnector(connector);
|
||||
server.setHandler(new EmptyHandler());
|
||||
|
|
|
@ -46,13 +46,13 @@ public class AsyncStressTest
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(AsyncStressTest.class);
|
||||
|
||||
protected Server _server = new Server();
|
||||
protected QueuedThreadPool _threads=new QueuedThreadPool();
|
||||
protected Server _server = new Server(_threads);
|
||||
protected SuspendHandler _handler = new SuspendHandler();
|
||||
protected SelectChannelConnector _connector;
|
||||
protected InetAddress _addr;
|
||||
protected int _port;
|
||||
protected Random _random = new Random();
|
||||
protected QueuedThreadPool _threads=new QueuedThreadPool();
|
||||
private final static String[][] __paths =
|
||||
{
|
||||
{"/path","NORMAL"},
|
||||
|
@ -66,9 +66,9 @@ public class AsyncStressTest
|
|||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
_server.manage(_threads);
|
||||
_threads.setMaxThreads(50);
|
||||
_server.setThreadPool(_threads);
|
||||
_connector = new SelectChannelConnector();
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_connector.setIdleTimeout(120000);
|
||||
_server.setConnectors(new Connector[]{ _connector });
|
||||
_server.setHandler(_handler);
|
||||
|
|
|
@ -9,7 +9,7 @@ public class ChannelHttpServer
|
|||
System.setProperty("org.eclipse.jetty.LEVEL","DEBUG");
|
||||
Log.getRootLogger().setDebugEnabled(true);
|
||||
Server server = new Server();
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
SelectChannelConnector connector = new SelectChannelConnector(server);
|
||||
connector.setPort(8080);
|
||||
server.addConnector(connector);
|
||||
server.setHandler(new DumpHandler());
|
||||
|
|
|
@ -93,10 +93,10 @@ public class CheckReverseProxyHeadersTest
|
|||
private void testRequest(String headers, RequestValidator requestValidator) throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
LocalHttpConnector connector = new LocalHttpConnector();
|
||||
LocalConnector connector = new LocalConnector(server);
|
||||
|
||||
// Activate reverse proxy headers checking
|
||||
connector.setForwarded(true);
|
||||
connector.getHttpConfig().setForwarded(true);
|
||||
|
||||
server.setConnectors(new Connector[] {connector});
|
||||
ValidationHandler validationHandler = new ValidationHandler(requestValidator);
|
||||
|
|
|
@ -52,16 +52,16 @@ public class HttpConnectionTest
|
|||
private static final Logger LOG = Log.getLogger(HttpConnectionTest.class);
|
||||
|
||||
private Server server;
|
||||
private LocalHttpConnector connector;
|
||||
private LocalConnector connector;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new LocalHttpConnector();
|
||||
connector = new LocalConnector(server);
|
||||
server.addConnector(connector);
|
||||
connector.setRequestHeaderSize(1024);
|
||||
connector.setResponseHeaderSize(1024);
|
||||
connector.getHttpConfig().setRequestHeaderSize(1024);
|
||||
connector.getHttpConfig().setResponseHeaderSize(1024);
|
||||
server.setHandler(new DumpHandler());
|
||||
server.start();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class HttpWriterTest
|
|||
HttpChannel channel = new HttpChannel(null,null,null)
|
||||
{
|
||||
@Override
|
||||
public HttpConnector getHttpConnector()
|
||||
public HttpConfiguration getHttpConfiguration()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -99,6 +99,12 @@ public class HttpWriterTest
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connector getConnector()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
HttpOutput httpOut = new HttpOutput(channel);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class LocalAsyncContextTest
|
|||
|
||||
protected Connector initConnector()
|
||||
{
|
||||
return new LocalHttpConnector();
|
||||
return new LocalConnector(_server);
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -247,8 +247,8 @@ public class LocalAsyncContextTest
|
|||
|
||||
protected String getResponse(String request) throws Exception
|
||||
{
|
||||
LocalHttpConnector connector=(LocalHttpConnector)_connector;
|
||||
LocalHttpConnector.LocalEndPoint endp = connector.executeRequest(request);
|
||||
LocalConnector connector=(LocalConnector)_connector;
|
||||
LocalConnector.LocalEndPoint endp = connector.executeRequest(request);
|
||||
endp.waitUntilClosed();
|
||||
return endp.takeOutputString();
|
||||
}
|
||||
|
|
|
@ -10,13 +10,13 @@ import org.junit.Test;
|
|||
public class LocalHttpConnectorTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalConnector _connector;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector = new LocalConnector(_server);
|
||||
_server.addConnector(_connector);
|
||||
_server.setHandler(new DumpHandler());
|
||||
_server.start();
|
||||
|
|
|
@ -54,7 +54,7 @@ public class NetworkTrafficListenerTest
|
|||
server.setSendDateHeader(false);
|
||||
server.setSendServerVersion(false);
|
||||
|
||||
connector = new NetworkTrafficSelectChannelConnector();
|
||||
connector = new NetworkTrafficSelectChannelConnector(server);
|
||||
server.addConnector(connector);
|
||||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
|
|
@ -42,13 +42,13 @@ import org.junit.Test;
|
|||
public class RFC2616Test
|
||||
{
|
||||
private Server server;
|
||||
private LocalHttpConnector connector;
|
||||
private LocalConnector connector;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new LocalHttpConnector();
|
||||
connector = new LocalConnector(server);
|
||||
connector.setIdleTimeout(10000);
|
||||
server.addConnector(connector);
|
||||
|
||||
|
@ -490,7 +490,7 @@ public class RFC2616Test
|
|||
{
|
||||
int offset=0;
|
||||
// Expect 100
|
||||
LocalHttpConnector.LocalEndPoint endp =connector.executeRequest("GET /R1 HTTP/1.1\n"+
|
||||
LocalConnector.LocalEndPoint endp =connector.executeRequest("GET /R1 HTTP/1.1\n"+
|
||||
"Host: localhost\n"+
|
||||
"Connection: close\n"+
|
||||
"Expect: 100-continue\n"+
|
||||
|
@ -898,7 +898,7 @@ public class RFC2616Test
|
|||
}
|
||||
}
|
||||
|
||||
private void checkContentRange(LocalHttpConnector listener, String tname, String path, String reqRanges, int expectedStatus, String expectedRange, String expectedData)
|
||||
private void checkContentRange(LocalConnector listener, String tname, String path, String reqRanges, int expectedStatus, String expectedRange, String expectedData)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -49,19 +49,19 @@ public class RequestTest
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(RequestTest.class);
|
||||
private Server _server;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalConnector _connector;
|
||||
private RequestHandler _handler;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector.setRequestHeaderSize(512);
|
||||
_connector.setRequestBufferSize(1024);
|
||||
_connector.setResponseHeaderSize(512);
|
||||
_connector.setResponseBufferSize(2048);
|
||||
_connector.setForwarded(true);
|
||||
_connector = new LocalConnector(_server);
|
||||
_connector.getHttpConfig().setRequestHeaderSize(512);
|
||||
_connector.getHttpConfig().setRequestBufferSize(1024);
|
||||
_connector.getHttpConfig().setResponseHeaderSize(512);
|
||||
_connector.getHttpConfig().setResponseBufferSize(2048);
|
||||
_connector.getHttpConfig().setForwarded(true);
|
||||
_server.addConnector(_connector);
|
||||
_handler = new RequestHandler();
|
||||
_server.setHandler(_handler);
|
||||
|
|
|
@ -56,7 +56,7 @@ import static org.junit.Assert.fail;
|
|||
public class ResponseTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalConnector _connector;
|
||||
private HttpChannel _channel;
|
||||
private ScheduledExecutorService _timer;
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class ResponseTest
|
|||
public void init() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector = new LocalConnector(_server);
|
||||
_server.addConnector(_connector);
|
||||
_server.setHandler(new DumpHandler());
|
||||
_server.start();
|
||||
|
@ -100,35 +100,28 @@ public class ResponseTest
|
|||
@Override
|
||||
protected void resetBuffer()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void increaseContentBufferSize(int size)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScheduledExecutorService getScheduler()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpConnector getHttpConnector()
|
||||
public HttpConfiguration getHttpConfiguration()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentBufferSize()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -142,29 +135,27 @@ public class ResponseTest
|
|||
@Override
|
||||
protected void execute(Runnable task)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void completed()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void completeResponse() throws IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void commitResponse(ResponseInfo info, ByteBuffer content) throws IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connector getConnector()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class SelectChannelAsyncContextTest extends LocalAsyncContextTest
|
|||
@Override
|
||||
protected Connector initConnector()
|
||||
{
|
||||
return new SelectChannelConnector();
|
||||
return new SelectChannelConnector(_server);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,6 @@ public class SelectChannelConnectorCloseTest extends ConnectorCloseTestBase
|
|||
public void init() throws Exception
|
||||
{
|
||||
System.setProperty("org.eclipse.jetty.util.log.DEBUG","true");
|
||||
startServer(new SelectChannelConnector());
|
||||
startServer(new SelectChannelConnector(_server));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class SelectChannelServerTest extends HttpServerTestBase
|
|||
@BeforeClass
|
||||
public static void init() throws Exception
|
||||
{
|
||||
startServer(new SelectChannelConnector());
|
||||
startServer(new SelectChannelConnector(_server));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,7 +58,7 @@ public class SelectChannelStatisticsTest
|
|||
_connect = new CyclicBarrier(2);
|
||||
|
||||
_server = new Server();
|
||||
_connector = new SelectChannelConnector()
|
||||
_connector = new SelectChannelConnector(_server)
|
||||
{
|
||||
@Override
|
||||
protected void endPointClosed(AsyncEndPoint endpoint)
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SelectChannelTimeoutTest extends ConnectorTimeoutTest
|
|||
@BeforeClass
|
||||
public static void init() throws Exception
|
||||
{
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
SelectChannelConnector connector = new SelectChannelConnector(_server);
|
||||
connector.setIdleTimeout(MAX_IDLE_TIME); // 250 msec max idle
|
||||
startServer(connector);
|
||||
}
|
||||
|
|
|
@ -44,12 +44,12 @@ public class SlowClientWithPipelinedRequestTest
|
|||
public void startServer(Handler handler) throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector()
|
||||
connector = new SelectChannelConnector(server)
|
||||
{
|
||||
@Override
|
||||
protected AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint)
|
||||
protected AsyncConnection newConnection(AsyncEndPoint endpoint)
|
||||
{
|
||||
return new HttpConnection(this,endpoint,getServer())
|
||||
return new HttpConnection(getHttpConfig(),this,endpoint)
|
||||
{
|
||||
@Override
|
||||
public synchronized void onFillable()
|
||||
|
@ -57,7 +57,6 @@ public class SlowClientWithPipelinedRequestTest
|
|||
handles.incrementAndGet();
|
||||
super.onFillable();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -85,10 +85,8 @@ public class StressTest
|
|||
_threads = new QueuedThreadPool();
|
||||
_threads.setMaxThreads(200);
|
||||
|
||||
_server = new Server();
|
||||
_server.setThreadPool(_threads);
|
||||
|
||||
_connector = new SelectChannelConnector(1,1);
|
||||
_server = new Server(_threads);
|
||||
_connector = new SelectChannelConnector(_server,null,null,null,null,false,1,1);
|
||||
_connector.setAcceptQueueSize(5000);
|
||||
_connector.setIdleTimeout(30000);
|
||||
_server.addConnector(_connector);
|
||||
|
|
|
@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.junit.Test;
|
||||
|
@ -35,7 +35,7 @@ public class ContextHandlerCollectionTest
|
|||
public void testVirtualHostNormalization() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
LocalHttpConnector connector = new LocalHttpConnector();
|
||||
LocalConnector connector = new LocalConnector(server);
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class ContextHandlerCollectionTest
|
|||
public void testVirtualHostWildcard() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
LocalHttpConnector connector = new LocalHttpConnector();
|
||||
LocalConnector connector = new LocalConnector(server);
|
||||
server.setConnectors(new Connector[] { connector });
|
||||
|
||||
ContextHandler context = new ContextHandler("/");
|
||||
|
@ -133,7 +133,7 @@ public class ContextHandlerCollectionTest
|
|||
|
||||
private void checkWildcardHost(boolean succeed, Server server, String[] contextHosts, String[] requestHosts) throws Exception
|
||||
{
|
||||
LocalHttpConnector connector = (LocalHttpConnector)server.getConnectors()[0];
|
||||
LocalConnector connector = (LocalConnector)server.getConnectors()[0];
|
||||
ContextHandlerCollection handlerCollection = (ContextHandlerCollection)server.getHandler();
|
||||
ContextHandler context = (ContextHandler)handlerCollection.getHandlers()[0];
|
||||
IsHandledHandler handler = (IsHandledHandler)context.getHandler();
|
||||
|
|
|
@ -31,7 +31,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
@ -58,7 +58,7 @@ public class ContextHandlerTest
|
|||
public void testVirtualHostNormalization() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
LocalHttpConnector connector = new LocalHttpConnector();
|
||||
LocalConnector connector = new LocalConnector(server);
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class ContextHandlerTest
|
|||
public void testContextGetContext() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
LocalHttpConnector connector = new LocalHttpConnector();
|
||||
LocalConnector connector = new LocalConnector(server);
|
||||
server.setConnectors(new Connector[] { connector });
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
server.setHandler(contexts);
|
||||
|
@ -149,7 +149,7 @@ public class ContextHandlerTest
|
|||
public void testContextVirtualGetContext() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
LocalHttpConnector connector = new LocalHttpConnector();
|
||||
LocalConnector connector = new LocalConnector(server);
|
||||
server.setConnectors(new Connector[] { connector });
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
server.setHandler(contexts);
|
||||
|
@ -196,7 +196,7 @@ public class ContextHandlerTest
|
|||
public void testVirtualHostWildcard() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
LocalHttpConnector connector = new LocalHttpConnector();
|
||||
LocalConnector connector = new LocalConnector(server);
|
||||
server.setConnectors(new Connector[] { connector });
|
||||
|
||||
ContextHandler context = new ContextHandler("/");
|
||||
|
@ -365,7 +365,7 @@ public class ContextHandlerTest
|
|||
{
|
||||
Server server = new Server();
|
||||
server.setUncheckedPrintWriter(true);
|
||||
LocalHttpConnector connector = new LocalHttpConnector();
|
||||
LocalConnector connector = new LocalConnector(server);
|
||||
server.setConnectors(new Connector[] { connector });
|
||||
ContextHandler context = new ContextHandler("/");
|
||||
WriterHandler handler = new WriterHandler();
|
||||
|
@ -391,7 +391,7 @@ public class ContextHandlerTest
|
|||
|
||||
private void checkWildcardHost(boolean succeed, Server server, String[] contextHosts, String[] requestHosts) throws Exception
|
||||
{
|
||||
LocalHttpConnector connector = (LocalHttpConnector)server.getConnectors()[0];
|
||||
LocalConnector connector = (LocalConnector)server.getConnectors()[0];
|
||||
ContextHandler context = (ContextHandler)server.getHandler();
|
||||
context.setVirtualHosts(contextHosts);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class IPAccessHandlerTest
|
|||
throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new SelectChannelConnector();
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_server.setConnectors(new Connector[] { _connector });
|
||||
|
||||
_handler = new IPAccessHandler();
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ResourceHandlerTest extends TestCase
|
|||
public void setUp() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new SelectChannelConnector();
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_server.setConnectors(new Connector[] { _connector });
|
||||
|
||||
_resourceHandler = new ResourceHandler();
|
||||
|
|
|
@ -31,7 +31,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.eclipse.jetty.continuation.Continuation;
|
||||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.continuation.ContinuationSupport;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.junit.After;
|
||||
|
@ -41,7 +41,7 @@ import org.junit.Test;
|
|||
public class StatisticsHandlerTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalConnector _connector;
|
||||
private LatchHandler _latchHandler;
|
||||
private StatisticsHandler _statsHandler;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class StatisticsHandlerTest
|
|||
{
|
||||
_server = new Server();
|
||||
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector = new LocalConnector(_server);
|
||||
_server.addConnector(_connector);
|
||||
_connector.getStatistics().start();
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class SSLCloseTest extends TestCase
|
|||
public void testClose() throws Exception
|
||||
{
|
||||
Server server=new Server();
|
||||
SslSelectChannelConnector connector=new SslSelectChannelConnector();
|
||||
SslSelectChannelConnector connector=new SslSelectChannelConnector(server);
|
||||
|
||||
String keystore = System.getProperty("user.dir")+File.separator+"src"+File.separator+"test"+File.separator+"resources"+File.separator+"keystore";
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public class SSLEngineTest
|
|||
public void startServer() throws Exception
|
||||
{
|
||||
server=new Server();
|
||||
connector=new SslSelectChannelConnector();
|
||||
connector=new SslSelectChannelConnector(server);
|
||||
String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath();
|
||||
|
||||
connector.setPort(0);
|
||||
|
@ -96,8 +96,8 @@ public class SSLEngineTest
|
|||
cf.setKeyStorePath(keystore);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
connector.setRequestBufferSize(512);
|
||||
connector.setRequestHeaderSize(512);
|
||||
connector.getHttpConfig().setRequestBufferSize(512);
|
||||
connector.getHttpConfig().setRequestHeaderSize(512);
|
||||
|
||||
server.setConnectors(new Connector[]{connector });
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class SSLSelectChannelConnectorLoadTest
|
|||
public static void startServer() throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new SslSelectChannelConnector();
|
||||
connector = new SslSelectChannelConnector(server);
|
||||
server.addConnector(connector);
|
||||
|
||||
String keystorePath = System.getProperty("basedir", ".") + "/src/test/resources/keystore";
|
||||
|
@ -69,7 +69,7 @@ public class SSLSelectChannelConnectorLoadTest
|
|||
server.start();
|
||||
|
||||
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
keystore.load(new FileInputStream(connector.getKeystore()), "storepwd".toCharArray());
|
||||
keystore.load(new FileInputStream(connector.getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
|
||||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
trustManagerFactory.init(keystore);
|
||||
sslContext = SSLContext.getInstance("SSL");
|
||||
|
|
|
@ -49,7 +49,7 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
|
|||
@BeforeClass
|
||||
public static void init() throws Exception
|
||||
{
|
||||
SslSelectChannelConnector connector = new SslSelectChannelConnector();
|
||||
SslSelectChannelConnector connector = new SslSelectChannelConnector(_server);
|
||||
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
|
@ -62,7 +62,7 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
|
|||
|
||||
|
||||
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
keystore.load(new FileInputStream(connector.getKeystore()), "storepwd".toCharArray());
|
||||
keystore.load(new FileInputStream(connector.getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
|
||||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
trustManagerFactory.init(keystore);
|
||||
__sslContext = SSLContext.getInstance("TLS");
|
||||
|
|
|
@ -81,7 +81,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
threadPool = Executors.newCachedThreadPool();
|
||||
server = new Server();
|
||||
|
||||
SslSelectChannelConnector connector = new SslSelectChannelConnector()
|
||||
SslSelectChannelConnector connector = new SslSelectChannelConnector(server)
|
||||
{
|
||||
@Override
|
||||
protected SslConnection newSslConnection(AsyncEndPoint endPoint, SSLEngine engine)
|
||||
|
|
|
@ -37,7 +37,7 @@ public class SslSelectChannelTimeoutTest extends ConnectorTimeoutTest
|
|||
@BeforeClass
|
||||
public static void init() throws Exception
|
||||
{
|
||||
SslSelectChannelConnector connector = new SslSelectChannelConnector();
|
||||
SslSelectChannelConnector connector = new SslSelectChannelConnector(_server);
|
||||
connector.setIdleTimeout(MAX_IDLE_TIME); //250 msec max idle
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
|
@ -49,7 +49,7 @@ public class SslSelectChannelTimeoutTest extends ConnectorTimeoutTest
|
|||
startServer(connector);
|
||||
|
||||
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
keystore.load(new FileInputStream(connector.getKeystore()), "storepwd".toCharArray());
|
||||
keystore.load(new FileInputStream(connector.getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
|
||||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
trustManagerFactory.init(keystore);
|
||||
__sslContext = SSLContext.getInstance("SSL");
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SslUploadTest
|
|||
public static void startServer() throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new SslSelectChannelConnector();
|
||||
connector = new SslSelectChannelConnector(server);
|
||||
server.addConnector(connector);
|
||||
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
|
@ -83,7 +83,7 @@ public class SslUploadTest
|
|||
public void test() throws Exception
|
||||
{
|
||||
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
keystore.load(new FileInputStream(connector.getKeystore()), "storepwd".toCharArray());
|
||||
keystore.load(new FileInputStream(connector.getSslContextFactory().getKeyStorePath()), "storepwd".toCharArray());
|
||||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
trustManagerFactory.init(keystore);
|
||||
SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||
|
|
|
@ -39,17 +39,16 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.io.WriterOutputStream;
|
||||
import org.eclipse.jetty.server.AbstractConnector;
|
||||
import org.eclipse.jetty.server.HttpConnection;
|
||||
import org.eclipse.jetty.server.HttpChannel;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Dispatcher;
|
||||
import org.eclipse.jetty.server.HttpConnector;
|
||||
import org.eclipse.jetty.server.HttpOutput;
|
||||
import org.eclipse.jetty.server.InclusiveByteRange;
|
||||
import org.eclipse.jetty.server.ResourceCache;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.ssl.SslConnector;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.MultiPartOutputStream;
|
||||
|
@ -779,7 +778,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
}
|
||||
else
|
||||
{
|
||||
HttpConnector connector = HttpChannel.getCurrentHttpChannel().getHttpConnector();
|
||||
Connector connector = HttpChannel.getCurrentHttpChannel().getConnector();
|
||||
// TODO either make this more targeted and/or configurable or just get rid of the choice
|
||||
direct=!(connector instanceof SslConnector);
|
||||
content_length=content.getContentLength();
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.jetty.http.HttpMethod;
|
|||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.Attributes;
|
||||
|
@ -29,7 +29,7 @@ import org.eclipse.jetty.util.resource.Resource;
|
|||
public class ServletTester extends AggregateLifeCycle
|
||||
{
|
||||
private final Server _server=new Server();
|
||||
private final LocalHttpConnector _connector=new LocalHttpConnector();
|
||||
private final LocalConnector _connector=new LocalConnector(_server);
|
||||
private final ServletContextHandler _context;
|
||||
public void setVirtualHosts(String[] vhosts)
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ public class ServletTester extends AggregateLifeCycle
|
|||
*/
|
||||
public String createConnector(boolean localhost) throws Exception
|
||||
{
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
SelectChannelConnector connector = new SelectChannelConnector(_server);
|
||||
if (localhost)
|
||||
connector.setHost("127.0.0.1");
|
||||
_server.addConnector(connector);
|
||||
|
@ -198,9 +198,9 @@ public class ServletTester extends AggregateLifeCycle
|
|||
)+":"+connector.getLocalPort();
|
||||
}
|
||||
|
||||
public LocalHttpConnector createLocalConnector()
|
||||
public LocalConnector createLocalConnector()
|
||||
{
|
||||
LocalHttpConnector connector = new LocalHttpConnector();
|
||||
LocalConnector connector = new LocalConnector(_server);
|
||||
_server.addConnector(connector);
|
||||
return connector;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.jetty.continuation.ContinuationSupport;
|
|||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.HttpChannelState;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
|
@ -45,7 +45,7 @@ public class AsyncContextDispatchWithQueryStrings {
|
|||
|
||||
private Server _server = new Server();
|
||||
private ServletContextHandler _contextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
|
||||
private LocalHttpConnector _connector = new LocalHttpConnector();
|
||||
private LocalConnector _connector = new LocalConnector(_server);
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
|
|
@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletResponseWrapper;
|
|||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
|
@ -50,14 +50,14 @@ public class AsyncContextTest
|
|||
|
||||
private Server _server;
|
||||
private ServletContextHandler _contextHandler;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalConnector _connector;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_contextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector = new LocalConnector(_server);
|
||||
_connector.setIdleTimeout(30000);
|
||||
_server.setConnectors(new Connector[]
|
||||
{ _connector });
|
||||
|
|
|
@ -28,7 +28,7 @@ import javax.servlet.ServletResponse;
|
|||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
@ -48,7 +48,7 @@ public class DefaultServletTest
|
|||
public TestingDir testdir = new TestingDir();
|
||||
|
||||
private Server server;
|
||||
private LocalHttpConnector connector;
|
||||
private LocalConnector connector;
|
||||
private ServletContextHandler context;
|
||||
|
||||
@Before
|
||||
|
@ -57,7 +57,7 @@ public class DefaultServletTest
|
|||
server = new Server();
|
||||
server.setSendServerVersion(false);
|
||||
|
||||
connector = new LocalHttpConnector();
|
||||
connector = new LocalConnector(server);
|
||||
|
||||
context = new ServletContextHandler();
|
||||
context.setContextPath("/context");
|
||||
|
|
|
@ -45,7 +45,7 @@ import javax.servlet.http.HttpServletResponseWrapper;
|
|||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.server.Dispatcher;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
|
@ -58,7 +58,7 @@ import org.junit.Test;
|
|||
public class DispatcherTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalConnector _connector;
|
||||
private ContextHandlerCollection _contextCollection;
|
||||
private ServletContextHandler _contextHandler;
|
||||
private ResourceHandler _resourceHandler;
|
||||
|
@ -68,7 +68,7 @@ public class DispatcherTest
|
|||
{
|
||||
_server = new Server();
|
||||
_server.setSendServerVersion(false);
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector = new LocalConnector(_server);
|
||||
|
||||
_contextCollection = new ContextHandlerCollection();
|
||||
_contextHandler = new ServletContextHandler();
|
||||
|
|
|
@ -23,7 +23,7 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -35,13 +35,13 @@ import org.junit.Test;
|
|||
public class InvokerTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalConnector _connector;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector = new LocalConnector(_server);
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
||||
|
||||
_server.setSendServerVersion(false);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ResponseHeadersTest
|
|||
{
|
||||
// Configure Server
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector();
|
||||
connector = new SelectChannelConnector(server);
|
||||
server.addConnector(connector);
|
||||
|
||||
ServletContextHandler context = new ServletContextHandler();
|
||||
|
|
|
@ -26,7 +26,7 @@ import junit.framework.AssertionFailedError;
|
|||
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
import org.eclipse.jetty.security.SecurityHandler;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandlerContainer;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
|
@ -39,14 +39,14 @@ import org.junit.Test;
|
|||
public class ServletContextHandlerTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalConnector _connector;
|
||||
|
||||
@Before
|
||||
public void createServer()
|
||||
{
|
||||
_server = new Server();
|
||||
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector = new LocalConnector(_server);
|
||||
_server.addConnector(_connector);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
|
@ -45,7 +45,7 @@ public class QoSFilterTest
|
|||
private static final Logger LOG = Log.getLogger(QoSFilterTest.class);
|
||||
|
||||
private ServletTester _tester;
|
||||
private LocalHttpConnector[] _connectors;
|
||||
private LocalConnector[] _connectors;
|
||||
private CountDownLatch _doneRequests;
|
||||
private final int NUM_CONNECTIONS = 8;
|
||||
private final int NUM_LOOPS = 6;
|
||||
|
@ -60,7 +60,7 @@ public class QoSFilterTest
|
|||
TestServlet.__maxSleepers=0;
|
||||
TestServlet.__sleepers=0;
|
||||
|
||||
_connectors = new LocalHttpConnector[NUM_CONNECTIONS];
|
||||
_connectors = new LocalConnector[NUM_CONNECTIONS];
|
||||
for(int i = 0; i < _connectors.length; ++i)
|
||||
_connectors[i] = _tester.createLocalConnector();
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.SecureRandom;
|
||||
|
@ -1525,6 +1528,19 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public SSLEngine createSSLEngine(InetSocketAddress address) throws IOException
|
||||
{
|
||||
SSLEngine engine = (address != null)
|
||||
?newSslEngine(address.getAddress().getHostAddress(), address.getPort())
|
||||
:newSslEngine();
|
||||
engine.setUseClientMode(false);
|
||||
|
||||
customize(engine);
|
||||
return engine;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s@%x(%s,%s)",
|
||||
|
|
Loading…
Reference in New Issue