Пример #1
0
  /**
   * @param args
   * @throws InterruptedException
   */
  public static void main(String[] args) throws InterruptedException {

    String conf = "spring.xml";
    AbstractApplicationContext context = new ClassPathXmlApplicationContext(conf);
    ConfigurableEnvironment configurableEnvironment = new StandardEnvironment();
    boolean testMode = false;

    if (args != null && args.length > 0) {
      if ("-test".equals(args[0])) {
        configurableEnvironment.setActiveProfiles("TEST");
        testMode = true;
      } else {
        configurableEnvironment.setActiveProfiles("PROD");
      }
    } else {
      configurableEnvironment.setActiveProfiles("PROD");
    }
    context.setEnvironment(configurableEnvironment);

    PropertyConfigurator.configure("resources/log4j.properties");

    logger.info("Starting launcher...");

    int iteration = 0;

    Launcher launcher = context.getBean("launcher", Launcher.class);

    while (true) {

      iteration++;

      logger.info("Iteration #" + iteration + " at " + new Date());

      logger.info(" Launching zezo automatic routing...");
      launcher.runZezoAutoRouting(testMode);

      /*
       * logger.info(" Launching waypoints..."); launcher.runWaypoints();
       *
       * logger.info(" Launching speed regulation...");
       * launcher.speedRegulation();
       */

      Date nextIteration = getNextIteration();
      long msToSleep = getSecondRemainingBefore(nextIteration);
      logger.info("Waiting for next iteration at " + nextIteration + "\n\n\n");
      Thread.sleep(msToSleep);
    }
  }