|
The im4java Library, Version 1.4.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.im4java.process.ProcessStarter
public class ProcessStarter
This class implements the processing of os-commands using a ProcessBuilder.
This is the core class of the im4java-library where all the magic takes place. It does add some overhead compared to a direct call of ProcessBuilder, but you gain additional features like piping and asynchronous execution.
Field Summary | |
---|---|
static int |
BUFFER_SIZE
Buffer size of process input-stream (used for reading the output (sic!) |
Constructor Summary | |
---|---|
protected |
ProcessStarter()
Constructor. |
Method Summary | |
---|---|
void |
addProcessEventListener(ProcessEventListener pListener)
Add a ProcessEventListener to this ProcessStarter. |
void |
addProcessListener(ProcessListener pProcessListener)
Deprecated. use addProcessEventListener(org.im4java.process.ProcessEventListener) instead |
protected void |
finished(java.lang.Exception pException)
Post-processing after the process has terminated with an exception. |
protected void |
finished(int pReturnCode)
Post-processing after the process has terminated. |
static java.lang.String |
getGlobalSearchPath()
Query the global (static) search path. |
int |
getPID()
Query the process-id. |
protected ProcessTask |
getProcessTask(java.util.LinkedList<java.lang.String> pArgs)
Return a ProcessTask for future execution. |
java.lang.String |
getSearchPath()
Query the per object search path. |
boolean |
isAsyncMode()
Query the async-execution mode. |
void |
removeProcessEventListener(ProcessEventListener pListener)
Remove a ProcessEventListener from this ProcessStarter. |
protected int |
run(java.util.LinkedList<java.lang.String> pArgs)
Execute the command. |
java.lang.String |
searchForCmd(java.lang.String pCmd,
java.lang.String pPath)
Query the per object search path. |
void |
setAsyncMode(boolean pAsyncMode)
Set the async-execution mode. |
void |
setErrorConsumer(ErrorConsumer pErrorConsumer)
Set the ErrorConsumer for the stderr of the ProcessStarter. |
static void |
setGlobalSearchPath(java.lang.String pGlobalSearchPath)
Set the global (static) search path. |
void |
setInputProvider(InputProvider pInputProvider)
Set the InputProvider for the ProcessStarter (if used as a pipe). |
void |
setOutputConsumer(OutputConsumer pOutputConsumer)
Set the OutputConsumer for the ProcessStarter (if used as a pipe). |
void |
setPID(int pPID)
Set the process-id of this ProcessStarter. |
static void |
setPIDCounter(int pPID)
Set the process-id counter of the class. |
void |
setSearchPath(java.lang.String pSearchPath)
Set the per object search path. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BUFFER_SIZE
Constructor Detail |
---|
protected ProcessStarter()
Method Detail |
---|
public void setInputProvider(InputProvider pInputProvider)
public void setOutputConsumer(OutputConsumer pOutputConsumer)
public void setErrorConsumer(ErrorConsumer pErrorConsumer)
public void addProcessEventListener(ProcessEventListener pListener)
pListener
- the ProcessEventListener to addpublic void removeProcessEventListener(ProcessEventListener pListener)
pListener
- the ProcessEventListener to removepublic void addProcessListener(ProcessListener pProcessListener)
addProcessEventListener(org.im4java.process.ProcessEventListener)
instead
pProcessListener
- the ProcessListener to addprotected int run(java.util.LinkedList<java.lang.String> pArgs) throws java.io.IOException, java.lang.InterruptedException, java.lang.Exception
pArgs
- arguments for ProcessBuilder
java.io.IOException
java.lang.InterruptedException
java.lang.Exception
protected ProcessTask getProcessTask(java.util.LinkedList<java.lang.String> pArgs)
pArgs
- arguments for ProcessBuilderpublic void setAsyncMode(boolean pAsyncMode)
pAsyncMode
- the iAsyncMode to setpublic boolean isAsyncMode()
public static void setGlobalSearchPath(java.lang.String pGlobalSearchPath)
pGlobalSearchPath
- the global search pathpublic static java.lang.String getGlobalSearchPath()
public void setSearchPath(java.lang.String pSearchPath)
pSearchPath
- the search pathpublic java.lang.String getSearchPath()
public static void setPIDCounter(int pPID)
pPID
- the process-idpublic void setPID(int pPID)
pPID
- the process-idpublic int getPID()
protected void finished(int pReturnCode) throws java.lang.Exception
pReturnCode
- the return-code of the process
java.lang.Exception
protected void finished(java.lang.Exception pException) throws java.lang.Exception
Note that if this method throws an exception in asynchronous execution mode, the original exception is lost and not propagated to any ProcessEventListeners. Therefore, you should take care to fill in any exception and stack-trace information.
pException
- the exception of the process
java.lang.Exception
public java.lang.String searchForCmd(java.lang.String pCmd, java.lang.String pPath) throws java.io.IOException, java.io.FileNotFoundException
pCmd
- the command to search forpPath
- the search path
java.io.IOException
java.io.FileNotFoundException
|
The im4java Library, Version 1.4.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |