|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--springs.util.ProcessExecutor
A process executor.
Nested Class Summary | |
(package private) class |
ProcessExecutor.ReaderThread
|
Field Summary | |
private java.lang.String |
_commandName
|
private static java.lang.String |
_ENCODING
|
private ProcessExecutor.ReaderThread |
_errorOutputWriter
|
private java.lang.String |
_id
|
private java.io.ObjectOutputStream |
_oos
|
private java.lang.String |
_output
|
private java.lang.Process |
_p
|
private boolean |
_recordOutput
|
private boolean |
_showOutput
|
private boolean |
_signalTermination
|
private ProcessExecutor.ReaderThread |
_standardOutputWriter
|
private java.lang.String |
_stringForEnd
|
private boolean |
_stringForEndReceived
|
private java.lang.String |
_stringForStart
|
private boolean |
_stringForStartReceived
|
private boolean |
_terminated
|
private static boolean |
_USE_ENCODING
|
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
ProcessExecutor(java.lang.String[] commandWithArgs,
java.lang.String id,
boolean waitForOutput)
Constructor de la clase. |
|
ProcessExecutor(java.lang.String[] commandWithArgs,
java.lang.String id,
int numLines)
Constructor. |
|
ProcessExecutor(java.lang.String commandName,
java.lang.String id,
boolean waitForOutput)
Constructor. |
|
ProcessExecutor(java.lang.String commandName,
java.lang.String id,
int numLines)
Constructor de la clase. |
|
ProcessExecutor(java.lang.String commandName,
java.lang.String id,
int numLines,
java.lang.Object object,
boolean signalTermination)
Constructor de la clase. |
|
ProcessExecutor(java.lang.String commandName,
java.lang.String id,
java.lang.String stringForStart,
java.lang.String stringForEnd,
java.lang.Object object,
boolean signalTermination)
Constructor. |
Method Summary | |
private void |
createObjectOutputStream()
Creates an output stream to pass objects to the process. |
private void |
execute(java.lang.String commandName)
Starts the execution of a command. |
private void |
execute(java.lang.String[] commandWithArgs)
Starts the execution of a command. |
java.lang.String |
getRecordedOutput()
Returns the recorded output. |
static void |
main(java.lang.String[] args)
Main method. |
void |
passObject(java.lang.Object object)
Writes an object in the standard input of the process. |
private void |
prepareReaders()
Start the readers. |
void |
sendCommand(java.lang.String command)
Sends a command to the process. |
void |
setShowOutput(boolean showOutput)
Sets if the output of the process should be shown. |
void |
startRecordingOutput()
Starts recording the output. |
void |
stopRecordingOutput()
Stops recording the output. |
void |
terminate()
Terminates the execution. |
private void |
waitForOutput(int numLines)
Blocks until the specified number of lines have been received. |
private void |
waitOutputEnd()
Waits for an output line that indicates the end of the process. |
private void |
waitOutputStart()
Waits for an output line that indicates the start of the process. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private java.lang.Process _p
private java.lang.String _commandName
private java.lang.String _id
private ProcessExecutor.ReaderThread _standardOutputWriter
private ProcessExecutor.ReaderThread _errorOutputWriter
private boolean _signalTermination
private java.io.ObjectOutputStream _oos
private java.lang.String _stringForStart
private java.lang.String _stringForEnd
private volatile boolean _stringForEndReceived
private volatile boolean _stringForStartReceived
private java.lang.String _output
private boolean _recordOutput
private boolean _showOutput
private boolean _terminated
private static final boolean _USE_ENCODING
private static final java.lang.String _ENCODING
Constructor Detail |
public ProcessExecutor(java.lang.String commandName, java.lang.String id, boolean waitForOutput)
commandName
- the command name.id
- an identifier for the ProcessExecutor.waitForOutput
- a boolean indicating whether it must block waiting for an output.String
public ProcessExecutor(java.lang.String[] commandWithArgs, java.lang.String id, boolean waitForOutput)
commandWithArgs
- the command name with its arguments.id
- an identifier for the ProcessExecutor.waitForOutput
- a boolean indicating whether it must block waiting for an output.String
public ProcessExecutor(java.lang.String commandName, java.lang.String id, int numLines)
commandName
- the command name.id
- an identifier for the ProcessExecutor.numLines
- number of lines in the output to wait for.String
public ProcessExecutor(java.lang.String commandName, java.lang.String id, int numLines, java.lang.Object object, boolean signalTermination) throws java.io.IOException
commandName
- the command name.id
- an identifier for the ProcessExecutor.numLines
- number of lines in the output to wait for.object
- an object to pass as an argument in the standard input of the process.signalTermination
- a boolean indicating if the termination of the process must be
signaled by sending a signal through its standard input or by just destroying it.
java.io.IOException
String
,
Object
public ProcessExecutor(java.lang.String commandName, java.lang.String id, java.lang.String stringForStart, java.lang.String stringForEnd, java.lang.Object object, boolean signalTermination) throws java.io.IOException
commandName
- name of the command to execute.id
- an identifier for the process executor.stringForStart
- the string that signals the start of the process.stringForEnd
- the string that signals the end of the process.object
- an object to pass as an argument in the standard input of the process.signalTermination
- a boolean indicating if the termination of the process must be
signaled by sending a signal through its standard input or by just destroying it.
java.io.IOException
String
,
Object
public ProcessExecutor(java.lang.String[] commandWithArgs, java.lang.String id, int numLines)
commandWithArgs
- an array with the command name and its arguments.id
- an identifier for the process executor.numLines
- number of lines in the output to wait for.String
Method Detail |
public void setShowOutput(boolean showOutput)
showOutput
- a boolean indicating whether the output should be shown.public void startRecordingOutput()
public void stopRecordingOutput()
public java.lang.String getRecordedOutput()
String
private void execute(java.lang.String commandName)
commandName
- the name of the command (with its options).String
private void execute(java.lang.String[] commandWithArgs)
commandWithArgs
- the name of the command (with its options).String
private void prepareReaders()
private void waitOutputEnd()
private void waitOutputStart()
private void waitForOutput(int numLines)
numLines
- the number of lines to wait for.public void terminate()
private void createObjectOutputStream() throws java.io.IOException
java.io.IOException
- if error.IOException
public void passObject(java.lang.Object object) throws java.io.IOException
object
- the object. It must be Serializable.
java.io.IOException
- if there is an error.Object
,
Serializable
,
IOException
public void sendCommand(java.lang.String command) throws java.io.IOException
command
- the command.
java.io.IOException
- if there is an error.String
,
IOException
public static void main(java.lang.String[] args)
args
- the command to execute.String
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |