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

  1. package com.everyware.tango.jas;
  2.  
  3. import java.io.FileInputStream;
  4. import java.util.Properties;
  5.  
  6. public class JAS implements Runnable {
  7.    public boolean isTracing = false;
  8.    private int port = 4000;
  9.    private String hostName;
  10.    private int maxNumBacklog = 50;
  11.    private int serverSocketTimeout = 30;
  12.    private int maxNumThreads = 5;
  13.    private int clientSocketTimeout = 30;
  14.    private int actionTimeout = 30;
  15.    private transient Timer timer;
  16.    public transient TraceManager traceM;
  17.    private transient ThreadManager threadM;
  18.    private transient ConnectionManager connectionM;
  19.  
  20.    public JAS() {
  21.       Properties var1 = new Properties();
  22.  
  23.       try {
  24.          var1.load(new FileInputStream("JAS.properties"));
  25.          String var2;
  26.          if ((var2 = var1.getProperty("isTracing")) != null) {
  27.             switch (Integer.parseInt(var2)) {
  28.                case 0:
  29.                   this.setTracing(false);
  30.                   break;
  31.                case 1:
  32.                   this.setTracing(true);
  33.                   break;
  34.                default:
  35.                   System.err.println("Invalid properties setting for isTracing: " + var2);
  36.             }
  37.          }
  38.  
  39.          if ((var2 = var1.getProperty("port")) != null) {
  40.             this.setPort(Integer.parseInt(var2));
  41.          }
  42.  
  43.          if ((var2 = var1.getProperty("hostName")) != null) {
  44.             this.setHostName(var2);
  45.          }
  46.  
  47.          if ((var2 = var1.getProperty("maxNumBacklog")) != null) {
  48.             this.setMaxNumBacklog(Integer.parseInt(var2));
  49.          }
  50.  
  51.          if ((var2 = var1.getProperty("serverSocketTimeout")) != null) {
  52.             this.setServerSocketTimeout(Integer.parseInt(var2));
  53.          }
  54.  
  55.          if ((var2 = var1.getProperty("maxNumThreads")) != null) {
  56.             this.setMaxNumThreads(Integer.parseInt(var2));
  57.          }
  58.  
  59.          if ((var2 = var1.getProperty("clientSocketTimeout")) != null) {
  60.             this.setClientSocketTimeout(Integer.parseInt(var2));
  61.          }
  62.  
  63.          if ((var2 = var1.getProperty("actionTimeout")) != null) {
  64.             this.setActionTimeout(Integer.parseInt(var2));
  65.             return;
  66.          }
  67.       } catch (Exception var3) {
  68.          System.err.println("Could not load properties file due to exception: " + var3);
  69.       }
  70.  
  71.    }
  72.  
  73.    public void run() {
  74.       try {
  75.          this.timer = new Timer(this);
  76.          this.timer.start();
  77.          this.traceM = new TraceManager(this);
  78.          if (this.isTracing) {
  79.             this.traceM.trace("JS: TraceManager up");
  80.          }
  81.  
  82.          this.dumpSettings();
  83.          this.threadM = new ThreadManager(this);
  84.          this.threadM.start();
  85.          if (this.isTracing) {
  86.             this.traceM.trace("JS: ThreadManager up");
  87.          }
  88.  
  89.          this.connectionM = new ConnectionManager(this, this.threadM);
  90.          this.connectionM.start();
  91.          if (this.isTracing) {
  92.             this.traceM.trace("JS: ConnectionManager up");
  93.          }
  94.       } catch (Exception var2) {
  95.          if (this.isTracing) {
  96.             this.traceM.trace("JS: caught " + var2);
  97.          }
  98.  
  99.          System.exit(1);
  100.       }
  101.  
  102.       if (this.isTracing) {
  103.          this.traceM.trace("JS: now up and running");
  104.       }
  105.  
  106.    }
  107.  
  108.    public void finalize() {
  109.       if (this.isTracing) {
  110.          this.traceM.trace("JS: Now shutting down");
  111.       }
  112.  
  113.       System.exit(0);
  114.    }
  115.  
  116.    public void setTracing(boolean var1) {
  117.       this.isTracing = var1;
  118.    }
  119.  
  120.    public boolean isTracing() {
  121.       return this.isTracing;
  122.    }
  123.  
  124.    public Timer getTimer() {
  125.       return this.timer;
  126.    }
  127.  
  128.    public void setPort(int var1) {
  129.       this.port = var1;
  130.    }
  131.  
  132.    public int getPort() {
  133.       return this.port;
  134.    }
  135.  
  136.    public void setHostName(String var1) {
  137.       this.hostName = new String(var1);
  138.    }
  139.  
  140.    public String getHostName() {
  141.       return this.hostName;
  142.    }
  143.  
  144.    public void setMaxNumBacklog(int var1) {
  145.       this.maxNumBacklog = var1;
  146.    }
  147.  
  148.    public int getMaxNumBacklog() {
  149.       return this.maxNumBacklog;
  150.    }
  151.  
  152.    public void setServerSocketTimeout(int var1) {
  153.       this.serverSocketTimeout = var1;
  154.    }
  155.  
  156.    public int getServerSocketTimeout() {
  157.       return this.serverSocketTimeout;
  158.    }
  159.  
  160.    public void setMaxNumThreads(int var1) {
  161.       this.maxNumThreads = var1;
  162.    }
  163.  
  164.    public int getMaxNumThreads() {
  165.       return this.maxNumThreads;
  166.    }
  167.  
  168.    public void setClientSocketTimeout(int var1) {
  169.       this.clientSocketTimeout = var1;
  170.    }
  171.  
  172.    public int getClientSocketTimeout() {
  173.       return this.clientSocketTimeout;
  174.    }
  175.  
  176.    public void setActionTimeout(int var1) {
  177.       this.actionTimeout = var1;
  178.    }
  179.  
  180.    public int getActionTimeout() {
  181.       return this.actionTimeout;
  182.    }
  183.  
  184.    public void dumpSettings() {
  185.       this.traceM.trace("JA:\t JAS settings: \n\t isTracing=" + this.isTracing + "\n" + "\t port=" + this.port + "\n" + "\t hostName=" + this.hostName + "\n" + "\t maxNumBacklog=" + this.maxNumBacklog + "\n" + "\t serverSocketTimeout=" + this.serverSocketTimeout + "\n" + "\t maxNumThreads=" + this.maxNumThreads + "\n" + "\t clientSocketTimeout=" + this.clientSocketTimeout + "\n" + "\t actionTimeout=" + this.actionTimeout);
  186.    }
  187. }
  188.