| 10 | public class Main { |
| 11 | |
| 12 | public static void main(String[] args) { |
| 13 | Map<String, Class> map = new HashMap<>(); |
| 14 | map.put("1", HttpServer01.class); |
| 15 | map.put("2", HttpServer02.class); |
| 16 | map.put("3", HttpServer03.class); |
| 17 | map.put("8", NettyHttpServer.class); |
| 18 | |
| 19 | String id = (null == args || args.length == 0) ? "1" : args[0]; |
| 20 | Class clazz = map.get(id); |
| 21 | if( null == clazz ) { |
| 22 | System.out.println("No class for id: " + id); |
| 23 | } |
| 24 | |
| 25 | try { |
| 26 | Method method = clazz.getDeclaredMethod("main", new Class[]{String[].class}); |
| 27 | method.invoke(null, new Object[]{new String[]{}}); |
| 28 | } catch (Exception e) { |
| 29 | e.printStackTrace(); |
| 30 | } |
| 31 | |
| 32 | } |
| 33 | |
| 34 | } |