Package bootstrap.tankwar

Source Code of bootstrap.tankwar.Main

package bootstrap.tankwar;

import java.io.File;

import org.jgroups.demo.tankwar.TankWar;


import bootstrap.Bootstrap;

public class Main extends Bootstrap{

  public static void main(String[] args) {
   
    String name = null;
    boolean isGood = false ;
    String props = null;
   
    for(int i=0; i < args.length; i++) {

      if (args[i].equals("-n")) {
        name = args[++i];
        continue;
      }
     
      if (args[i].equals("-p") || args[i].equals("-props")) {
        props = args[++i];
        continue;
      }
     
      if (args[i].equals("isGood")) {
        isGood = true ;
        continue;
      }

      help();
    }
   
    if(null == name) {
      System.out.println("You need prompt a unique name");
      help();
    }
   
    String jgroupsProps = null ;
    if(null == props) {
      jgroupsProps = System.getProperty("demo.conf.dir") + File.separator + "tankwar-udp.xml" ;
    } else {
      jgroupsProps = System.getProperty("demo.conf.dir") + File.separator + props ;
    }
   
    new TankWar(jgroupsProps, name, isGood).doStart();
  }

  private static void help() {
    System.out.println("Run Application with [-n <name>] [-p <config>] [isGood]");
    System.out.println("On Linux:");
    System.out.println("    ./tankwar.sh -n <node name>  -p <config> isGood");
    System.out.println("On Windows:");
    System.out.println("    tankwar.bat -n <node name> -p <config> isGood");
    Runtime.getRuntime().exit(0);
  }

}
TOP

Related Classes of bootstrap.tankwar.Main

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.