Package org.jppf.process
Class ProcessWrapper
java.lang.Object
org.jppf.process.ProcessWrapper
Wrapper around an external process started with
ProcessBuilder.
Instances of this class read the output ands error streams generated by the process and provide
a notification mechanism with separate events for the respective streams.- Author:
- Laurent Cohen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<ProcessWrapperEventListener>The list of registered listeners. -
Constructor Summary
ConstructorsConstructorDescriptionInitialize this process handler.ProcessWrapper(Process process) Initialize this process handler with the specified process. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ProcessWrapperEventListener listener) Add a listener to the list of listeners.protected voidfireStreamEvent(boolean output, String content) Notify all listeners that a stream event has occurred.Get the process to handle.voidremoveListener(ProcessWrapperEventListener listener) Remove a listener from the list of listeners.voidGive a name to this object.voidsetProcess(Process process) Set the process to handle.
-
Field Details
-
eventListeners
The list of registered listeners.
-
-
Constructor Details
-
ProcessWrapper
public ProcessWrapper()Initialize this process handler. -
ProcessWrapper
Initialize this process handler with the specified process.- Parameters:
process- the process to handle.
-
-
Method Details
-
getProcess
Get the process to handle.- Returns:
- a
Processinstance.
-
setProcess
Set the process to handle. If the process has already been set through this setter or the corresponding constructor, this method does nothing.- Parameters:
process- - aProcessinstance.
-
addListener
Add a listener to the list of listeners.- Parameters:
listener- the listener to add to the list.
-
removeListener
Remove a listener from the list of listeners.- Parameters:
listener- the listener to remove from the list.
-
fireStreamEvent
Notify all listeners that a stream event has occurred.- Parameters:
output- true if the event is for the output stream, false if it is for the error stream.content- the text that written to the stream.
-
setName
Give a name to this object.- Parameters:
name- the object's name.
-