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.IOException
public java.lang.String getName()
IndependentProcess
getName
in interface IndependentProcess
public 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.InterruptedException
java.util.concurrent.ExecutionException
public 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.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public 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.Runnable
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
IndependentProcess
addPropertyChangeListener
in interface IndependentProcess
listener
- a PropertyChangeListener instancepublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
IndependentProcess
removePropertyChangeListener
in interface IndependentProcess
listener
- a PropertyChangeListener instancepublic void execute()
IndependentProcess
execute
in interface IndependentProcess
public void setName(java.lang.String name)
IndependentProcess
setName
in interface IndependentProcess
name
- a Stringpublic void sendObjectToProcess(java.io.Serializable obj) throws java.io.IOException
IndependentProcess
sendObjectToProcess
in interface IndependentProcess
obj
- a Serializable objectjava.io.IOException
public void redirectOutputStream(boolean redirectOutputStream)
redirectOutputStream
- true to enable or false to disable