org.zeroturnaround.process
Class JavaProcess

java.lang.Object
  extended by org.zeroturnaround.process.AbstractProcess
      extended by org.zeroturnaround.process.JavaProcess
All Implemented Interfaces:
SystemProcess
Direct Known Subclasses:
Java8Process

public class JavaProcess
extends AbstractProcess

Wrapper for Process.


Field Summary
protected  Process process
          The wrapped process.
 
Fields inherited from class org.zeroturnaround.process.AbstractProcess
log
 
Constructor Summary
protected JavaProcess(Process process)
           
 
Method Summary
protected  boolean canDestroy(boolean forceful)
           
 void destroy(boolean forceful)
          Destroys the process handled by this killer either forcefully or gracefully according to the given option.
 String getDescription()
          Returns the description of the system process represented.
 Process getProcess()
          Returns the wrapped process.
protected  void invokeDestroy(boolean forceful)
           
 boolean isAlive()
          Tests whether this process is alive.
 void waitFor()
          Causes the current thread to wait, if necessary, until this process has terminated.
 
Methods inherited from class org.zeroturnaround.process.AbstractProcess
destroyForcefully, destroyGracefully, toString, waitFor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

process

protected final Process process
The wrapped process.

Constructor Detail

JavaProcess

protected JavaProcess(Process process)
Method Detail

getProcess

public Process getProcess()
Returns the wrapped process.

Returns:
the wrapped process.

getDescription

public String getDescription()
Description copied from class: AbstractProcess
Returns the description of the system process represented.

Specified by:
getDescription in class AbstractProcess
Returns:
the description of the system process represented.

isAlive

public boolean isAlive()
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.

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
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

canDestroy

protected boolean canDestroy(boolean forceful)
Returns:
true if invokeDestroy(boolean) is supported with the given forceful flag on the given system.

invokeDestroy

protected void invokeDestroy(boolean forceful)


Copyright © 2015 ZeroTurnaround. All rights reserved.