예제 #1
0
public class DryRunShawnProcess extends IShawnProcess {
  private Category log = Logging.get(this);

  private boolean running = true;

  @Override
  public void addResult(ShawnResult res) {}

  @Override
  public boolean isRunning() {
    return running;
  }

  @Override
  public void killProcess() {
    running = false;
    super.killProcess();
  }

  @Override
  public void notifyTaskDone() {}

  @Override
  public LinkedList<ShawnResult> runCommand(String cmd) {
    return runCommand(cmd, "");
  }

  @Override
  public LinkedList<ShawnResult> runCommand(String cmd, String params) {
    String cmdLine = toCommandLine(cmd, params);
    storeCommandInHistory(cmdLine);
    log.debug("Sending line to shawn: " + cmdLine);
    return new LinkedList<ShawnResult>();
  }

  @Override
  public void setGlobalVariable(String name, String value) {
    String cmdLine = toGlobalVariableLine(name, value);
    storeCommandInHistory(cmdLine);
    log.debug("Setting global variable: " + cmdLine);
  }
}
예제 #2
0
public class ShawnProcessFactory {
  private static Category log = Logging.get(ShawnProcessFactory.class);

  private static Vector<IShawnProcess> shawns = new Vector<IShawnProcess>();

  private static EnvironmentConfig defaultValues = null;

  public static IShawnProcess create() throws Exception {
    log.debug("Creating shawn instance with default values");

    IShawnProcess s = null;

    if (defaultValues.isDryRun()) {
      log.info("Creating dry run shawn instance");
      s = new DryRunShawnProcess();
    } else {
      log.info("Creating local process shawn instance");
      s = new ShawnProcess(defaultValues.getShawnExecutable(), defaultValues.getWorkDir());
    }
    shawns.add(s);
    return s;
  }

  public static void destroy() {

    log.debug("Destroying " + shawns.size() + " shawn processes.");
    for (IShawnProcess proc : shawns) proc.killProcess();
    log.debug("Done.");
  }

  public static EnvironmentConfig getDefaultValues() {
    return defaultValues;
  }

  public static void setDefaultValues(EnvironmentConfig defaultValues) {
    ShawnProcessFactory.defaultValues = defaultValues;
  }
}