public class CmdProcess
extends java.lang.Object
IndependentProcess.StateValue| Constructor and Description |
|---|
CmdProcess(java.util.List<java.lang.String> commands)
Sub constructor with the commands only.
|
CmdProcess(java.util.List<java.lang.String> commands,
java.io.File workingDirectory)
General constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
This method add a listener to the instance of this class if it is not already included in the listeners list.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
protected java.lang.Process |
createIndependentProcess()
This method creates the proper Process instance according to the derived class.
|
void |
execute()
This method starts the independent process.
|
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue) |
java.lang.Integer |
get() |
java.lang.Integer |
get(long duration,
java.util.concurrent.TimeUnit timeUnit) |
java.lang.String |
getName()
This method returns the name of the process.
|
IndependentProcess.StateValue |
getState()
This method returns the state of the process which can be either PENDING, STARTED, or DONE.
|
boolean |
isCancelled() |
boolean |
isDone() |
void |
redirectOutputStream(boolean redirectOutputStream)
This method enables the redirection of the outputstream of the independent process into the outputstream of this outer process (this process).
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
This method removes all the instances of the listener among the listeners of this class.
|
void |
run() |
void |
sendObjectToProcess(java.io.Serializable obj)
This method makes it possible to send a Serializable object to the independent process, typically a callback process.
|
void |
setName(java.lang.String name)
This method sets the name of this process.
|
public CmdProcess(java.util.List<java.lang.String> commands,
java.io.File workingDirectory)
commands - the list of commandsworkingDirectory - the working directory for the processpublic CmdProcess(java.util.List<java.lang.String> commands)
commands - the list of commandsprotected java.lang.Process createIndependentProcess()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getName()
IndependentProcessgetName in interface IndependentProcesspublic boolean cancel(boolean mayInterruptIfRunning)
cancel in interface java.util.concurrent.Future<java.lang.Integer>public java.lang.Integer get()
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
get in interface java.util.concurrent.Future<java.lang.Integer>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic java.lang.Integer get(long duration,
java.util.concurrent.TimeUnit timeUnit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
get in interface java.util.concurrent.Future<java.lang.Integer>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionpublic boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<java.lang.Integer>public IndependentProcess.StateValue getState()
public boolean isDone()
isDone in interface java.util.concurrent.Future<java.lang.Integer>public void run()
run in interface java.lang.Runnableprotected void firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
IndependentProcessaddPropertyChangeListener in interface IndependentProcesslistener - a PropertyChangeListener instancepublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
IndependentProcessremovePropertyChangeListener in interface IndependentProcesslistener - a PropertyChangeListener instancepublic void execute()
IndependentProcessexecute in interface IndependentProcesspublic void setName(java.lang.String name)
IndependentProcesssetName in interface IndependentProcessname - a Stringpublic void sendObjectToProcess(java.io.Serializable obj)
throws java.io.IOException
IndependentProcesssendObjectToProcess in interface IndependentProcessobj - a Serializable objectjava.io.IOExceptionpublic void redirectOutputStream(boolean redirectOutputStream)
redirectOutputStream - true to enable or false to disable