info.aduna.platform
Class ProcessLauncher

java.lang.Object
  extended by info.aduna.platform.ProcessLauncher

public final class ProcessLauncher
extends Object

Launches a process, redirecting the output of that sub-process to the output of this (the parent) process.


Nested Class Summary
static class ProcessLauncher.CommandNotExistsException
          Exception that is thrown when a command could not be executed because it (probably) does not exist at all.
static interface ProcessLauncher.OutputListener
          Classes implementing this interface can receive output generated by processes launched using the ProcessLauncher.
 
Constructor Summary
ProcessLauncher(ArrayList<?> commandList)
          Constructs new process launcher with the given command element list.
ProcessLauncher(ArrayList<?> commandList, File baseDir)
           
ProcessLauncher(String commandLine)
          Constructs a new ProcessLauncher with the given command line.
ProcessLauncher(String[] commandArray)
          Constructs a new ProcessLauncher with the given command array.
ProcessLauncher(String[] commandArray, File baseDir)
           
ProcessLauncher(String commandLine, File baseDir)
           
 
Method Summary
 void abort()
          Tries to abort the currently running process.
 void addOutputListener(ProcessLauncher.OutputListener listener)
          Add a listener for output from the to-be-launched process.
 String getCommandLine()
          Get the commandline that is used to launch the process.
 String getErrorOutput()
          Get error output, in case no listeners were registered - never returns null.
 String getStandardOutput()
          Get standard output, in case no listeners were registered - never returns null.
 boolean hasFinished()
          Check whether execution has finished.
 int launch()
          Launches the process, and blocks until that process completes execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessLauncher

public ProcessLauncher(String commandLine)
Constructs a new ProcessLauncher with the given command line.


ProcessLauncher

public ProcessLauncher(String commandLine,
                       File baseDir)

ProcessLauncher

public ProcessLauncher(String[] commandArray)
Constructs a new ProcessLauncher with the given command array.


ProcessLauncher

public ProcessLauncher(String[] commandArray,
                       File baseDir)

ProcessLauncher

public ProcessLauncher(ArrayList<?> commandList)
Constructs new process launcher with the given command element list.


ProcessLauncher

public ProcessLauncher(ArrayList<?> commandList,
                       File baseDir)
Method Detail

addOutputListener

public void addOutputListener(ProcessLauncher.OutputListener listener)
Add a listener for output from the to-be-launched process.


getStandardOutput

public String getStandardOutput()
Get standard output, in case no listeners were registered - never returns null.


getErrorOutput

public String getErrorOutput()
Get error output, in case no listeners were registered - never returns null.


getCommandLine

public String getCommandLine()
Get the commandline that is used to launch the process.


hasFinished

public boolean hasFinished()
Check whether execution has finished.


launch

public int launch()
           throws ProcessLauncher.CommandNotExistsException
Launches the process, and blocks until that process completes execution.

Throws:
ProcessLauncher.CommandNotExistsException - If the command could not be executed because it does not exist

abort

public void abort()
Tries to abort the currently running process.



Copyright © 2001-2012 Aduna. All Rights Reserved.