View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  
20  package org.eclipse.jetty.spdy.server.proxy;
21  
22  import org.eclipse.jetty.server.ConnectionFactory;
23  import org.eclipse.jetty.server.HttpConfiguration;
24  import org.eclipse.jetty.server.Server;
25  import org.eclipse.jetty.server.ServerConnector;
26  import org.eclipse.jetty.spdy.api.SPDY;
27  import org.eclipse.jetty.spdy.server.NPNServerConnectionFactory;
28  import org.eclipse.jetty.spdy.server.SPDYServerConnectionFactory;
29  import org.eclipse.jetty.util.ssl.SslContextFactory;
30  
31  public class HTTPSPDYProxyServerConnector extends ServerConnector
32  {
33      public HTTPSPDYProxyServerConnector(Server server, ProxyEngineSelector proxyEngineSelector)
34      {
35          this(server, new HttpConfiguration(), proxyEngineSelector);
36      }
37  
38      public HTTPSPDYProxyServerConnector(Server server, HttpConfiguration config, ProxyEngineSelector proxyEngineSelector)
39      {
40          this(server, null, config, proxyEngineSelector);
41      }
42  
43      public HTTPSPDYProxyServerConnector(Server server, SslContextFactory sslContextFactory, ProxyEngineSelector proxyEngineSelector)
44      {
45          this(server, sslContextFactory, new HttpConfiguration(), proxyEngineSelector);
46      }
47  
48      public HTTPSPDYProxyServerConnector(Server server, SslContextFactory sslContextFactory, HttpConfiguration config, ProxyEngineSelector proxyEngineSelector)
49      {
50          super(server,
51                  sslContextFactory,
52                  sslContextFactory == null
53                          ? new ConnectionFactory[]{new ProxyHTTPConnectionFactory(config, SPDY.V2, proxyEngineSelector)}
54                          : new ConnectionFactory[]{new NPNServerConnectionFactory("spdy/3", "spdy/2", "http/1.1"),
55                          new SPDYServerConnectionFactory(SPDY.V3, proxyEngineSelector),
56                          new SPDYServerConnectionFactory(SPDY.V2, proxyEngineSelector),
57                          new ProxyHTTPConnectionFactory(config, SPDY.V2, proxyEngineSelector)});
58          NPNServerConnectionFactory npnConnectionFactory = getConnectionFactory(NPNServerConnectionFactory.class);
59          if (npnConnectionFactory != null)
60              npnConnectionFactory.setDefaultProtocol("http/1.1");
61      }
62  }