Class AbstractProcess
- All Implemented Interfaces:
SystemProcess
- Direct Known Subclasses:
CompositeProcess,JavaProcess,PollingProcess
SystemProcess.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voiddestroy(boolean forceful) Destroys the process either forcefully or gracefully according to the given option.Kills this process.Terminates this process.protected abstract StringtoString()booleanCauses the current thread to wait, if necessary, until the process handled by this killer has terminated, or the specified timeout is reached.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.zeroturnaround.process.SystemProcess
isAlive, waitFor
-
Field Details
-
log
protected final org.slf4j.Logger log
-
-
Constructor Details
-
AbstractProcess
public AbstractProcess()
-
-
Method Details
-
toString
-
getDescription
- Returns:
- the description of the system process.
-
waitFor
Causes the current thread to wait, if necessary, until the process handled by this killer has terminated, or the specified timeout is reached.If the process has already terminated then this method returns immediately with the value
true. If the process has not terminated and the timeout value is less than, or equal to, zero, then this method returns immediately with the valuefalse.- Specified by:
waitForin interfaceSystemProcess- Parameters:
timeout- the maximum time to waitunit- the time unit of the timeout argument- Returns:
trueif the process has exited andfalseif the timeout is reached before the process has exited.- Throws:
InterruptedException- if interrupted.
-
destroyGracefully
Terminates this process. The process is gracefully terminated (likekill -TERMdoes).Note: The process may not terminate at all. i.e.
isAlive()may returntruefor a any period afterdestroyGracefully()is called. This method may be chained towaitFor()if needed.No error is thrown if the process was already terminated.
- Specified by:
destroyGracefullyin interfaceSystemProcess- Returns:
- this process object.
- Throws:
UnsupportedOperationException- if this implementation is unable to gracefully terminate the process.IOException- on IO error.InterruptedException- if interrupted.
-
destroyForcefully
Kills this process. The process is forcibly terminated (likekill -KILLdoes).Note: The process may not terminate immediately. i.e.
isAlive()may returntruefor a brief period afterdestroyForcefully()is called. This method may be chained towaitFor()if needed.No error is thrown if the process was already terminated.
- Specified by:
destroyForcefullyin interfaceSystemProcess- Returns:
- this process object.
- Throws:
UnsupportedOperationException- if this implementation is unable to gracefully terminate the process.IOException- on IO error.InterruptedException- if interrupted.
-
destroy
Destroys the process either forcefully or gracefully according to the given option.Note: The process may not terminate at all. i.e.
isAlive()may returntruefor a any period afterdestroy()is called. This method may be chained towaitFor()if needed.No error is thrown if the process was already terminated.
- Parameters:
forceful-trueif the process must be destroyed forcefully (likekill -KILL),falseif it must be destroyed gracefully (likekill -TERM).- Throws:
UnsupportedOperationException- if this implementation is unable to terminate the process with thisforcefulvalue.IOException- on IO error.InterruptedException- if interrupted.
-