View Javadoc
1   /*
2    * Copyright 2015 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  
17  package io.netty.example.http2.tiles;
18  
19  import io.netty.channel.EventLoopGroup;
20  import io.netty.channel.nio.NioEventLoopGroup;
21  
22  /**
23   * <p>
24   * Launches both Http and Http2 servers using Netty to display a set of images
25   * and simulate latency. It is a Netty version of the <a
26   * href="https://http2.golang.org/gophertiles?latency=0"> Go lang HTTP2 tiles
27   * demo</a>.
28   * </p>
29   * <p>
30   * Please note that if you intent to use the JDK provider for SSL, you MUST use JDK 1.8.
31   * Previous JDK versions don't have any cipher suite that is suitable for use with HTTP/2.
32   * The associated ALPN library for your JDK version can be found here:
33   * https://eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions.
34   * Alternatively, you can use the OpenSsl provider. Please make sure that you run OpenSsl
35   * version 1.0.2 or greater.
36   * </p>
37   */
38  public final class Launcher {
39  
40      public static void main(String[] args) {
41          EventLoopGroup group = new NioEventLoopGroup();
42          Http2Server http2 = new Http2Server(group);
43          HttpServer http = new HttpServer(group);
44          try {
45              http2.start();
46              System.err.println("Open your web browser and navigate to " + "http://" + Html.IP + ":" + HttpServer.PORT);
47              http.start().sync();
48          } catch (Exception e) {
49              e.printStackTrace();
50          } finally {
51              group.shutdownGracefully();
52          }
53      }
54  }