aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2013-09-18 10:52:12 (EDT)
committerThomas Becker2013-09-19 05:33:01 (EDT)
commit1394559e00a05d65404e40c9ec2baafc7af17698 (patch)
tree736eb3b2a5b26a5169c039e3befea7199a6b065e
parentd4c035a06f114d68d3be3dded37c4b41a507f375 (diff)
downloadorg.eclipse.jetty.project-1394559e00a05d65404e40c9ec2baafc7af17698.zip
org.eclipse.jetty.project-1394559e00a05d65404e40c9ec2baafc7af17698.tar.gz
org.eclipse.jetty.project-1394559e00a05d65404e40c9ec2baafc7af17698.tar.bz2
416453 Add comments to embedded SpdyServer example
-rw-r--r--examples/embedded/src/main/java/org/eclipse/jetty/embedded/SpdyServer.java28
1 files changed, 23 insertions, 5 deletions
diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/SpdyServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/SpdyServer.java
index 302f434..0c5b69e 100644
--- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/SpdyServer.java
+++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/SpdyServer.java
@@ -57,6 +57,7 @@ public class SpdyServer
// Setup Threadpool
QueuedThreadPool threadPool = new QueuedThreadPool(512);
+ // Setup Jetty Server instance
Server server = new Server(threadPool);
server.manage(threadPool);
server.setDumpAfterStart(false);
@@ -73,9 +74,13 @@ public class SpdyServer
config.addCustomizer(new ForwardedRequestCustomizer());
config.addCustomizer(new SecureRequestCustomizer());
config.setSendServerVersion(true);
-
-
- // Http Connector
+
+
+ // Http Connector Setup
+
+ // A plain HTTP connector listening on port 8080. Note that it's also possible to have port 8080 configured as
+ // a non SSL SPDY connector. But the specification and most browsers do not allow to use SPDY without SSL
+ // encryption. However some browsers allow it to be configured.
HttpConnectionFactory http = new HttpConnectionFactory(config);
ServerConnector httpConnector = new ServerConnector(server,http);
httpConnector.setPort(8080);
@@ -83,6 +88,9 @@ public class SpdyServer
server.addConnector(httpConnector);
// SSL configurations
+
+ // We need a SSLContextFactory for the SSL encryption. That SSLContextFactory will be used by the SPDY
+ // connector.
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(jetty_home + "/etc/keystore");
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
@@ -100,13 +108,20 @@ public class SpdyServer
// Spdy Connector
+
+ // Make sure that the required NPN implementations are available.
SPDYServerConnectionFactory.checkNPNAvailable();
+ // A ReferrerPushStrategy is being initialized.
+ // See: http://www.eclipse.org/jetty/documentation/current/spdy-configuring-push.html for more details.
PushStrategy push = new ReferrerPushStrategy();
HTTPSPDYServerConnectionFactory spdy2 = new HTTPSPDYServerConnectionFactory(2,config,push);
spdy2.setInputBufferSize(8192);
spdy2.setInitialWindowSize(32768);
+ // We need a connection factory per protocol that our server is supposed to support on the NPN port. We then
+ // create a ServerConnector and pass in the supported factories. NPN will then be used to negotiate the
+ // protocol with the client.
HTTPSPDYServerConnectionFactory spdy3 = new HTTPSPDYServerConnectionFactory(3,config,push);
spdy2.setInputBufferSize(8192);
@@ -115,12 +130,15 @@ public class SpdyServer
npn.setInputBufferSize(1024);
SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory,npn.getProtocol());
-
+
+ // Setup the npn connector on port 8443
ServerConnector spdyConnector = new ServerConnector(server,ssl,npn,spdy3,spdy2,http);
spdyConnector.setPort(8443);
server.addConnector(spdyConnector);
-
+
+ // The following section adds some handlers, deployers and webapp providers.
+ // See: http://www.eclipse.org/jetty/documentation/current/advanced-embedding.html for details.
// Setup handlers
HandlerCollection handlers = new HandlerCollection();