com.plumtree.openfoundation.util
Class XPProcess

java.lang.Object
  extended bycom.plumtree.openfoundation.util.XPProcess

public class XPProcess
extends java.lang.Object

Wraps a local subprocess. To do: allow capturing of output.

Author:
JeffM

Constructor Summary
XPProcess(java.lang.Process process)
          Construct an XPProcess from the platform-local equivalent.
 
Method Summary
 void Destroy()
          Stop the process.
 int GetReturnValue()
          Return the external process's return value, if available.
 boolean HasExited()
          Return true if the process has a valid return value available.
static XPProcess Start(java.lang.String processName)
          Start-without-args creation method.
static XPProcess Start(java.lang.String processName, java.lang.String arguments)
          Initialize a Java Process object and wrap it in an XPProcess.
static XPProcess Start(java.lang.String processName, java.lang.String arguments, XPWriter outputDrain, XPWriter errorDrain)
          Initialize a Java Process object and wrap it in an XPProcess, providing one or two XPWriter instances to drain its standard output and/or standard error output.
 void WaitForExit()
          Exposes java.lang.Process.waitFor().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPProcess

public XPProcess(java.lang.Process process)
Construct an XPProcess from the platform-local equivalent.

Parameters:
process - The OutputStream of SubProcess.
Method Detail

Start

public static XPProcess Start(java.lang.String processName)
Start-without-args creation method. Chained to general case (start-with-args).

Parameters:
processName - a String
Returns:
a XPProcess object

Start

public static XPProcess Start(java.lang.String processName,
                              java.lang.String arguments)
Initialize a Java Process object and wrap it in an XPProcess. Per the javadoc for java.lang.process, it is important to redirect I/O to prevent the subprocess from hanging.
Start-with-args creation method.

Parameters:
processName - a String
arguments - a String
Returns:
a XPProcess object

Start

public static XPProcess Start(java.lang.String processName,
                              java.lang.String arguments,
                              XPWriter outputDrain,
                              XPWriter errorDrain)
Initialize a Java Process object and wrap it in an XPProcess, providing one or two XPWriter instances to drain its standard output and/or standard error output. Supply a "null" argument to discard either output stream. Per the javadoc for java.lang.process, it is important to redirect I/O to prevent the subprocess from hanging.
Start-with-args creation method.

Parameters:
processName - a String
arguments - a String
outputDrain - a XPWriter object
errorDrain - a XPWriter object
Returns:
a XPProcess object

Destroy

public void Destroy()
Stop the process.


GetReturnValue

public int GetReturnValue()
Return the external process's return value, if available. If not, throw XPIllegalStateException.

Returns:
the external process's return value.
Throws:
XPIllegalStateException - if process has not exited.

HasExited

public boolean HasExited()
Return true if the process has a valid return value available.

Returns:
returns boolean if process has exited or not.

WaitForExit

public void WaitForExit()
Exposes java.lang.Process.waitFor().



Copyright 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.