home *** CD-ROM | disk | FTP | other *** search
/ Datatid 1999 #6 / Datatid_1999-06.iso / internet / Tango352Promo / Tango / data.z / JASMain.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-02-03  |  3.4 KB  |  123 lines

  1. package com.everyware.tango.jas;
  2.  
  3. public class JASMain {
  4.    private JAS jas = new JAS();
  5.  
  6.    public static void main(String[] var0) {
  7.       new JASMain(var0);
  8.    }
  9.  
  10.    public JASMain(String[] var1) {
  11.       try {
  12.          this.parseArgs(var1);
  13.       } catch (Exception var3) {
  14.          System.err.println("Exception: " + var3);
  15.          this.usage();
  16.          System.exit(1);
  17.       }
  18.  
  19.       this.jas.run();
  20.    }
  21.  
  22.    private void usage() {
  23.       System.err.println("Usage: JASMain [-trace|notrace] [-port P] [-hostname H] [-serversockettimeout S] [-maxnumthreads T] [-maxnumbacklog B] [-clientsockettimeout C] [-actiontimeout A] [-help]");
  24.    }
  25.  
  26.    private void parseArgs(String[] var1) throws Exception {
  27.       for(int var2 = 0; var2 < var1.length; ++var2) {
  28.          if (var1[var2].equals("-port")) {
  29.             if (var2 + 1 >= var1.length) {
  30.                throw new Exception("The port number was not specified");
  31.             }
  32.  
  33.             ++var2;
  34.  
  35.             try {
  36.                this.jas.setPort(Integer.parseInt(var1[var2]));
  37.             } catch (NumberFormatException var8) {
  38.                throw new Exception("An invalid port number was specified");
  39.             }
  40.          } else if (var1[var2].equals("-hostname")) {
  41.             if (var2 + 1 >= var1.length) {
  42.                throw new Exception("The hostname was not specified");
  43.             }
  44.  
  45.             ++var2;
  46.             this.jas.setHostName(var1[var2]);
  47.          } else if (var1[var2].equals("-actiontimeout")) {
  48.             if (var2 + 1 >= var1.length) {
  49.                throw new Exception("The actiontimeout duration was not specified");
  50.             }
  51.  
  52.             ++var2;
  53.  
  54.             try {
  55.                this.jas.setActionTimeout(Integer.parseInt(var1[var2]));
  56.             } catch (NumberFormatException var7) {
  57.                throw new Exception("An invalid actiontimeout was specified");
  58.             }
  59.          } else if (var1[var2].equals("-serversockettimeout")) {
  60.             if (var2 + 1 >= var1.length) {
  61.                throw new Exception("The serversockettimeout duration was not specified");
  62.             }
  63.  
  64.             ++var2;
  65.  
  66.             try {
  67.                this.jas.setServerSocketTimeout(Integer.parseInt(var1[var2]));
  68.             } catch (NumberFormatException var6) {
  69.                throw new Exception("An invalid serversockettimeout was specified");
  70.             }
  71.          } else if (var1[var2].equals("-clientsockettimeout")) {
  72.             if (var2 + 1 >= var1.length) {
  73.                throw new Exception("The clientsockettimeout duration was not specified");
  74.             }
  75.  
  76.             ++var2;
  77.  
  78.             try {
  79.                this.jas.setClientSocketTimeout(Integer.parseInt(var1[var2]));
  80.             } catch (NumberFormatException var5) {
  81.                throw new Exception("An invalid clientsockettimeout was specified");
  82.             }
  83.          } else if (var1[var2].equals("-maxnumthreads")) {
  84.             if (var2 + 1 >= var1.length) {
  85.                throw new Exception("The maxnumthreads number was not specified");
  86.             }
  87.  
  88.             ++var2;
  89.  
  90.             try {
  91.                this.jas.setMaxNumThreads(Integer.parseInt(var1[var2]));
  92.             } catch (NumberFormatException var4) {
  93.                throw new Exception("An invalid maxnumthread number was specified");
  94.             }
  95.          } else if (var1[var2].equals("-maxnumbacklog")) {
  96.             if (var2 + 1 >= var1.length) {
  97.                throw new Exception("The maxnumbacklog number was not specified");
  98.             }
  99.  
  100.             ++var2;
  101.  
  102.             try {
  103.                this.jas.setMaxNumBacklog(Integer.parseInt(var1[var2]));
  104.             } catch (NumberFormatException var3) {
  105.                throw new Exception("An invalid maxnumbacklog number was specified");
  106.             }
  107.          } else if (var1[var2].equals("-trace")) {
  108.             this.jas.setTracing(true);
  109.          } else if (var1[var2].equals("-notrace")) {
  110.             this.jas.setTracing(false);
  111.          } else {
  112.             if (!var1[var2].equals("-help")) {
  113.                throw new Exception("Unknown argument: " + var1[var2]);
  114.             }
  115.  
  116.             this.usage();
  117.             System.exit(0);
  118.          }
  119.       }
  120.  
  121.    }
  122. }
  123.