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.MultiThreadIoEventLoopGroup;
21 import io.netty.channel.nio.NioIoHandler;
22
23 /**
24 * <p>
25 * Launches both Http and Http2 servers using Netty to display a set of images
26 * and simulate latency. It is a Netty version of the <a
27 * href="https://http2.golang.org/gophertiles?latency=0"> Go lang HTTP2 tiles
28 * demo</a>.
29 * </p>
30 * <p>
31 * Please note that if you intent to use the JDK provider for SSL, you MUST use JDK 1.8.
32 * Previous JDK versions don't have any cipher suite that is suitable for use with HTTP/2.
33 * Alternatively, you can use the OpenSsl provider. Please make sure that you run OpenSsl
34 * version 1.0.2 or greater.
35 * </p>
36 */
37 public final class Launcher {
38
39 public static void main(String[] args) {
40 EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
41 Http2Server http2 = new Http2Server(group);
42 HttpServer http = new HttpServer(group);
43 try {
44 http2.start();
45 System.err.println("Open your web browser and navigate to " + "http://" + Html.IP + ":" + HttpServer.PORT);
46 http.start().sync();
47 } catch (Exception e) {
48 e.printStackTrace();
49 } finally {
50 group.shutdownGracefully();
51 }
52 }
53 }