Exemple #1
0
  public static void main(String[] args) {
    System.out.println("CommandLineExec.main CALLED");
    if (args.length == 0) {
      System.out.println("Error: Taskgraph xml file not specified");
      System.out.println("Usage: java CommandLineExec <xmlfile>");
      return;
    }

    File file = new File(args[0]);

    if (!file.exists()) {
      System.out.println("File not found: " + file.getAbsolutePath());
      return;
    }
    try {
      TrianaInstance engine = null;
      try {
        engine = new TrianaInstance(args);
        engine.init();
      } catch (Exception e) {
        e.printStackTrace(); // To change body of catch statement use File | Settings | File
        // Templates.
        System.exit(1);
      }

      XMLReader reader = new XMLReader(new FileReader(file));
      CommandLineExec exec =
          new CommandLineExec(
              "CommandLineExec <xmlfile> ", reader.readComponent(engine.getProperties()));

      String[] argsub = new String[args.length - 1];
      System.arraycopy(args, 1, argsub, 0, argsub.length);
      exec.initParameters(argsub);

      exec.run(new Object[0]);
      while (!exec.isFinished()) {
        System.out.println("CommandLineExec.main WAITING FOR TASKGRAPH TO FINISH");
        try {
          Thread.sleep(100);
        } catch (InterruptedException e) {

        }
      }
      exec.dispose();
    } catch (FileNotFoundException except) {
      System.out.println("File not found: " + file.getAbsolutePath());
    } catch (TaskGraphException except) {
      System.out.println("Invalid taskgraph file: " + file.getAbsolutePath());
    } catch (SchedulerException except) {
      System.out.println("Error running taskgraph: " + except.getMessage());
    } catch (IOException except) {
      except.printStackTrace();
    }
    System.exit(0);
  }