View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 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.server;
20  
21  import org.eclipse.jetty.http.HttpVersion;
22  import org.eclipse.jetty.io.Connection;
23  import org.eclipse.jetty.io.EndPoint;
24  import org.eclipse.jetty.util.annotation.Name;
25  
26  /** A Connection Factory for HTTP Connections.
27   * <p>Accepts connections either directly or via SSL and/or ALPN chained connection factories.  The accepted
28   * {@link HttpConnection}s are configured by a {@link HttpConfiguration} instance that is either created by
29   * default or passed in to the constructor.
30   */
31  public class HttpConnectionFactory extends AbstractConnectionFactory implements HttpConfiguration.ConnectionFactory
32  {
33      private final HttpConfiguration _config;
34  
35      public HttpConnectionFactory()
36      {
37          this(new HttpConfiguration());
38      }
39  
40      public HttpConnectionFactory(@Name("config") HttpConfiguration config)
41      {
42          super(HttpVersion.HTTP_1_1.asString());
43          _config=config;
44          if (config==null)
45              throw new IllegalArgumentException("Null HttpConfiguration");
46          addBean(_config);
47      }
48  
49      @Override
50      public HttpConfiguration getHttpConfiguration()
51      {
52          return _config;
53      }
54  
55      @Override
56      public Connection newConnection(Connector connector, EndPoint endPoint)
57      {
58          return configure(new HttpConnection(_config, connector, endPoint), connector, endPoint);
59      }
60  }