Package com.acelet.s.scheduler

Source Code of com.acelet.s.scheduler.SchedulingDaemon

/* Copyright 1999-2008 Acelet.org. All rights reserved. GPL v2 license */
/** @author Wei Jiang */

package com.acelet.s.scheduler;

import java.io.*;
import java.sql.Connection;
import java.util.*;

import com.acelet.lib.Common;
import com.acelet.lib.Externals;
import com.acelet.lib.JavaVersionException;
import com.acelet.lib.Phrase;
import com.acelet.s.MailServerData;
import com.acelet.s.PrintInfo;
import com.acelet.s.scheduler.Delegate;
import com.acelet.s.scheduler.SchedulerProperties;
import com.acelet.s.task.BusinessCalendar;
import com.acelet.s.task.CandidateTask;
import com.acelet.s.task.Task;
import com.acelet.s.task.TaskText;
import com.acelet.s.task.WorkingTask;

public class SchedulingDaemon extends Scheduling {
  public SchedulingDaemon() {
  }

  public void init() throws Exception {
    showLicense();
    new PrintInfo().printInfo();
    Externals.runningMode = Externals.RUNNING_MODE_COMMAND_LINE;
   
    MailServerData.init();
   
    String logAgentName = SchedulerProperties.getLogAgentName();
    Delegate.init(logAgentName);
   
    init(true, Externals.RUNNING_MODE_COMMAND_LINE);
  }

  public void showLicense() throws Exception {
    System.out.println("SuperScheduler version " + version + " " +
      "Copyright Acelet.org. 1999-2008. All rights reserved");
    System.out.println("GNU GENERAL PUBLIC LICENSE v2");
    try {
      Thread.currentThread().sleep(3000);
    } catch (Exception ex) {
    }
  }

  public void process(String[] args) throws Exception {
    for (int i = 0; i < args.length; i++) {
      if (args[i].equalsIgnoreCase("-" + NO_PERIODIC_PROMPT))
        noPeriodicPrompt = true;
    }

    init();

    while (true) {
      if (noPeriodicPrompt == false)
        iAmAlive();

      try {
        readRefreshTime();
        readFromDatabase();
        readWorkingTasks();
        checkDurations();
      } catch (Throwable th) {
        System.err.println("Scheduling: " + new Date() + ": " + th.toString());
      }
      try {
        Thread.currentThread().sleep(interval);
      } catch (Exception excep) {
        excep.printStackTrace();
      }
    }
  }

  public static void main(String[] args) throws Exception {
    new SchedulingDaemon().process(args);
  }

}
TOP

Related Classes of com.acelet.s.scheduler.SchedulingDaemon

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.