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.http;
21  
22  import java.util.Collections;
23  import java.util.Map;
24  
25  import org.eclipse.jetty.spdy.api.SPDY;
26  import org.eclipse.jetty.util.ssl.SslContextFactory;
27  
28  public class HTTPSPDYServerConnector extends AbstractHTTPSPDYServerConnector
29  {
30      public HTTPSPDYServerConnector()
31      {
32          this(null, Collections.<Short, PushStrategy>emptyMap());
33      }
34  
35      public HTTPSPDYServerConnector(Map<Short, PushStrategy> pushStrategies)
36      {
37          this(null, pushStrategies);
38      }
39  
40      public HTTPSPDYServerConnector(SslContextFactory sslContextFactory)
41      {
42          this(sslContextFactory, Collections.<Short, PushStrategy>emptyMap());
43      }
44  
45      public HTTPSPDYServerConnector(SslContextFactory sslContextFactory, Map<Short, PushStrategy> pushStrategies)
46      {
47          // We pass a null ServerSessionFrameListener because for
48          // HTTP over SPDY we need one that references the endPoint
49          super(null, sslContextFactory);
50          clearAsyncConnectionFactories();
51          // The "spdy/3" protocol handles HTTP over SPDY
52          putAsyncConnectionFactory("spdy/3", new ServerHTTPSPDYAsyncConnectionFactory(SPDY.V3, getByteBufferPool(), getExecutor(), getScheduler(), this, getPushStrategy(SPDY.V3,pushStrategies)));
53          // The "spdy/2" protocol handles HTTP over SPDY
54          putAsyncConnectionFactory("spdy/2", new ServerHTTPSPDYAsyncConnectionFactory(SPDY.V2, getByteBufferPool(), getExecutor(), getScheduler(), this, getPushStrategy(SPDY.V2,pushStrategies)));
55          // The "http/1.1" protocol handles browsers that support NPN but not SPDY
56          putAsyncConnectionFactory("http/1.1", new ServerHTTPAsyncConnectionFactory(this));
57          // The default connection factory handles plain HTTP on non-SSL or non-NPN connections
58          setDefaultAsyncConnectionFactory(getAsyncConnectionFactory("http/1.1"));
59      }
60  
61      private PushStrategy getPushStrategy(short version, Map<Short, PushStrategy> pushStrategies)
62      {
63          PushStrategy pushStrategy = pushStrategies.get(version);
64          if(pushStrategy == null)
65              pushStrategy = new PushStrategy.None();
66          return pushStrategy;
67      }
68  
69  }