Package org.apache.commons.exec
Class ShutdownHookProcessDestroyer
java.lang.Object
org.apache.commons.exec.ShutdownHookProcessDestroyer
- All Implemented Interfaces:
- Runnable,- ProcessDestroyer
Destroys all registered 
Processes when the VM exits.- 
Constructor SummaryConstructorsConstructorDescriptionConstructs aProcessDestroyerand obtainsRuntime.addShutdownHook()andRuntime.removeShutdownHook()through reflection.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanReturnstrueif the specifiedProcesswas successfully added to the list of processes to destroy upon VM exit.booleanTests whether or not the ProcessDestroyer is registered as shutdown hook.booleanisEmpty()Tests emptiness (size == 0).booleanReturnstrueif the specifiedProcesswas successfully removed from the list of processes to destroy upon VM exit.voidrun()Invoked by the VM when it is exiting.intsize()Returns the number of registered processes.
- 
Constructor Details- 
ShutdownHookProcessDestroyerpublic ShutdownHookProcessDestroyer()Constructs aProcessDestroyerand obtainsRuntime.addShutdownHook()andRuntime.removeShutdownHook()through reflection. The ProcessDestroyer manages a list of processes to be destroyed when the VM exits. If a process is added when the list is empty, thisProcessDestroyeris registered as a shutdown hook. If removing a process results in an empty list, theProcessDestroyeris removed as a shutdown hook.
 
- 
- 
Method Details- 
addReturnstrueif the specifiedProcesswas successfully added to the list of processes to destroy upon VM exit.- Specified by:
- addin interface- ProcessDestroyer
- Parameters:
- process- the process to add.
- Returns:
- trueif the specified- Processwas successfully added.
 
- 
isAddedAsShutdownHookTests whether or not the ProcessDestroyer is registered as shutdown hook.- Returns:
- true if this is currently added as shutdown hook.
 
- 
isEmptyTests emptiness (size == 0).- Returns:
- Whether or not this is empty.
- Since:
- 1.4.0
 
- 
removeReturnstrueif the specifiedProcesswas successfully removed from the list of processes to destroy upon VM exit.- Specified by:
- removein interface- ProcessDestroyer
- Parameters:
- process- the process to remove.
- Returns:
- trueif the specified- Processwas successfully removed.
 
- 
runInvoked by the VM when it is exiting.
- 
sizeReturns the number of registered processes.- Specified by:
- sizein interface- ProcessDestroyer
- Returns:
- the number of register process.
 
 
-