View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2014 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 java.util.Objects;
23  
24  import org.eclipse.jetty.server.HttpConfiguration;
25  import org.eclipse.jetty.server.NegotiatingServerConnectionFactory;
26  import org.eclipse.jetty.server.Server;
27  import org.eclipse.jetty.server.ServerConnector;
28  import org.eclipse.jetty.spdy.api.SPDY;
29  import org.eclipse.jetty.spdy.server.NPNServerConnectionFactory;
30  import org.eclipse.jetty.spdy.server.SPDYServerConnectionFactory;
31  import org.eclipse.jetty.util.ssl.SslContextFactory;
32  
33  public class HTTPSPDYProxyServerConnector extends ServerConnector
34  {
35      public HTTPSPDYProxyServerConnector(Server server, ProxyEngineSelector proxyEngineSelector)
36      {
37          this(server, new HttpConfiguration(), proxyEngineSelector);
38      }
39  
40      public HTTPSPDYProxyServerConnector(Server server, HttpConfiguration config, ProxyEngineSelector proxyEngineSelector)
41      {
42          super(server, (SslContextFactory)null, new ProxyHTTPConnectionFactory(config, SPDY.V2, proxyEngineSelector));
43      }
44  
45      public HTTPSPDYProxyServerConnector(Server server, SslContextFactory sslContextFactory, ProxyEngineSelector proxyEngineSelector)
46      {
47          this(server, sslContextFactory, new HttpConfiguration(), proxyEngineSelector);
48      }
49  
50      public HTTPSPDYProxyServerConnector(Server server, SslContextFactory sslContextFactory, HttpConfiguration config, ProxyEngineSelector proxyEngineSelector)
51      {
52          this(server, sslContextFactory, config, proxyEngineSelector, new NPNServerConnectionFactory("spdy/3", "spdy/2", "http/1.1"));
53      }
54  
55      public HTTPSPDYProxyServerConnector(Server server, SslContextFactory sslContextFactory, HttpConfiguration config, ProxyEngineSelector proxyEngineSelector, NegotiatingServerConnectionFactory negotiatingFactory)
56      {
57          super(server, Objects.requireNonNull(sslContextFactory), negotiatingFactory,
58                  new SPDYServerConnectionFactory(SPDY.V3, proxyEngineSelector),
59                  new SPDYServerConnectionFactory(SPDY.V2, proxyEngineSelector),
60                  new ProxyHTTPConnectionFactory(config, SPDY.V2, proxyEngineSelector));
61          negotiatingFactory.setDefaultProtocol("http/1.1");
62      }
63  }