Package org.apache.commons.exec

Examples of org.apache.commons.exec.PumpStreamHandler


        String tmStr = config.getProperty(PROP_EXIT_TIMEOUT_SECONDS);
        final int exitTimeoutSeconds = tmStr == null ? DEFAULT_EXIT_TIMEOUT : Integer.valueOf(tmStr);

        log.info("Executing " + cl);
        executor.setStreamHandler(new PumpStreamHandler());
        final ShutdownHookSingleProcessDestroyer pd = new ShutdownHookSingleProcessDestroyer("java -jar " + jarToExecute.getName(), exitTimeoutSeconds);
        final boolean waitOnShutdown = Boolean.valueOf(config.getProperty(PROP_WAIT_ONSHUTDOWN, "false"));
        log.info("Setting up ProcessDestroyer with waitOnShutdown=" + waitOnShutdown);
        pd.setWaitOnShutdown(waitOnShutdown);
        executor.setProcessDestroyer(pd);
View Full Code Here


          }
        }
      }
    };
   
    streamHandler = new PumpStreamHandler(outStream, errStream);
   
    executor = new DefaultExecutor();
    executor.setStreamHandler(streamHandler);

  }
View Full Code Here

        Executor exec = new DefaultExecutor();
        Map<String, String> env = new HashMap<String, String>(System.getenv());
//        env.put("path", ";");
//        env.put("path", System.getProperty("java.home"));

        ExecuteStreamHandler handler = new PumpStreamHandler(System.out, System.err, System.in);
        exec.setStreamHandler(handler);
        exec.setWorkingDirectory(getWorkingDirectory());

        int status;
        try {
View Full Code Here

      if(this.writerStdIn)
      {
        this.bais = new ByteArrayInputStream(in.getText().getBytes());

        executor.setStreamHandler(new PumpStreamHandler(this.baos, this.baosErr, this.bais));
      }
      else
      {
        executor.setStreamHandler(new PumpStreamHandler(this.baos, this.baosErr));
      }

      executor.setWatchdog(watchdog);

      executor.execute(commandLine, new ExecuteResultHandler(){
View Full Code Here

    private String exec(File workingDir, org.apache.commons.exec.CommandLine cmdLine) throws Exception {
        Executor executor = new DefaultExecutor();
        org.apache.commons.io.output.ByteArrayOutputStream buffer = new org.apache.commons.io.output.ByteArrayOutputStream();
        NullOutputStream nullOs = new NullOutputStream();
        PumpStreamHandler streamHandler = new PumpStreamHandler(nullOs, buffer);
        executor.setWorkingDirectory(workingDir);
        executor.setStreamHandler(streamHandler);
        String result = "";

        try {
View Full Code Here

    }

    protected void killPid(String pid) throws IOException {
        Executor executor = new DefaultExecutor();
        executor.setWorkingDirectory(getBinDir());
        PumpStreamHandler streamHandler = new PumpStreamHandler(createNullOutputStream(), createNullOutputStream());
        executor.setStreamHandler(streamHandler);
        org.apache.commons.exec.CommandLine commandLine;

        commandLine = new org.apache.commons.exec.CommandLine("kill").addArgument(pid);
        executor.execute(commandLine);
View Full Code Here

    protected boolean isUnixPidRunning(String pid) {

        Executor executor = new DefaultExecutor();
        executor.setWorkingDirectory(getBinDir());
        PumpStreamHandler streamHandler = new PumpStreamHandler(createNullOutputStream(), createNullOutputStream());
        executor.setStreamHandler(streamHandler);
        org.apache.commons.exec.CommandLine commandLine;
        commandLine = new org.apache.commons.exec.CommandLine("kill").addArgument("-0").addArgument(pid);

        boolean isRunning = true; // assume it is running
View Full Code Here

    cmdLine.addArguments(pid);
    final Executor executor = new DefaultExecutor();
    executor.setExitValue(1);
    final DefaultExecuteResultHandler derh = new DefaultExecuteResultHandler();
//    executor.setProcessDestroyer(MPlayerFileService.PROCESS_SHUTDOWN_HOOK);
    executor.setStreamHandler(new PumpStreamHandler(out, err));
    try {
      logger.info("execute " + kill_cmd_log + " " + pid);
      executor.execute(cmdLine, derh);
      derh.waitFor();
      return true;
View Full Code Here

    final Executor executor = new DefaultExecutor();
    executor.setExitValue(1);

    final DefaultExecuteResultHandler derh = new DefaultExecuteResultHandler();
    executor.setProcessDestroyer(MPlayerFileService.PROCESS_SHUTDOWN_HOOK);
    executor.setStreamHandler(new PumpStreamHandler(out, err));
    try {
      logger.info("execute " + list_cmd_log);
      executor.execute(cmdLine, derh);
      derh.waitFor();
     
View Full Code Here

//      ExecuteWatchdog watchdog = new ExecuteWatchdog(30*1000);
      final Executor executor = new DefaultExecutor();
      executor.setExitValue(1);
//      executor.setWatchdog(watchdog);
//      executor.setProcessDestroyer(MPlayerFileService.PROCESS_SHUTDOWN_HOOK);
      executor.setStreamHandler(new PumpStreamHandler(this.out, this.err));
      executor.setWorkingDirectory(this.tempFolder);
      executor.execute(cmdLine, this);
     
//    } else {
//      throw new ExecuteException("mts will not work with mplayer -identify", 0);
View Full Code Here

TOP

Related Classes of org.apache.commons.exec.PumpStreamHandler

Copyright © 2018 www.massapicom. 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.