Example #1
0
  private static void bootstrap() {
    try {
      MessageParameterContext.getInstance().init();
      ConfigContext.getInstance().init();
      readConfig();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }

    int serverId = ConfigContainer.getInstance().getConfig().getServerId();
    String serverIp = ConfigContainer.getInstance().getConfig().getServerIp();
    int paltformId = ConfigContainer.getInstance().getConfig().getPlatformId();
    String account = ConfigContainer.getInstance().getConfig().getAccount();
    String password = ConfigContainer.getInstance().getConfig().getPassword();
    Client client = new Client(serverId, serverIp, paltformId, account, password);
    client.start();

    // String serverIp = "119.29.25.197";
    // Client client = new Client(serverIp, 100, "safziy", "safziymy");
    // Client client = new Client(serverIp, 100, "62683011", "woshiziyi");
    // client.start();

  }
Example #2
0
 private static void readConfig() throws Exception {
   String classBinPath = Launcher.class.getResource("/").getPath();
   File file = new File(classBinPath + "config.xml");
   Serializer ser = new Persister();
   InputStream in = null;
   try {
     in = new FileInputStream(file);
     InputNode inputNode = NodeBuilder.read(in);
     Configs configs = ser.read(Configs.class, inputNode, false);
     ConfigContainer.getInstance().setConfigs(configs);
   } finally {
     if (in != null) {
       try {
         in.close();
       } catch (Exception e) {
         LogUtil.error("close FileInputStream fail", e);
       }
     }
   }
 }