org.zeroturnaround.process
Class AndProcess

java.lang.Object
  extended by org.zeroturnaround.process.AbstractProcess
      extended by org.zeroturnaround.process.CompositeProcess
          extended by org.zeroturnaround.process.AndProcess
All Implemented Interfaces:
SystemProcess

public class AndProcess
extends CompositeProcess

Represents multiple processes.

It tries to kill all processes (invokes all child killers). If it fails to destroy any process it still tries to destroy other processes before actually throwing the initial error. isAlive() returns true if at least one of the processes is still alive. isAllAlive() returns true only if all processes are still alive.

If it has only one child it should act the same as this child alone.


Field Summary
 
Fields inherited from class org.zeroturnaround.process.CompositeProcess
children
 
Fields inherited from class org.zeroturnaround.process.AbstractProcess
log
 
Constructor Summary
AndProcess(List<? extends SystemProcess> children)
           
 
Method Summary
 void destroy(boolean forceful)
          Destroys the process handled by this killer either forcefully or gracefully according to the given option.
 boolean isAlive()
          Tests whether this process is alive.
 boolean isAllAlive()
           
 void waitFor()
          Causes the current thread to wait, if necessary, until this process has terminated.
 
Methods inherited from class org.zeroturnaround.process.CompositeProcess
getDescription, invokeDestroy, toString
 
Methods inherited from class org.zeroturnaround.process.AbstractProcess
destroyForcefully, destroyGracefully, waitFor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AndProcess

public AndProcess(List<? extends SystemProcess> children)
Method Detail

isAlive

public boolean isAlive()
                throws IOException,
                       InterruptedException
Description copied from interface: SystemProcess
Tests whether this process is alive.

This operation may also take some time to finish.

Returns:
true if this process is alive, false if it is finished or not found.
Throws:
IOException
InterruptedException

isAllAlive

public boolean isAllAlive()
                   throws IOException,
                          InterruptedException
Throws:
IOException
InterruptedException

waitFor

public void waitFor()
             throws InterruptedException
Description copied from interface: SystemProcess
Causes the current thread to wait, if necessary, until this process has terminated.

This method returns immediately if the process has already terminated. If the process has not yet terminated, the calling thread will be blocked until the process exits.

Throws:
InterruptedException

destroy

public void destroy(boolean forceful)
             throws IOException,
                    InterruptedException
Description copied from class: AbstractProcess
Destroys the process handled by this killer either forcefully or gracefully according to the given option.

Note: The process may not terminate at all. i.e. isAlive() may return true for a any period after destroy() is called. This method may be chained to waitFor() if needed.

No error is thrown if the process was already terminated.

Specified by:
destroy in class AbstractProcess
Parameters:
forceful - true if the process must be destroyed forcefully (like kill -KILL), false if it must be destroyed gracefully (like kill -TERM).
Throws:
IOException
InterruptedException


Copyright © 2015 ZeroTurnaround. All rights reserved.