Package org.apache.commons.exec

Examples of org.apache.commons.exec.PumpStreamHandler


        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


        cl.addArgument("-jar");
        cl.addArgument(jarToExecute.getAbsolutePath());
        cl.addArgument("-p");
        cl.addArgument(String.valueOf(serverPort));
        log.info("Executing " + cl);
        e.setStreamHandler(new PumpStreamHandler());
        e.setProcessDestroyer(new ShutdownHookProcessDestroyer());
        e.execute(cl, h);
    }
View Full Code Here

    protected int executeCommandLine( Executor exec, CommandLine commandLine, Map enviro, OutputStream out,
                                      OutputStream err )
        throws ExecuteException, IOException
    {
        exec.setStreamHandler( new PumpStreamHandler( out, err, System.in ) );
        return exec.execute( commandLine, enviro );
    }
View Full Code Here

            {
                getLog( ).error( "An error occurred executing background process with command line [" + commandLine
                        + "].", e );
            }
        };
        exec.setStreamHandler( new PumpStreamHandler( out, err, System.in ) );
        // Kill the process when this JVM exits.
        exec.setProcessDestroyer( new ShutdownHookProcessDestroyer( ) );
        exec.execute( commandLine, enviro, resultHandler );

        if ( backgroundPollingAddress != null )
View Full Code Here

        commandLine.addArgument(command);
        commandLine.addArguments(args);
        DefaultExecutor executor = new DefaultExecutor();
        ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
        executor.setWatchdog(watchdog);
        executor.setStreamHandler(new PumpStreamHandler());
        return doExecution(executor, commandLine, newEnv);
    }
View Full Code Here

        Map<Object, Object> newEnv = this.copyEnvironmentVariables();
        DefaultExecutor executor = new DefaultExecutor();
        ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
        executor.setWatchdog(watchdog);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
        executor.setStreamHandler(streamHandler);
        if (this.doExecution(executor, new CommandLine(this.muleBin).addArgument("status"), newEnv) == 0)
        {
            Matcher matcher = STATUS_PATTERN.matcher(outputStream.toString());
            if (matcher.find())
View Full Code Here

        CommandLine cmdLine = CommandLine.parse(command);
        DefaultExecutor executor = new DefaultExecutor();
        Map<String, String> env = addEnvProperties(envVars);
        ExecuteWatchdog watchDog = new ExecuteWatchdog(TIMEOUT);
        executor.setWatchdog(watchDog);
        executor.setStreamHandler(new PumpStreamHandler());
        int result = executor.execute(cmdLine, env);
        if (executor.isFailure(result))
        {
            if (watchDog.killedProcess())
            {
View Full Code Here

        displayCmd(displayCmd, cmd);
        Executor exec = new DefaultExecutor();

        //err and out are redirected to out
        if (!_redirectToLog) {
          exec.setStreamHandler(new PumpStreamHandler(System.out, System.err, System.in));
        } else {
            exec.setStreamHandler(new PumpStreamHandler(new LogOutputStream() {
                private LevelState _previous = new LevelState();
               
                @Override
                protected void processLine(String line, int level) {
                  try {
View Full Code Here

    // Setup stdout and stderr
    int nbytes = appConf.getInt(AppConfig.EXEC_MAX_BYTES_NAME, -1);
    ByteArrayOutputStream outStream = new MaxByteArrayOutputStream(nbytes);
    ByteArrayOutputStream errStream = new MaxByteArrayOutputStream(nbytes);
    executor.setStreamHandler(new PumpStreamHandler(outStream, errStream));

    // Only run for N milliseconds
    int timeout = appConf.getInt(AppConfig.EXEC_TIMEOUT_NAME, 0);
    ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
    executor.setWatchdog(watchdog);
View Full Code Here

  {
    LOG.debug("Execute command : {}", command);

    CommandLine cmdLine = CommandLine.parse(command);
    DefaultExecutor executor = new DefaultExecutor();
    executor.setStreamHandler(new PumpStreamHandler(out, err));

    int exitValue = executor.execute(cmdLine);
    LOG.debug("Execution finished with exit code : {}", exitValue);
    return exitValue;
  }
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.