refined jetty embedded examples

This commit is contained in:
Greg Wilkins 2013-02-22 16:19:06 +11:00
parent c302a404cd
commit 999db7f4d8
3 changed files with 13 additions and 10 deletions

View File

@ -18,14 +18,8 @@
package org.eclipse.jetty.embedded;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.util.ssl.SslContextFactory;
/* ------------------------------------------------------------ */
/**
@ -44,8 +38,8 @@ public class OneConnector
http.setPort(8080);
http.setIdleTimeout(30000);
// Set the connectors
server.setConnectors(new Connector[] { http });
// Set the connector
server.addConnector(http);
// Set a handler
server.setHandler(new HelloHandler());

View File

@ -73,14 +73,16 @@ public class SpdyConnector
// NPN Factory
SPDYServerConnectionFactory.checkNPNAvailable();
NPNServerConnectionFactory npn = new NPNServerConnectionFactory(spdy3.getProtocol(),spdy2.getProtocol(),http.getDefaultProtocol());
NPNServerConnectionFactory npn =
new NPNServerConnectionFactory(spdy3.getProtocol(),spdy2.getProtocol(),http.getDefaultProtocol());
npn.setDefaultProtocol(http.getDefaultProtocol());
// SSL Factory
SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory,npn.getProtocol());
// SPDY Connector
ServerConnector spdyConnector = new ServerConnector(server,ssl,npn,spdy3,spdy2,http.getDefaultConnectionFactory());
ServerConnector spdyConnector =
new ServerConnector(server,ssl,npn,spdy3,spdy2,new HttpConnectionFactory(https_config));
spdyConnector.setPort(8443);
server.addConnector(spdyConnector);

View File

@ -25,6 +25,13 @@ import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.annotation.Name;
/* ------------------------------------------------------------ */
/** A Connection Factory for HTTP Connections.
* <p>Accepts connections either directly or via SSL and/or NPN chained connection factories. The accepted
* {@link HttpConnection}s are configured by a {@link HttpConfiguration} instance that is either created by
* default or passed in to the constructor.
*/
public class HttpConnectionFactory extends AbstractConnectionFactory implements HttpConfiguration.ConnectionFactory
{
private final HttpConfiguration _config;