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  package org.eclipse.jetty.spdy.server;
20  
21  import org.eclipse.jetty.server.ConnectionFactory;
22  import org.eclipse.jetty.server.HttpConnectionFactory;
23  import org.eclipse.jetty.server.Server;
24  import org.eclipse.jetty.server.ServerConnector;
25  import org.eclipse.jetty.spdy.api.SPDY;
26  import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
27  import org.eclipse.jetty.util.ssl.SslContextFactory;
28  
29  public class SPDYServerConnector extends ServerConnector
30  {
31      public SPDYServerConnector(Server server, ServerSessionFrameListener listener)
32      {
33          this(server, null, listener);
34      }
35  
36      public SPDYServerConnector(Server server, SslContextFactory sslContextFactory, ServerSessionFrameListener listener)
37      {
38          super(server,
39              sslContextFactory,
40              sslContextFactory==null
41              ?new ConnectionFactory[]{new SPDYServerConnectionFactory(SPDY.V2, listener)}
42              :new ConnectionFactory[]{
43                  new NPNServerConnectionFactory("spdy/3","spdy/2","http/1.1"),
44                  new HttpConnectionFactory(),
45                  new SPDYServerConnectionFactory(SPDY.V2, listener),
46                  new SPDYServerConnectionFactory(SPDY.V3, listener)});
47          if (getConnectionFactory(NPNServerConnectionFactory.class)!=null)
48              getConnectionFactory(NPNServerConnectionFactory.class).setDefaultProtocol("http/1.1");
49  
50      }
51  
52  }