Package org.apache.commons.exec

Examples of org.apache.commons.exec.PumpStreamHandler


        Executor executor = new DefaultExecutor();
        ByteArrayOutputStream os = new ByteArrayOutputStream();

        try {
            executor.setStreamHandler(new PumpStreamHandler(os, os));
            executor.execute(CommandLine.parse(from.getPath() + " -V"));
        } catch (IOException e) {
            throw new PlatformDependentTools.ThisIsNotNginxExecutableException(e);
        }
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

     */
    private Executor buildExecutor(OutputStream output) {
        DefaultExecutor executor = new DefaultExecutor();
        ExecuteWatchdog watchdog = new ExecuteWatchdog(60000);
        executor.setWatchdog(watchdog);
        ExecuteStreamHandler psh = new PumpStreamHandler(output);
        executor.setStreamHandler(psh);
        // We want to handle all exit values directly (not as ExecuteException).
        executor.setExitValues(null);
        return executor;
    }
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());
    ShutdownHookProcessDestroyer destroyer = new ShutdownHookProcessDestroyer();
    exec.setProcessDestroyer(destroyer);
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

                environment.put("DYLD_LIBRARY_PATH", kakadu);
            } else {
                environment.put("LD_LIBRARY_PATH", kakadu);
            }

            executor.setStreamHandler(new PumpStreamHandler(stdOut, error));
            executor.setWatchdog(watchdog);
            executor.execute(cmdLine, environment, handler);

            try {
                handler.waitFor();
View Full Code Here

                environment.put("DYLD_LIBRARY_PATH", kakadu);
            } else {
                environment.put("LD_LIBRARY_PATH", kakadu);
            }

            executor.setStreamHandler(new PumpStreamHandler(stdOut, error));
            executor.setWatchdog(watchdog);
            executor.execute(cmdLine, environment, handler);

            try {
                handler.waitFor();
View Full Code Here

   */
  void doProcess(final InputStream in, final OutputStream out)
      throws ExecuteException, IOException {
    final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
    final Executor executor = new DefaultExecutor();
    executor.setStreamHandler(new PumpStreamHandler(out, errorStream, in));
    final int result = executor.execute(CommandLine.parse(NGMIN_COMMAND));
    LOG.debug("result={}", result);
    if (result != 0) {
      throw new ExecuteException("Processing failed: " + new String(errorStream.toByteArray()), result);
    }
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

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.