-
Notifications
You must be signed in to change notification settings - Fork 837
Expand file tree
/
Copy pathMain.java
More file actions
34 lines (27 loc) · 970 Bytes
/
Main.java
File metadata and controls
34 lines (27 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java0.nio01.HttpServer01;
import java0.nio01.HttpServer02;
import java0.nio01.HttpServer03;
import java0.nio01.netty.NettyHttpServer;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
Map<String, Class> map = new HashMap<>();
map.put("1", HttpServer01.class);
map.put("2", HttpServer02.class);
map.put("3", HttpServer03.class);
map.put("8", NettyHttpServer.class);
String id = (null == args || args.length == 0) ? "1" : args[0];
Class clazz = map.get(id);
if( null == clazz ) {
System.out.println("No class for id: " + id);
}
try {
Method method = clazz.getDeclaredMethod("main", new Class[]{String[].class});
method.invoke(null, new Object[]{new String[]{}});
} catch (Exception e) {
e.printStackTrace();
}
}
}