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.netty5.example.http2.tiles;
18
19 import io.netty5.channel.EventLoopGroup;
20 import io.netty5.channel.MultithreadEventLoopGroup;
21 import io.netty5.channel.nio.NioHandler;
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 * The associated ALPN library for your JDK version can be found here:
34 * https://eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions.
35 * Alternatively, you can use the OpenSsl provider. Please make sure that you run OpenSsl
36 * version 1.0.2 or greater.
37 * </p>
38 */
39 public final class Launcher {
40
41 public static void main(String[] args) {
42 EventLoopGroup group = new MultithreadEventLoopGroup(NioHandler.newFactory());
43 Http2Server http2 = new Http2Server(group);
44 HttpServer http = new HttpServer(group);
45 try {
46 http2.start();
47 System.err.println("Open your web browser and navigate to " + "http://" + Html.IP + ":" + HttpServer.PORT);
48 http.start().asStage().sync();
49 } catch (Exception e) {
50 e.printStackTrace();
51 } finally {
52 group.shutdownGracefully();
53 }
54 }
55 }