public abstract class AbstractProcessOutput
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String[] |
m_Command
the command.
|
protected java.lang.String[] |
m_Environment
the environment variables.
|
protected int |
m_ExitCode
the exit code.
|
protected java.lang.Process |
m_Process
the process.
|
protected boolean |
m_TimedOut
whether the process has timed out.
|
protected int |
m_TimeOut
the timeout for the process in seconds (ignored if < 1).
|
| Constructor and Description |
|---|
AbstractProcessOutput()
Starts the monitoring process.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract java.lang.Thread |
configureStdErr(java.lang.Process process)
Configures the thread for stderr.
|
protected abstract java.lang.Thread |
configureStdOut(java.lang.Process process)
Configures the thread for stdout.
|
protected java.lang.Thread |
configureTimeOutMonitor(java.lang.Process process)
Configures the thread for watching for time outs.
|
void |
destroy()
Destroys the process if possible.
|
java.lang.String[] |
getCommand()
Returns the command that was used for the process.
|
java.lang.String[] |
getEnvironment()
Returns the environment.
|
int |
getExitCode()
Returns the exit code.
|
java.lang.Process |
getProcess()
Returns the process.
|
int |
getTimeOut()
Returns the timeout for the process in seconds.
|
boolean |
hasSucceeded()
Returns whether the process has succeeded.
|
boolean |
hasTimedOut()
Returns whether the process timed out and got terminated.
|
protected void |
initialize()
For initializing the members.
|
void |
monitor(java.lang.ProcessBuilder builder)
Performs the actual process monitoring.
|
void |
monitor(java.lang.String[] cmd,
java.lang.String[] env,
java.lang.String input,
java.lang.Process process)
Performs the actual process monitoring.
|
void |
monitor(java.lang.String input,
java.lang.ProcessBuilder builder)
Performs the actual process monitoring.
|
void |
monitor(java.lang.String cmd,
java.lang.String[] env,
java.lang.Process process)
Performs the actual process monitoring.
|
void |
monitor(java.lang.String cmd,
java.lang.String[] env,
java.lang.String input,
java.lang.Process process)
Performs the actual process monitoring.
|
void |
setTimeOut(int value)
Sets the timeout for the process in seconds.
|
java.lang.String |
toString()
Returns a short description string.
|
protected java.lang.String[] m_Command
protected java.lang.String[] m_Environment
protected int m_ExitCode
protected transient java.lang.Process m_Process
protected int m_TimeOut
protected boolean m_TimedOut
public AbstractProcessOutput()
protected void initialize()
public void setTimeOut(int value)
value - the timeout (less than 1 for no timeout)public int getTimeOut()
public void monitor(java.lang.ProcessBuilder builder)
throws java.lang.Exception
builder - the process builder to monitorjava.lang.Exception - if writing to stdin failspublic void monitor(java.lang.String input,
java.lang.ProcessBuilder builder)
throws java.lang.Exception
builder - the process builder to monitorjava.lang.Exception - if writing to stdin failspublic void monitor(java.lang.String cmd,
java.lang.String[] env,
java.lang.Process process)
throws java.lang.Exception
cmd - the command that was usedenv - the environmentprocess - the process to monitorjava.lang.Exception - if writing to stdin failspublic void monitor(java.lang.String cmd,
java.lang.String[] env,
java.lang.String input,
java.lang.Process process)
throws java.lang.Exception
cmd - the command that was usedenv - the environmentinput - the input to be written to the process via stdin, ignored if nullprocess - the process to monitorjava.lang.Exception - if writing to stdin failspublic void monitor(java.lang.String[] cmd,
java.lang.String[] env,
java.lang.String input,
java.lang.Process process)
throws java.lang.Exception
cmd - the command that was usedenv - the environmentinput - the input to be written to the process via stdin, ignored if nullprocess - the process to monitorjava.lang.Exception - if writing to stdin failsprotected abstract java.lang.Thread configureStdErr(java.lang.Process process)
process - the process to monitorprotected abstract java.lang.Thread configureStdOut(java.lang.Process process)
process - the process to monitorprotected java.lang.Thread configureTimeOutMonitor(java.lang.Process process)
process - the process to monitorpublic java.lang.String[] getCommand()
public java.lang.String[] getEnvironment()
public boolean hasSucceeded()
hasTimedOut()public int getExitCode()
public boolean hasTimedOut()
getTimeOut(),
setTimeOut(int)public java.lang.Process getProcess()
public void destroy()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2018 University of Waikato, Hamilton, NZ. All Rights Reserved.