Package org.atomojo.app.storage.xmldb

Source Code of org.atomojo.app.storage.xmldb.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.storage.xmldb;

import org.atomojo.app.Main;

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

   Main main;
  
   /** Creates a new instance of Daemon */
   public Daemon()
   {
   }
  
   public void init(String[] args) {
      // Here open the configuration files, create the trace file, create the ServerSockets, the Threads
      if (args.length!=1) {
         throw new RuntimeException("The minimum number of argument is 1 (the directory).");
      }
      boolean found = false;
      for (int i=0; i<args.length; i++) {
         if (args[i].equals("-c") || args[i].equals("--class")) {
            found = true;
         }
      }
      if (!found) {
         String [] newargs = new String[args.length+2];
         newargs[0] = "-c";
         newargs[1] = XMLDBStorageFactory.class.getName();
         System.arraycopy(args, 0, newargs, 2, args.length);
         args = newargs;
      }
      main = new Main(args);
      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.storage.xmldb.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.