jetty-9 javadoc improvements and renamed SelectChannelConnector to ServerConnector
This commit is contained in:
parent
b3381b4996
commit
129583679a
|
@ -29,7 +29,7 @@ import org.eclipse.jetty.server.Connector;
|
|||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.NCSARequestLog;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
|
@ -66,7 +66,7 @@ public class LikeJettyXml
|
|||
// Setup Connectors
|
||||
HttpConnectionFactory http = new HttpConnectionFactory();
|
||||
http.getHttpChannelConfig().setSecurePort(8443);
|
||||
SelectChannelConnector connector = new SelectChannelConnector(server,http);
|
||||
ServerConnector connector = new ServerConnector(server,http);
|
||||
connector.setPort(8080);
|
||||
connector.setIdleTimeout(30000);
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class LikeJettyXml
|
|||
"SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
|
||||
"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"
|
||||
});
|
||||
SelectChannelConnector sslConnector = new SelectChannelConnector(server,sslContextFactory);
|
||||
ServerConnector sslConnector = new ServerConnector(server,sslContextFactory);
|
||||
sslConnector.setPort(8443);
|
||||
server.addConnector(sslConnector);
|
||||
sslConnector.open();
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.jetty.server.ForwardedRequestCustomizer;
|
|||
import org.eclipse.jetty.server.HttpChannelConfig;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.SecureRequestCustomizer;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.SslConnectionFactory;
|
||||
import org.eclipse.jetty.spdy.NPNServerConnectionFactory;
|
||||
|
@ -51,7 +51,7 @@ public class ManyConnectors
|
|||
Server server = new Server();
|
||||
|
||||
// HTTP connector
|
||||
SelectChannelConnector connector0 = new SelectChannelConnector(server);
|
||||
ServerConnector connector0 = new ServerConnector(server);
|
||||
connector0.setPort(8080);
|
||||
connector0.setIdleTimeout(30000);
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class ManyConnectors
|
|||
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
|
||||
sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
|
||||
|
||||
SelectChannelConnector connector1 = new SelectChannelConnector(server,sslContextFactory);
|
||||
ServerConnector connector1 = new ServerConnector(server,sslContextFactory);
|
||||
connector1.setPort(8443);
|
||||
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class ManyConnectors
|
|||
TimerScheduler scheduler = new TimerScheduler();
|
||||
ByteBufferPool bufferPool= new ArrayByteBufferPool(32,4096,32768);
|
||||
|
||||
SelectChannelConnector connector2 = new SelectChannelConnector(server,threadPool,scheduler,bufferPool,2,2,ssl,npn,spdy3,spdy2,http);
|
||||
ServerConnector connector2 = new ServerConnector(server,threadPool,scheduler,bufferPool,2,2,ssl,npn,spdy3,spdy2,http);
|
||||
connector2.setDefaultProtocol("ssl-npn");
|
||||
connector2.setPort(8444);
|
||||
connector2.setIdleTimeout(30000);
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.eclipse.jetty.embedded;
|
|||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
|
@ -42,7 +42,7 @@ public class ManyContexts
|
|||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
SelectChannelConnector connector = new SelectChannelConnector(server);
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
connector.setPort(8080);
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.eclipse.jetty.embedded;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class OneWebApp
|
|||
{
|
||||
Server server = new Server();
|
||||
|
||||
SelectChannelConnector connector = new SelectChannelConnector(server);
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
connector.setPort(Integer.getInteger("jetty.port",8080).intValue());
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.eclipse.jetty.embedded;
|
|||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
|
@ -41,7 +41,7 @@ public class SplitFileServer
|
|||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
SelectChannelConnector connector = new SelectChannelConnector(server);
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
connector.setPort(8090);
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.nio.ServerConnector">
|
||||
<Set name="port">8080</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
|
@ -32,4 +32,4 @@
|
|||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</Configure>
|
||||
</Configure>
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.eclipse.jetty.ant.utils.WebApplicationProxy;
|
|||
import org.eclipse.jetty.security.LoginService;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.RequestLog;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
|
@ -123,7 +123,7 @@ public class ServerProxyImpl implements ServerProxy
|
|||
while (connectorIterator.hasNext())
|
||||
{
|
||||
Connector jettyConnector = (Connector) connectorIterator.next();
|
||||
SelectChannelConnector jc = new SelectChannelConnector(server);
|
||||
ServerConnector jc = new ServerConnector(server);
|
||||
|
||||
jc.setPort(jettyConnector.getPort());
|
||||
jc.setIdleTimeout(jettyConnector.getMaxIdleTime());
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Collection;
|
|||
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
@ -80,7 +80,7 @@ public abstract class AbstractHttpClientServerTest
|
|||
|
||||
if (server == null)
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector(server, sslContextFactory);
|
||||
connector = new ServerConnector(server, sslContextFactory);
|
||||
server.addConnector(connector);
|
||||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Arg><Ref id="Server" /></Arg>
|
||||
<Set name="host"></Set>
|
||||
<Set name="port">0</Set>
|
||||
|
|
|
@ -108,7 +108,7 @@ public abstract class AbstractConnection implements Connection
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldDispatchCompletion()
|
||||
protected boolean alwaysDispatchCompletion()
|
||||
{
|
||||
return dispatchCompletion;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public abstract class AbstractConnection implements Connection
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s@%x", getClass().getSimpleName(), AbstractConnection.this.hashCode());
|
||||
return String.format("AC.ReadCB@%x", AbstractConnection.this.hashCode());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.eclipse.jetty.maven.plugin;
|
|||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.RequestLog;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
|
@ -116,7 +116,7 @@ public class JettyServer extends org.eclipse.jetty.server.Server
|
|||
|
||||
public Connector createDefaultConnector(Server server, String portnum) throws Exception
|
||||
{
|
||||
SelectChannelConnector connector = new SelectChannelConnector(server);
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
int port = ((portnum==null||portnum.equals(""))?DEFAULT_PORT:Integer.parseInt(portnum.trim()));
|
||||
connector.setPort(port);
|
||||
connector.setIdleTimeout(DEFAULT_MAX_IDLE_TIME);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Set name="host"><Property name="jetty.host" /></Set>
|
||||
<Set name="port"><Property name="jetty.port" default="8080"/></Set>
|
||||
<Set name="idleTimeout">300000</Set>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Set name="host"><Property name="jetty.host" /></Set>
|
||||
<Set name="port"><Property name="jetty.port" default="8888"/></Set>
|
||||
<Set name="idleTimeout">300000</Set>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
-->
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Set name="host"><SystemProperty name="jetty.host" /></Set>
|
||||
<Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
|
||||
<Set name="idleTimeout">30000</Set>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Set name="port">8080</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<!-- =========================================================== -->
|
||||
<Call id="sslConnector" name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Arg name="server"><Ref id="Server" /></Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<!-- =========================================================== -->
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Arg name="server"><Ref id="Server" /></Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -33,6 +34,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.eclipse.jetty.io.ArrayByteBufferPool;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
|
@ -40,24 +42,94 @@ 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;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
import org.eclipse.jetty.util.thread.TimerScheduler;
|
||||
|
||||
/**
|
||||
* <p>Partial implementation of {@link Connector}</p>
|
||||
* <p>An abstract implementation of {@link Connector} that provides a {@link ConnectionFactory} mechanism
|
||||
* for creating {@link Connection} instances for various protocols (HTTP, SSL, SPDY, etc).</p>
|
||||
*
|
||||
* <p>
|
||||
* <h2>Connector Services</h2>
|
||||
* The abstract connector manages the dependent services needed by all specific connector instances:
|
||||
* <ul>
|
||||
* <li>The {@link Executor} service is used to run all active tasks needed by this connector such as accepting connections
|
||||
* or handle HTTP requests. The default is to use the {@link Server#getThreadPool()} as an executor.
|
||||
* </li>
|
||||
* <li>The {@link Scheduler} service is used to monitor the idle timeouts of all connections and is also made available
|
||||
* to the connections to time such things as asynchronous request timeouts. The default is to use a new
|
||||
* {@link TimerScheduler} instance.
|
||||
* </li>
|
||||
* <li>The {@link ByteBufferPool} service is made available to all connections to be used to acquire and release
|
||||
* {@link ByteBuffer} instances from a pool. The default is to use a new {@link ArrayByteBufferPool} instance.
|
||||
* </li>
|
||||
* </ul>
|
||||
* These services are managed as aggregate beans by the {@link AggregateLifeCycle} super class and
|
||||
* may either be managed or unmanaged beans.
|
||||
*
|
||||
* <h2>Connection Factories</h2>
|
||||
* The connector keeps a collection of {@link ConnectionFactory} instances, each of which are known by their
|
||||
* protocol name. The protocol name may be a real protocol (eg http/1.1 or spdy/3) or it may be a private name
|
||||
* that represents a special connection factory. For example, the name "SSL-http/1.1" is used for
|
||||
* an {@link SslConnectionFactory} that has been instantiated with the {@link HttpConnectionFactory} as it's
|
||||
* next protocol.
|
||||
* <p>
|
||||
* If NPN is used to select the real protocol used by an SSL connection, then the name "SSL-NPN" is used,
|
||||
* which represents a {@link SslConnectionFactory} with a NPNConnectionFactory as the next protocol. Once
|
||||
* the NPN connection is established, it will get the next protocol from the NPN extension and then call
|
||||
* {@link #getConnectionFactory(String)} to get the next connection factory.
|
||||
*
|
||||
* <h4>Configuring Connection Factories</h4>
|
||||
* The collection of available {@link ConnectionFactory} may be constructor injected or modified with the
|
||||
* methods {@link #addConnectionFactory(ConnectionFactory)}, {@link #removeConnectionFactory(String)} and
|
||||
* {@link #setConnectionFactories(Collection)}. Only a single {@link ConnectionFactory} instance may be configured
|
||||
* per protocol name, so if two factories with the same {@link ConnectionFactory#getProtocol()} are set, then
|
||||
* the second will replace the first.
|
||||
* <p>
|
||||
* The protocol factory used for newly accepted connections is specified by
|
||||
* the method {@link #setDefaultProtocol(String)} or defaults to the protocol of the first configured factory.
|
||||
* <p>
|
||||
* Each Connection factory type is responsible for the configuration of the protocols that it accepts. Thus to
|
||||
* configure the HTTP protocol, you pass a {@link HttpChannelConfig} instance to the {@link HttpConnectionFactory}
|
||||
* (or the SPDY factories that can also provide HTTP Semantics). Similarly the {@link SslConnectionFactory} is
|
||||
* configured by passing it a {@link SslContextFactory} and a next protocol name.
|
||||
*
|
||||
* <h4>Connection Factory Operation</h4>
|
||||
* {@link ConnectionFactory}s may simply create a {@link Connection} instance to support a specific
|
||||
* protocol. For example, the {@link HttpConnectionFactory} will create a {@link HttpConnection} instance
|
||||
* that can handle http/1.1, http/1.0 and http/0.9.
|
||||
* <p>
|
||||
* {@link ConnectionFactory}s may also create a chain of {@link Connection} instances, using other {@link ConnectionFactory} instances.
|
||||
* For example, the {@link SslConnectionFactory} is configured with a next protocol name, so that once it has accepted
|
||||
* a connection and created an {@link SslConnection}, it then used the next {@link ConnectionFactory} from the
|
||||
* connector using the {@link #getConnectionFactory(String)} method, to create a {@link Connection} instance that
|
||||
* will handle the unecrypted bytes from the {@link SslConnection}. If the next protocol is "http/1.1", then the
|
||||
* {@link SslConnectionFactory} will have a protocol name of "SSL-http/1.1" and lookup "http/1.1" for the protocol
|
||||
* to run over the SSL connection.
|
||||
* <p>
|
||||
* {@link ConnectionFactory}s may also create temporary {@link Connection} instances that will exchange bytes
|
||||
* over the connection to determine what is the next protocol to use. For example the NPN protocol is an extension
|
||||
* of SSL to allow a protocol to be specified during the SSL handshake. NPN is used by the SPDY protocol to
|
||||
* negotiate the version of SPDY or HTTP that the client and server will speak. Thus to accept a SPDY connection, the
|
||||
* connector will be configured with {@link ConnectionFactory}s for "SSL-NPN", "NPN", "spdy/3", "spdy/2", "http/1.1"
|
||||
* with the default protocol being "SSL-NPN". Thus a newly accepted connection uses "SSL-NPN", which specifies a
|
||||
* SSLConnectionFactory with "NPN" as the next protocol. Thus an SslConnection instance is created chained to an NPNConnection
|
||||
* instance. The NPN connection then negotiates with the client to determined the next protocol, which could be
|
||||
* "spdy/3", "spdy/2" or the default of "http/1.1". Once the next protocol is determined, the NPN connection
|
||||
* calls {@link #getConnectionFactory(String)} to create a connection instance that will replace the NPN connection as
|
||||
* the connection chained to the SSLConnection.
|
||||
* <p>
|
||||
* <h2>Acceptors</h2>
|
||||
* The connector will execute a number of acceptor tasks to the {@link Exception} service passed to the constructor.
|
||||
* The acceptor tasks run in a loop while the connector is running and repeatedly call the abstract {@link #accept(int)} method.
|
||||
* The implementation of the accept method must:
|
||||
* <nl>
|
||||
* <li>block waiting for new connections
|
||||
* <li>accept the connection (eg socket accept)
|
||||
* <li>perform any configuration of the connection (eg. socket linger times)
|
||||
* <li>call the {@link #getDefaultConnectionFactory()} {@link ConnectionFactory#newConnection(Connector, org.eclipse.jetty.io.EndPoint)}
|
||||
* method to create a new Connection instance.
|
||||
* <li>call the {@link #connectionOpened(Connection)} method to signal a new connection has been created.
|
||||
* <li>arrange for the {@link #connectionClosed(Connection)} method to be called once the connection is closed.
|
||||
* </nl>
|
||||
* The default number of acceptor tasks is the minimum of 1 and half the number of available CPUs. Having more acceptors may reduce
|
||||
* the latency for servers that see a high rate of new connections (eg HTTP/1.0 without keep-alive). Typically the default is
|
||||
* sufficient for modern persistent protocols (HTTP/1.1, SPDY etc.)
|
||||
*/
|
||||
@ManagedObject("Abstract implementation of the Connector Interface")
|
||||
public abstract class AbstractConnector extends AggregateLifeCycle implements Connector, Dumpable
|
||||
|
@ -78,12 +150,11 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
|
||||
/**
|
||||
* @param server The server this connector will be added to. Must not be null.
|
||||
* @param factory TODO
|
||||
* @param sslContextFactory the SSL context factory to make this connector SSL enabled, or 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 scheduler A scheduler for this connector or null to a new {@link TimerScheduler} instance.
|
||||
* @param pool A buffer pool for this connector or null to use a default {@link ByteBufferPool}
|
||||
* @param acceptors the number of acceptor threads to use, or 0 for a default value.
|
||||
* @param factories The Connection Factories to use.
|
||||
*/
|
||||
public AbstractConnector(
|
||||
Server server,
|
||||
|
@ -110,7 +181,7 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
addConnectionFactory(factory);
|
||||
|
||||
if (acceptors<=0)
|
||||
acceptors=Math.max(1,(Runtime.getRuntime().availableProcessors()) / 4);
|
||||
acceptors=Math.max(1,(Runtime.getRuntime().availableProcessors()) / 2);
|
||||
if (acceptors > 2 * Runtime.getRuntime().availableProcessors())
|
||||
LOG.warn("Acceptors should be <= 2*availableProcessors: " + this);
|
||||
_acceptors = new Thread[acceptors];
|
||||
|
@ -299,6 +370,20 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
return _factories.values();
|
||||
}
|
||||
}
|
||||
|
||||
public void setConnectionFactories(Collection<ConnectionFactory> factories)
|
||||
{
|
||||
synchronized (_factories)
|
||||
{
|
||||
List<ConnectionFactory> existing = new ArrayList<>(_factories.values());
|
||||
for (ConnectionFactory factory: existing)
|
||||
removeConnectionFactory(factory.getProtocol());
|
||||
for (ConnectionFactory factory: factories)
|
||||
if (factory!=null)
|
||||
addConnectionFactory(factory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getProtocols()
|
||||
|
|
|
@ -26,7 +26,9 @@ import org.eclipse.jetty.io.ByteBufferPool;
|
|||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
|
||||
/**
|
||||
* <p>Partial implementation of {@link NetworkConnector}.</p>
|
||||
* An abstract Network Connector.
|
||||
* <p>
|
||||
* Extends the {@link AbstractConnector} support for the {@link NetworkConnector} interface.
|
||||
*/
|
||||
public abstract class AbstractNetworkConnector extends AbstractConnector implements NetworkConnector
|
||||
{
|
||||
|
|
|
@ -187,9 +187,9 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
{
|
||||
while (true)
|
||||
{
|
||||
// Can the parser progress (even with an empty buffer)
|
||||
// Can the parser progress (even with an empty buffer)
|
||||
boolean event=_parser.parseNext(_requestBuffer==null?BufferUtil.EMPTY_BUFFER:_requestBuffer);
|
||||
|
||||
|
||||
// If there is a request buffer, we are re-entering here
|
||||
if (!event && BufferUtil.isEmpty(_requestBuffer))
|
||||
{
|
||||
|
@ -199,7 +199,6 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
int filled = getEndPoint().fill(_requestBuffer);
|
||||
if (filled==0) // Do a retry on fill 0 (optimisation for SSL connections)
|
||||
filled = getEndPoint().fill(_requestBuffer);
|
||||
|
||||
|
||||
LOG.debug("{} filled {}", this, filled);
|
||||
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
|
||||
public class HttpServerConnector extends SelectChannelConnector
|
||||
{
|
||||
public HttpServerConnector(
|
||||
@Name("server") Server server)
|
||||
{
|
||||
this(server,null,null,null,null,null,0,0);
|
||||
}
|
||||
|
||||
public HttpServerConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("sslContextFactory") SslContextFactory sslContextFactory)
|
||||
{
|
||||
this(server,null,sslContextFactory, null, null, null, 0, 0);
|
||||
}
|
||||
|
||||
public HttpServerConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("connectionFactory") HttpConnectionFactory connectionFactory)
|
||||
{
|
||||
this(server,connectionFactory,null, null, null, null, 0, 0);
|
||||
}
|
||||
|
||||
public HttpServerConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("connectionFactory") HttpConnectionFactory connectionFactory,
|
||||
@Name("sslContextFactory") SslContextFactory sslContextFactory)
|
||||
{
|
||||
this(server,connectionFactory,sslContextFactory, null, null, null, 0, 0);
|
||||
}
|
||||
|
||||
public HttpServerConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("connectionFactory") HttpConnectionFactory connectionFactory,
|
||||
@Name("sslContextFactory") SslContextFactory sslContextFactory,
|
||||
@Name("executor") Executor executor,
|
||||
@Name("scheduler") Scheduler scheduler,
|
||||
@Name("bufferPool") ByteBufferPool pool,
|
||||
@Name("acceptors") int acceptors,
|
||||
@Name("selectors") int selectors)
|
||||
{
|
||||
super(server,executor,scheduler,pool,acceptors,selectors,AbstractConnectionFactory.getFactories(sslContextFactory,connectionFactory==null?new HttpConnectionFactory():connectionFactory));
|
||||
}
|
||||
}
|
|
@ -221,12 +221,7 @@ public class LocalConnector extends AbstractConnector
|
|||
try
|
||||
{
|
||||
if (!_closed.await(10,TimeUnit.SECONDS))
|
||||
{
|
||||
System.err.println("wait timeout:\n--");
|
||||
System.err.println(takeOutputString());
|
||||
System.err.println("==");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.eclipse.jetty.server;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <p>A {@link Connector} that handles network communication.</p>
|
||||
* <p>A {@link Connector} for TCP/IP network connectors</p>
|
||||
*/
|
||||
public interface NetworkConnector extends Connector, AutoCloseable
|
||||
{
|
||||
|
|
|
@ -85,29 +85,29 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
/* ------------------------------------------------------------ */
|
||||
public Server()
|
||||
{
|
||||
this((ThreadPool)null);
|
||||
this((ThreadPool)null,null);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Convenience constructor
|
||||
* Creates server and a {@link SelectChannelConnector} at the passed port.
|
||||
* Creates server and a {@link ServerConnector} at the passed port.
|
||||
*/
|
||||
public Server(@Name("port")int port)
|
||||
{
|
||||
this((ThreadPool)null);
|
||||
SelectChannelConnector connector=new HttpServerConnector(this);
|
||||
this((ThreadPool)null,null);
|
||||
ServerConnector connector=new ServerConnector(this);
|
||||
connector.setPort(port);
|
||||
setConnectors(new Connector[]{connector});
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Convenience constructor
|
||||
* Creates server and a {@link SelectChannelConnector} at the passed address.
|
||||
* Creates server and a {@link ServerConnector} at the passed address.
|
||||
*/
|
||||
public Server(@Name("address")InetSocketAddress addr)
|
||||
{
|
||||
this((ThreadPool)null);
|
||||
SelectChannelConnector connector=new HttpServerConnector(this);
|
||||
this((ThreadPool)null,null);
|
||||
ServerConnector connector=new ServerConnector(this);
|
||||
connector.setHost(addr.getHostName());
|
||||
connector.setPort(addr.getPort());
|
||||
setConnectors(new Connector[]{connector});
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.net.Socket;
|
|||
import java.net.SocketException;
|
||||
import java.nio.channels.Channel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.Executor;
|
||||
|
@ -36,16 +37,47 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.io.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.SelectorManager;
|
||||
import org.eclipse.jetty.io.SelectorManager.ManagedSelector;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
|
||||
/**
|
||||
* <p>Implementation of {@link NetworkConnector} based on NIO classes.</p>
|
||||
* This {@link Connector} implementation is the primary connector for the
|
||||
* Jetty server over TCP/IP. By the use of various {@link ConnectionFactory} instances it is able
|
||||
* to accept connections for HTTP, SPDY and WebSocket, either directly or over SSL.
|
||||
* <p>
|
||||
* The connector is a fully asynchronous NIO based implementation that by default will
|
||||
* use all the commons services (eg {@link Executor}, {@link Scheduler}) of the
|
||||
* passed {@link Server} instance, but all services may also be constructor injected
|
||||
* into the connector so that it may operate with dedicated or otherwise shared services.
|
||||
* <p>
|
||||
* <h2>Connection Factories</h2>
|
||||
* Various convenience constructors are provided to assist with common configurations of
|
||||
* ConnectionFactories, whose generic use is described in {@link AbstractConnector}.
|
||||
* If no connection factories are passed, then the connector will
|
||||
* default to use a {@link HttpConnectionFactory}. If an non null {@link SslContextFactory}
|
||||
* instance is passed, then this used to instantiate a {@link SslConnectionFactory} which is
|
||||
* prepended to the other passed or default factories.
|
||||
* <p>
|
||||
* <h2>Selectors</h2>
|
||||
* The connector will use the {@link Executor} service to execute a number of Selector Tasks,
|
||||
* which are implemented to each use a NIO {@link Selector} instance to asynchronously
|
||||
* schedule a set of accepted connections. It is the selector thread that will call the
|
||||
* {@link Callback} instances passed in the {@link EndPoint#fillInterested(Object, Callback)} or
|
||||
* {@link EndPoint#write(Object, Callback, java.nio.ByteBuffer...)} methods. It is expected
|
||||
* that these callbacks may do some non-blocking IO work, but will always dispatch to the
|
||||
* {@link Executor} service any blocking, long running or application tasks.
|
||||
* <p>
|
||||
* The default number of selectors is equal to the number of processors available to the JVM,
|
||||
* which should allow optimal performance even if all the connections used are performing
|
||||
* significant non-blocking work in the callback tasks.
|
||||
*
|
||||
*/
|
||||
@ManagedObject("HTTP connector using NIO ByteChannels and Selectors")
|
||||
public class SelectChannelConnector extends AbstractNetworkConnector
|
||||
public class ServerConnector extends AbstractNetworkConnector
|
||||
{
|
||||
private final SelectorManager _manager;
|
||||
private volatile ServerSocketChannel _acceptChannel;
|
||||
|
@ -56,27 +88,27 @@ public class SelectChannelConnector extends AbstractNetworkConnector
|
|||
private volatile int _lingerTime = -1;
|
||||
|
||||
|
||||
public SelectChannelConnector(
|
||||
public ServerConnector(
|
||||
@Name("server") Server server)
|
||||
{
|
||||
this(server,null,null,null,0,0,new HttpConnectionFactory());
|
||||
}
|
||||
|
||||
public SelectChannelConnector(
|
||||
public ServerConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("factories") ConnectionFactory... factories)
|
||||
{
|
||||
this(server,null,null,null,0,0,factories);
|
||||
}
|
||||
|
||||
public SelectChannelConnector(
|
||||
public ServerConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("sslContextFactory") SslContextFactory sslContextFactory)
|
||||
{
|
||||
this(server,null,null,null,0,0,AbstractConnectionFactory.getFactories(sslContextFactory,new HttpConnectionFactory()));
|
||||
}
|
||||
|
||||
public SelectChannelConnector(
|
||||
public ServerConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("sslContextFactory") SslContextFactory sslContextFactory,
|
||||
@Name("factories") ConnectionFactory... factories)
|
||||
|
@ -92,7 +124,7 @@ public class SelectChannelConnector extends AbstractNetworkConnector
|
|||
* @param acceptors the number of acceptor threads to use, or 0 for a default value.
|
||||
* @param factories Zero or more {@link ConnectionFactory} instances.
|
||||
*/
|
||||
public SelectChannelConnector(
|
||||
public ServerConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("executor") Executor executor,
|
||||
@Name("scheduler") Scheduler scheduler,
|
||||
|
@ -102,7 +134,7 @@ public class SelectChannelConnector extends AbstractNetworkConnector
|
|||
@Name("factories") ConnectionFactory... factories)
|
||||
{
|
||||
super(server,executor,scheduler,pool,acceptors,factories);
|
||||
_manager = new ConnectorSelectorManager(selectors > 0 ? selectors : Math.max(1, (Runtime.getRuntime().availableProcessors()) / 4));
|
||||
_manager = new ConnectorSelectorManager(selectors > 0 ? selectors : Runtime.getRuntime().availableProcessors());
|
||||
addBean(_manager, true);
|
||||
}
|
||||
|
||||
|
@ -329,25 +361,25 @@ public class SelectChannelConnector extends AbstractNetworkConnector
|
|||
@Override
|
||||
public void connectionOpened(Connection connection)
|
||||
{
|
||||
SelectChannelConnector.this.connectionOpened(connection);
|
||||
ServerConnector.this.connectionOpened(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(Connection connection)
|
||||
{
|
||||
SelectChannelConnector.this.connectionClosed(connection);
|
||||
ServerConnector.this.connectionClosed(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SelectChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey selectionKey) throws IOException
|
||||
{
|
||||
return SelectChannelConnector.this.newEndPoint(channel, selectSet, selectionKey);
|
||||
return ServerConnector.this.newEndPoint(channel, selectSet, selectionKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment) throws IOException
|
||||
{
|
||||
return getDefaultConnectionFactory().newConnection(SelectChannelConnector.this, endpoint);
|
||||
return getDefaultConnectionFactory().newConnection(ServerConnector.this, endpoint);
|
||||
}
|
||||
}
|
||||
|
|
@ -323,24 +323,6 @@ public class IPAccessHandler extends HandlerWrapper
|
|||
return true;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Dump the white- and black-list configurations when started
|
||||
*
|
||||
* @see org.eclipse.jetty.server.handler.HandlerWrapper#doStart()
|
||||
*/
|
||||
@Override
|
||||
protected void doStart()
|
||||
throws Exception
|
||||
{
|
||||
super.doStart();
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
System.err.println(dump());
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Dump the handler configuration
|
||||
|
|
|
@ -34,17 +34,17 @@ import org.eclipse.jetty.io.SelectChannelEndPoint;
|
|||
import org.eclipse.jetty.io.SelectorManager;
|
||||
import org.eclipse.jetty.server.ConnectionFactory;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
|
||||
/**
|
||||
* <p>A specialized version of {@link SelectChannelConnector} that supports {@link NetworkTrafficListener}s.</p>
|
||||
* <p>A specialized version of {@link ServerConnector} that supports {@link NetworkTrafficListener}s.</p>
|
||||
* <p>{@link NetworkTrafficListener}s can be added and removed dynamically before and after this connector has
|
||||
* been started without causing {@link ConcurrentModificationException}s.</p>
|
||||
*/
|
||||
public class NetworkTrafficSelectChannelConnector extends SelectChannelConnector
|
||||
public class NetworkTrafficSelectChannelConnector extends ServerConnector
|
||||
{
|
||||
private final List<NetworkTrafficListener> listeners = new CopyOnWriteArrayList<NetworkTrafficListener>();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.eclipse.jetty.server.ssl;
|
|||
|
||||
import org.eclipse.jetty.server.AbstractConnectionFactory;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
|
@ -31,7 +31,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
|||
* @deprecated use SelectChannelConnector with {@link SslContextFactory}
|
||||
* @org.apache.xbean.XBean element="sslConnector" description="Creates an NIO ssl connector"
|
||||
*/
|
||||
public class SslSelectChannelConnector extends SelectChannelConnector
|
||||
public class SslSelectChannelConnector extends ServerConnector
|
||||
{
|
||||
public SslSelectChannelConnector(Server server)
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.junit.Before;
|
|||
public abstract class AbstractHttpTest
|
||||
{
|
||||
protected static Server server;
|
||||
protected static SelectChannelConnector connector;
|
||||
protected static ServerConnector connector;
|
||||
protected String httpVersion;
|
||||
protected SimpleHttpParser httpParser;
|
||||
|
||||
|
@ -57,7 +57,7 @@ public abstract class AbstractHttpTest
|
|||
public void setUp() throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new HttpServerConnector(server);
|
||||
connector = new ServerConnector(server);
|
||||
connector.setIdleTimeout(10000);
|
||||
server.addConnector(connector);
|
||||
httpParser = new SimpleHttpParser();
|
||||
|
|
|
@ -46,14 +46,14 @@ import org.junit.Test;
|
|||
public class AsyncRequestReadTest
|
||||
{
|
||||
private static Server server;
|
||||
private static SelectChannelConnector connector;
|
||||
private static ServerConnector connector;
|
||||
private final static Exchanger<Long> __total=new Exchanger<Long>();
|
||||
|
||||
@BeforeClass
|
||||
public static void startServer() throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new HttpServerConnector(server);
|
||||
connector = new ServerConnector(server);
|
||||
connector.setIdleTimeout(10000);
|
||||
server.addConnector(connector);
|
||||
server.setHandler(new EmptyHandler());
|
||||
|
|
|
@ -54,7 +54,7 @@ public class AsyncStressTest
|
|||
protected QueuedThreadPool _threads=new QueuedThreadPool();
|
||||
protected Server _server = new Server(_threads);
|
||||
protected SuspendHandler _handler = new SuspendHandler();
|
||||
protected SelectChannelConnector _connector;
|
||||
protected ServerConnector _connector;
|
||||
protected InetAddress _addr;
|
||||
protected int _port;
|
||||
protected Random _random = new Random();
|
||||
|
@ -73,7 +73,7 @@ public class AsyncStressTest
|
|||
{
|
||||
_server.manage(_threads);
|
||||
_threads.setMaxThreads(50);
|
||||
_connector = new HttpServerConnector(_server);
|
||||
_connector = new ServerConnector(_server);
|
||||
_connector.setIdleTimeout(120000);
|
||||
_server.setConnectors(new Connector[]{ _connector });
|
||||
_server.setHandler(_handler);
|
||||
|
|
|
@ -58,7 +58,7 @@ import org.junit.Test;
|
|||
public class ResponseTest
|
||||
{
|
||||
private Server _server;
|
||||
private HttpChannel _channel;
|
||||
private HttpChannel<?> _channel;
|
||||
private Scheduler _scheduler;
|
||||
|
||||
@Before
|
||||
|
@ -500,7 +500,7 @@ public class ResponseTest
|
|||
server.setHandler(new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(String string, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
response.setStatus(200);
|
||||
response.setContentType("text/plain");
|
||||
|
@ -516,10 +516,11 @@ public class ResponseTest
|
|||
server.start();
|
||||
|
||||
Socket socket = new Socket("localhost", ((NetworkConnector)server.getConnectors()[0]).getLocalPort());
|
||||
socket.setSoTimeout(500000);
|
||||
socket.getOutputStream().write("HEAD / HTTP/1.1\r\nHost: localhost\r\n\r\n".getBytes());
|
||||
socket.getOutputStream().write("GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n".getBytes());
|
||||
socket.getOutputStream().flush();
|
||||
|
||||
|
||||
LineNumberReader reader = new LineNumberReader(new InputStreamReader(socket.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
Assert.assertThat(line, Matchers.startsWith("HTTP/1.1 200 OK"));
|
||||
|
|
|
@ -27,13 +27,13 @@ public class SelectChannelAsyncContextTest extends LocalAsyncContextTest
|
|||
@Override
|
||||
protected Connector initConnector()
|
||||
{
|
||||
return new SelectChannelConnector(_server);
|
||||
return new ServerConnector(_server);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getResponse(String request) throws Exception
|
||||
{
|
||||
SelectChannelConnector connector = (SelectChannelConnector)_connector;
|
||||
ServerConnector connector = (ServerConnector)_connector;
|
||||
Socket socket = new Socket((String)null,connector.getLocalPort());
|
||||
socket.getOutputStream().write(request.getBytes("UTF-8"));
|
||||
return IO.toString(socket.getInputStream());
|
||||
|
|
|
@ -30,7 +30,7 @@ public class SelectChannelConnectorCloseTest extends ConnectorCloseTestBase
|
|||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
startServer(new SelectChannelConnector(_server));
|
||||
startServer(new ServerConnector(_server));
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -28,7 +28,7 @@ public class SelectChannelServerTest extends HttpServerTestBase
|
|||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
startServer(new SelectChannelConnector(_server));
|
||||
startServer(new ServerConnector(_server));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -64,7 +64,7 @@ public class SelectChannelStatisticsTest
|
|||
_connect = new CyclicBarrier(2);
|
||||
|
||||
_server = new Server();
|
||||
_connector = new SelectChannelConnector(_server)
|
||||
_connector = new ServerConnector(_server)
|
||||
{
|
||||
@Override
|
||||
public void connectionClosed(Connection connection)
|
||||
|
|
|
@ -35,7 +35,7 @@ public class SelectChannelTimeoutTest extends ConnectorTimeoutTest
|
|||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
SelectChannelConnector connector = new SelectChannelConnector(_server);
|
||||
ServerConnector connector = new ServerConnector(_server);
|
||||
connector.setIdleTimeout(MAX_IDLE_TIME); // 250 msec max idle
|
||||
startServer(connector);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class SelectChannelTimeoutTest extends ConnectorTimeoutTest
|
|||
|
||||
private String getResponse(String request) throws UnsupportedEncodingException, IOException, InterruptedException
|
||||
{
|
||||
SelectChannelConnector connector = (SelectChannelConnector)_connector;
|
||||
ServerConnector connector = (ServerConnector)_connector;
|
||||
Socket socket = new Socket((String)null,connector.getLocalPort());
|
||||
socket.setSoTimeout(10 * MAX_IDLE_TIME);
|
||||
socket.getOutputStream().write(request.getBytes("UTF-8"));
|
||||
|
|
|
@ -44,12 +44,12 @@ public class SlowClientWithPipelinedRequestTest
|
|||
{
|
||||
private final AtomicInteger handles = new AtomicInteger();
|
||||
private Server server;
|
||||
private SelectChannelConnector connector;
|
||||
private ServerConnector connector;
|
||||
|
||||
public void startServer(Handler handler) throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector(server,new HttpConnectionFactory()
|
||||
connector = new ServerConnector(server,new HttpConnectionFactory()
|
||||
{
|
||||
@Override
|
||||
public Connection newConnection(Connector connector, EndPoint endPoint)
|
||||
|
|
|
@ -53,7 +53,7 @@ public class StressTest
|
|||
|
||||
private static QueuedThreadPool _threads;
|
||||
private static Server _server;
|
||||
private static SelectChannelConnector _connector;
|
||||
private static ServerConnector _connector;
|
||||
private static final AtomicInteger _handled=new AtomicInteger(0);
|
||||
private static final ConcurrentLinkedQueue[] _latencies= {
|
||||
new ConcurrentLinkedQueue<Long>(),
|
||||
|
@ -94,7 +94,7 @@ public class StressTest
|
|||
|
||||
_server = new Server(_threads);
|
||||
_server.manage(_threads);
|
||||
_connector = new SelectChannelConnector(_server,null,null,null,1, 1,new HttpConnectionFactory());
|
||||
_connector = new ServerConnector(_server,null,null,null,1, 1,new HttpConnectionFactory());
|
||||
_connector.setAcceptQueueSize(5000);
|
||||
_connector.setIdleTimeout(30000);
|
||||
_server.addConnector(_connector);
|
||||
|
@ -237,7 +237,7 @@ public class StressTest
|
|||
{
|
||||
System.err.println("STALLED!!!");
|
||||
System.err.println(_server.getThreadPool().toString());
|
||||
((SelectChannelConnector)(_server.getConnectors()[0])).dump();
|
||||
((ServerConnector)(_server.getConnectors()[0])).dump();
|
||||
Thread.sleep(5000);
|
||||
System.exit(1);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.eclipse.jetty.http.HttpStatus;
|
|||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -69,7 +69,7 @@ public class IPAccessHandlerTest
|
|||
throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_connector = new ServerConnector(_server);
|
||||
_server.setConnectors(new Connector[] { _connector });
|
||||
|
||||
_handler = new IPAccessHandler();
|
||||
|
|
|
@ -24,7 +24,7 @@ import junit.framework.Assert;
|
|||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.SimpleRequest;
|
||||
|
@ -40,7 +40,7 @@ import org.junit.Test;
|
|||
public class ResourceHandlerTest extends TestCase
|
||||
{
|
||||
private static Server _server;
|
||||
private static SelectChannelConnector _connector;
|
||||
private static ServerConnector _connector;
|
||||
private static ContextHandler _contextHandler;
|
||||
private static ResourceHandler _resourceHandler;
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class ResourceHandlerTest extends TestCase
|
|||
public void setUp() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_connector = new ServerConnector(_server);
|
||||
_server.setConnectors(new Connector[] { _connector });
|
||||
|
||||
_resourceHandler = new ResourceHandler();
|
||||
|
|
|
@ -39,7 +39,7 @@ import junit.framework.TestCase;
|
|||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
@ -85,7 +85,7 @@ public class SSLCloseTest extends TestCase
|
|||
sslContextFactory.setKeyManagerPassword("keypwd");
|
||||
|
||||
Server server=new Server();
|
||||
SelectChannelConnector connector=new SelectChannelConnector(server, sslContextFactory);
|
||||
ServerConnector connector=new ServerConnector(server, sslContextFactory);
|
||||
connector.setPort(0);
|
||||
|
||||
server.setConnectors(new Connector[]
|
||||
|
|
|
@ -51,7 +51,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
@ -91,7 +91,7 @@ public class SSLEngineTest
|
|||
private static final int BODY_SIZE=300;
|
||||
|
||||
private Server server;
|
||||
private SelectChannelConnector connector;
|
||||
private ServerConnector connector;
|
||||
|
||||
|
||||
@Before
|
||||
|
@ -107,7 +107,7 @@ public class SSLEngineTest
|
|||
HttpConnectionFactory http = new HttpConnectionFactory();
|
||||
http.setInputBufferSize(512);
|
||||
http.getHttpChannelConfig().setRequestHeaderSize(512);
|
||||
connector=new SelectChannelConnector(server, sslContextFactory, http);
|
||||
connector=new ServerConnector(server, sslContextFactory, http);
|
||||
connector.setPort(0);
|
||||
|
||||
server.addConnector(connector);
|
||||
|
|
|
@ -41,7 +41,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
@ -52,7 +52,7 @@ import org.junit.Test;
|
|||
public class SSLSelectChannelConnectorLoadTest
|
||||
{
|
||||
private static Server server;
|
||||
private static SelectChannelConnector connector;
|
||||
private static ServerConnector connector;
|
||||
private static SSLContext sslContext;
|
||||
|
||||
@BeforeClass
|
||||
|
@ -67,7 +67,7 @@ public class SSLSelectChannelConnectorLoadTest
|
|||
sslContextFactory.setTrustStorePassword("storepwd");
|
||||
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector(server, sslContextFactory);
|
||||
connector = new ServerConnector(server, sslContextFactory);
|
||||
server.addConnector(connector);
|
||||
|
||||
server.setHandler(new EmptyHandler());
|
||||
|
|
|
@ -33,7 +33,7 @@ import javax.net.ssl.TrustManagerFactory;
|
|||
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.server.HttpServerTestBase;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.Before;
|
||||
|
@ -105,7 +105,7 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
|
|||
sslContextFactory.setKeyManagerPassword("keypwd");
|
||||
sslContextFactory.setTrustStorePath(keystorePath);
|
||||
sslContextFactory.setTrustStorePassword("storepwd");
|
||||
SelectChannelConnector connector = new SelectChannelConnector(_server, sslContextFactory);
|
||||
ServerConnector connector = new ServerConnector(_server, sslContextFactory);
|
||||
|
||||
startServer(connector);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.io.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.SelectorManager.ManagedSelector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
@ -90,7 +90,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
sslContextFactory.setKeyStorePath(keyStore.getAbsolutePath());
|
||||
sslContextFactory.setKeyStorePassword("storepwd");
|
||||
sslContextFactory.setKeyManagerPassword("keypwd");
|
||||
SelectChannelConnector connector = new SelectChannelConnector(server, sslContextFactory)
|
||||
ServerConnector connector = new ServerConnector(server, sslContextFactory)
|
||||
{
|
||||
@Override
|
||||
protected SelectChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey key) throws IOException
|
||||
|
|
|
@ -26,7 +26,7 @@ import javax.net.ssl.SSLContext;
|
|||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
import org.eclipse.jetty.server.ConnectorTimeoutTest;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.Before;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class SslSelectChannelTimeoutTest extends ConnectorTimeoutTest
|
|||
sslContextFactory.setKeyManagerPassword("keypwd");
|
||||
sslContextFactory.setTrustStorePath(keystorePath);
|
||||
sslContextFactory.setTrustStorePassword("storepwd");
|
||||
SelectChannelConnector connector = new SelectChannelConnector(_server, sslContextFactory);
|
||||
ServerConnector connector = new ServerConnector(_server, sslContextFactory);
|
||||
connector.setIdleTimeout(MAX_IDLE_TIME); //250 msec max idle
|
||||
startServer(connector);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.SslConnectionFactory;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
|
@ -52,7 +52,7 @@ import org.junit.Test;
|
|||
public class SslUploadTest
|
||||
{
|
||||
private static Server server;
|
||||
private static SelectChannelConnector connector;
|
||||
private static ServerConnector connector;
|
||||
private static int total;
|
||||
|
||||
@BeforeClass
|
||||
|
@ -67,7 +67,7 @@ public class SslUploadTest
|
|||
sslContextFactory.setTrustStorePassword("storepwd");
|
||||
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector(server, sslContextFactory);
|
||||
connector = new ServerConnector(server, sslContextFactory);
|
||||
server.addConnector(connector);
|
||||
|
||||
server.setHandler(new EmptyHandler());
|
||||
|
|
|
@ -29,7 +29,7 @@ import javax.servlet.Servlet;
|
|||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.Attributes;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
|
@ -193,7 +193,7 @@ public class ServletTester extends AggregateLifeCycle
|
|||
*/
|
||||
public String createConnector(boolean localhost) throws Exception
|
||||
{
|
||||
SelectChannelConnector connector = new SelectChannelConnector(_server);
|
||||
ServerConnector connector = new ServerConnector(_server);
|
||||
if (localhost)
|
||||
connector.setHost("127.0.0.1");
|
||||
_server.addConnector(connector);
|
||||
|
|
|
@ -32,7 +32,7 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -61,7 +61,7 @@ public class ResponseHeadersTest
|
|||
}
|
||||
|
||||
private static Server server;
|
||||
private static SelectChannelConnector connector;
|
||||
private static ServerConnector connector;
|
||||
private static URI serverUri;
|
||||
|
||||
@BeforeClass
|
||||
|
@ -69,7 +69,7 @@ public class ResponseHeadersTest
|
|||
{
|
||||
// Configure Server
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector(server);
|
||||
connector = new ServerConnector(server);
|
||||
server.addConnector(connector);
|
||||
|
||||
ServletContextHandler context = new ServletContextHandler();
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<!-- =========================================================== -->
|
||||
<Call id="sslConnector" name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Arg name="server"><Ref id="Server" /></Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.eclipse.jetty.server.AbstractConnectionFactory;
|
|||
import org.eclipse.jetty.server.ConnectionFactory;
|
||||
import org.eclipse.jetty.server.HttpChannelConfig;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.spdy.NPNServerConnectionFactory;
|
||||
import org.eclipse.jetty.spdy.SPDYServerConnector;
|
||||
|
@ -34,7 +34,7 @@ import org.eclipse.jetty.spdy.api.SPDY;
|
|||
import org.eclipse.jetty.spdy.http.PushStrategy.None;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
public class HTTPSPDYServerConnector extends SelectChannelConnector
|
||||
public class HTTPSPDYServerConnector extends ServerConnector
|
||||
{
|
||||
public HTTPSPDYServerConnector(Server server)
|
||||
{
|
||||
|
|
|
@ -20,13 +20,13 @@ package org.eclipse.jetty.spdy;
|
|||
|
||||
import org.eclipse.jetty.server.ConnectionFactory;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.spdy.api.SPDY;
|
||||
import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
public class SPDYServerConnector extends SelectChannelConnector
|
||||
public class SPDYServerConnector extends ServerConnector
|
||||
{
|
||||
public SPDYServerConnector(Server server, ServerSessionFrameListener listener)
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
<property name="connectors">
|
||||
<list>
|
||||
<bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
|
||||
<bean id="Connector" class="org.eclipse.jetty.server.ServerConnector">
|
||||
<property name="port" value="8080"/>
|
||||
</bean>
|
||||
</list>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<!--
|
||||
<property name="connectors">
|
||||
<list>
|
||||
<bean id="Connector" class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<bean id="Connector" class="org.eclipse.jetty.server.ServerConnector">
|
||||
<constructor-arg type="org.eclipse.jetty.spring.Server"><ref bean="Server"/></constructor-arg>
|
||||
<property name="port" value="0"/>
|
||||
</bean>
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.util;
|
|||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
|
||||
public abstract class ExecutorCallback<C> implements Callback<C>
|
||||
{
|
||||
|
@ -55,7 +56,7 @@ public abstract class ExecutorCallback<C> implements Callback<C>
|
|||
public final void completed(final C context)
|
||||
{
|
||||
// Should we execute?
|
||||
if (!shouldDispatchCompletion())
|
||||
if (!alwaysDispatchCompletion())
|
||||
{
|
||||
// Do we have a recursion limit?
|
||||
if (_maxRecursion<=0)
|
||||
|
@ -129,8 +130,14 @@ public abstract class ExecutorCallback<C> implements Callback<C>
|
|||
{
|
||||
}
|
||||
|
||||
protected boolean shouldDispatchCompletion()
|
||||
protected boolean alwaysDispatchCompletion()
|
||||
{
|
||||
return _executor!=null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s@%x", getClass(), hashCode());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,17 +30,20 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
|
||||
/**
|
||||
* An AggregateLifeCycle is an {@link LifeCycle} implementation for a collection of contained beans.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Beans can be added the AggregateLifeCycle either as managed beans or as unmanaged beans. A managed bean is started, stopped and destroyed with the aggregate.
|
||||
* An unmanaged bean is associated with the aggregate for the purposes of {@link #dump()}, but it's lifecycle must be managed externally.
|
||||
* <p/>
|
||||
* When a bean is added, if it is a {@link LifeCycle} and it is already started, then it is assumed to be an unmanaged bean.
|
||||
* Otherwise the methods {@link #addBean(Object, boolean)}, {@link #manage(Object)} and {@link #unmanage(Object)} can be used to
|
||||
* <p>
|
||||
* When a {@link LifeCycle} bean is added with out a managed state being specified, if it is already started, then it is assumed to be an unmanaged bean.
|
||||
* If it is not started then it is added in and auto managed state, which means that when this bean is itself started, it if must also start the added bean, then it
|
||||
* is switched from Auto to be a managed bean. Otherwise it becomes an unmanaged bean. Simply put an Auto bean will be stopped by this aggregate only if it
|
||||
* is started by this aggregate.
|
||||
* <p>
|
||||
* The methods {@link #addBean(Object, boolean)}, {@link #manage(Object)} and {@link #unmanage(Object)} can be used to
|
||||
* explicitly control the life cycle relationship.
|
||||
* <p/>
|
||||
* <p>
|
||||
* If adding a bean that is shared between multiple {@link AggregateLifeCycle} instances, then it should be started before being added, so it is unmanaged, or
|
||||
* the API must be used to explicitly set it as unmanaged.
|
||||
* <p/>
|
||||
*/
|
||||
public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable, Dumpable
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.eclipse.jetty.websocket.server;
|
|||
import java.net.URI;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
|
@ -29,7 +29,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
|||
public class SimpleServletServer
|
||||
{
|
||||
private Server server;
|
||||
private SelectChannelConnector connector;
|
||||
private ServerConnector connector;
|
||||
private URI serverUri;
|
||||
private HttpServlet servlet;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class SimpleServletServer
|
|||
{
|
||||
// Configure Server
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector(server);
|
||||
connector = new ServerConnector(server);
|
||||
server.addConnector(connector);
|
||||
|
||||
ServletContextHandler context = new ServletContextHandler();
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
@ -155,7 +155,7 @@ public class WebSocketLoadRFC6455Test
|
|||
|
||||
private static Server _server;
|
||||
|
||||
private static SelectChannelConnector _connector;
|
||||
private static ServerConnector _connector;
|
||||
|
||||
@BeforeClass
|
||||
public static void startServer() throws Exception
|
||||
|
@ -165,7 +165,7 @@ public class WebSocketLoadRFC6455Test
|
|||
_server = new Server(threadPool);
|
||||
_server.manage(threadPool);
|
||||
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_connector = new ServerConnector(_server);
|
||||
_server.addConnector(_connector);
|
||||
|
||||
WebSocketHandler wsHandler = new WebSocketHandler.Simple(MyEchoSocket.class);
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Arrays;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
|
@ -102,7 +102,7 @@ public class WebSocketOverSSLTest
|
|||
sslContextFactory.setKeyStorePassword("storepwd");
|
||||
sslContextFactory.setKeyManagerPassword("keypwd");
|
||||
_server = new Server();
|
||||
SelectChannelConnector connector = new SelectChannelConnector(_server, sslContextFactory);
|
||||
ServerConnector connector = new ServerConnector(_server, sslContextFactory);
|
||||
_server.addConnector(connector);
|
||||
_server.setHandler(new WebSocketHandler.Simple(websocket.getClass()));
|
||||
_server.start();
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.server.examples.echo;
|
||||
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -84,7 +84,7 @@ public class ExampleEchoServer
|
|||
|
||||
private Server server;
|
||||
|
||||
private SelectChannelConnector connector;
|
||||
private ServerConnector connector;
|
||||
private boolean _verbose;
|
||||
private WebSocketHandler wsHandler;
|
||||
private ResourceHandler rHandler;
|
||||
|
@ -92,7 +92,7 @@ public class ExampleEchoServer
|
|||
public ExampleEchoServer(int port)
|
||||
{
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector(server);
|
||||
connector = new ServerConnector(server);
|
||||
connector.setPort(port);
|
||||
|
||||
server.addConnector(connector);
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.io.InputStream;
|
|||
|
||||
import org.eclipse.jetty.continuation.test.ContinuationBase;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
|
@ -40,13 +40,13 @@ public class ContinuationTest extends ContinuationBase
|
|||
{
|
||||
protected Server _server = new Server();
|
||||
protected ServletHandler _servletHandler;
|
||||
protected SelectChannelConnector _connector;
|
||||
protected ServerConnector _connector;
|
||||
FilterHolder _filter;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_connector = new ServerConnector(_server);
|
||||
_server.setConnectors(new Connector[]{ _connector });
|
||||
ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.NO_SECURITY|ServletContextHandler.NO_SESSIONS);
|
||||
_server.setHandler(servletContext);
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.io.InputStream;
|
|||
|
||||
import org.eclipse.jetty.continuation.test.ContinuationBase;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
|
@ -36,12 +36,12 @@ public class FauxContinuationTest extends ContinuationBase
|
|||
{
|
||||
protected Server _server = new Server();
|
||||
protected ServletHandler _servletHandler;
|
||||
protected SelectChannelConnector _connector;
|
||||
protected ServerConnector _connector;
|
||||
FilterHolder _filter;
|
||||
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_connector = new ServerConnector(_server);
|
||||
_server.setConnectors(new Connector[]{ _connector });
|
||||
ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.NO_SECURITY|ServletContextHandler.NO_SESSIONS);
|
||||
_server.setHandler(servletContext);
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.eclipse.jetty.server.Handler;
|
|||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.NCSARequestLog;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.SslConnectionFactory;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
|
@ -77,21 +77,21 @@ public class TestServer
|
|||
mbContainer.addBean(Log.getLog());
|
||||
|
||||
// Setup Connectors
|
||||
SelectChannelConnector connector0 = new SelectChannelConnector(server);
|
||||
ServerConnector connector0 = new ServerConnector(server);
|
||||
connector0.setPort(8080);
|
||||
connector0.setIdleTimeout(30000);
|
||||
connector0.getConnectionFactory(HttpConnectionFactory.class).getHttpChannelConfig().setSecurePort(8443);
|
||||
server.addConnector(connector0);
|
||||
|
||||
// Setup Connectors
|
||||
SelectChannelConnector connector1 = new SelectChannelConnector(server);
|
||||
ServerConnector connector1 = new ServerConnector(server);
|
||||
connector1.setPort(8081);
|
||||
connector1.setIdleTimeout(30000);
|
||||
connector1.getConnectionFactory(HttpConnectionFactory.class).getHttpChannelConfig().setSecurePort(8443);
|
||||
server.addConnector(connector1);
|
||||
|
||||
|
||||
SelectChannelConnector ssl_connector = new SelectChannelConnector(server,new SslContextFactory());
|
||||
ServerConnector ssl_connector = new ServerConnector(server,new SslContextFactory());
|
||||
ssl_connector.setPort(8443);
|
||||
SslContextFactory cf = ssl_connector.getConnectionFactory(SslConnectionFactory.class).getSslContextFactory();
|
||||
cf.setKeyStorePath(jetty_root + "/jetty-server/src/main/config/etc/keystore");
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Set name="host"><SystemProperty name="jetty.host" /></Set>
|
||||
<Set name="port"><SystemProperty name="jetty.port" default="0"/></Set>
|
||||
<Set name="idleTimeout">300000</Set>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Set name="host"><SystemProperty name="jetty.host" /></Set>
|
||||
<Set name="port"><SystemProperty name="jetty.port" default="0"/></Set>
|
||||
<Set name="idleTimeout">300000</Set>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Set name="host"><SystemProperty name="jetty.host" /></Set>
|
||||
<Set name="port"><SystemProperty name="jetty.port" default="0"/></Set>
|
||||
<Set name="idleTimeout">300000</Set>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<!--
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SelectChannelConnector">
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Set name="host"><SystemProperty name="jetty.host" /></Set>
|
||||
<Set name="port"><SystemProperty name="jetty.port" default="0"/></Set>
|
||||
<Set name="idleTimeout">300000</Set>
|
||||
|
|
Loading…
Reference in New Issue