示例#1
0
 // This should be all we need to put in a main function.
 // args are the commandline arguments
 // First object is the Runnable object to call run on.
 // All of them are objects whose options args is to supposed to populate.
 public static void run(String[] args, Object... objects) {
   init(args, objects);
   if (makeThunk) {
     setExecStatus("thunk", true);
     printOutputMap(Execution.getFile("output.map"));
     List<String> cmd = new ArrayList();
     cmd.add("java");
     if (thunkJavaOpts != null) cmd.add(thunkJavaOpts);
     cmd.add("-cp " + StrUtils.join(jarFiles, ":") + ":" + System.getProperty("java.class.path"));
     cmd.addAll(
         ListUtils.newList(
             objects[0].getClass().getName(),
             "++" + virtualExecDir, // Load these options
             // Next time when we run, just run in the same path that we used to create the thunk
             "-execDir",
             virtualExecDir,
             "-overwriteExecDir"));
     IOUtils.printLinesHard(
         Execution.getFile("job.map"),
         ListUtils.newList(
             "workingDir\t" + SysInfoUtils.getcwd(), // Run from current directory
             "command\t" + StrUtils.join(cmd, "\t"),
             "priority\t" + thunkPriority));
   } else {
     if (dontCatchExceptions) {
       ((Runnable) objects[0]).run();
     } else {
       try {
         ((Runnable) objects[0]).run();
       } catch (Throwable t) {
         raiseException(t);
       }
     }
   }
   finish();
 }