Package org.atomojo.app.daemon

Source Code of org.atomojo.app.daemon.Daemon

/*
* Daemon.java
*
* Created on June 30, 2007, 12:31 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package org.atomojo.app.daemon;

import org.atomojo.app.Main;

/**
*
* @author alex
*/
public class Daemon
{

   Main main;
  
   /** Creates a new instance of Daemon */
   public Daemon()
   {
   }
  
   public void init(String[] arguments) {
      // Here open the configuration files, create the trace file, create the ServerSockets, the Threads
      if (arguments.length!=1) {
         throw new RuntimeException("The minimum number of argument is 1 (the directory).");
      }
      main = new Main(arguments);
      try {
         // bind
         main.init();
      } catch (Exception ex) {
         ex.printStackTrace();
      }
   }
  
   public void start() {
      // Start the Thread, accept incomming connections
      main.run();
   }
  
   public void stop() {
      // Inform the Thread to live the run(), close the ServerSockets
      try {
        main.stop();
      } catch (Exception ex) {
         ex.printStackTrace();
      }
   }
  
   public void destroy() {
      // Destroy any object created in init()
      main = null;
   }

}
TOP

Related Classes of org.atomojo.app.daemon.Daemon

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.