public class ManagedProcess extends Object implements Closeable
| Modifier and Type | Class and Description |
|---|---|
class |
ManagedProcess.ManagedProcessException |
| Constructor and Description |
|---|
ManagedProcess(List<String> commands) |
ManagedProcess(List<String> commands,
File logDirectory) |
ManagedProcess(String command) |
ManagedProcess(String name,
List<String> commands) |
ManagedProcess(String name,
List<String> commands,
File logDirectory,
boolean redirectOuput) |
ManagedProcess(String name,
String command) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
File |
getExecutionDirectory() |
String |
getId() |
File |
getProcessErrorLog() |
InputStream |
getProcessInputStream() |
File |
getProcessOutputLog() |
OutputStream |
getProcessOutputStream() |
void |
start() |
int |
waitFor(long timeout)
Causes the current thread to wait, if necessary, until the process has
terminated, or the specified waiting time elapses.
|
public ManagedProcess(String command) throws ManagedProcess.ManagedProcessException
command - the command to be executed (the program and its arguments)
formatted as stringManagedProcess.ManagedProcessExceptionpublic ManagedProcess(String name, String command) throws ManagedProcess.ManagedProcessException
name - a string describing the process. This is used to prefix the ID
which uniquely identifies the process instancecommand - the command to be executed (the program and its arguments)
formatted as stringManagedProcess.ManagedProcessExceptionpublic ManagedProcess(List<String> commands) throws ManagedProcess.ManagedProcessException
commands - the list containing the program and its argumentsManagedProcess.ManagedProcessExceptionpublic ManagedProcess(String name, List<String> commands) throws ManagedProcess.ManagedProcessException
name - a string describing the process. This is used to prefix the ID
which uniquely identifies the process instancecommands - the list containing the program and its argumentsManagedProcess.ManagedProcessExceptionpublic ManagedProcess(List<String> commands, File logDirectory) throws ManagedProcess.ManagedProcessException
commands - the list containing the program and its argumentslogDirectory - the directory where the logs (stdout and stderr) of the
process will be written toManagedProcess.ManagedProcessExceptionpublic ManagedProcess(String name, List<String> commands, File logDirectory, boolean redirectOuput) throws ManagedProcess.ManagedProcessException
name - a string describing the process. This is used to prefix
the ID wich uniquely identifies the process instancecommands - the list containing the program and its argumentslogDirectory - the directory where the logs (stdout and stderr) of the
process will be written toManagedProcess.ManagedProcessExceptionpublic String getId()
public OutputStream getProcessOutputStream()
public InputStream getProcessInputStream() throws Exception
Exceptionpublic File getProcessOutputLog()
public File getProcessErrorLog()
public File getExecutionDirectory()
public void start()
throws ManagedProcess.ManagedProcessException
public int waitFor(long timeout)
throws TimeoutException,
InterruptedException
timeout - the maximum time to wait in msTimeoutException - if the process doesn't exit within the defined
timeoutInterruptedException - if the thread is interrupted while waiting for
the process to exitpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2019. All rights reserved.