com.phoenix_int.aserver.util
Class PHXProcess

java.lang.Object
  extended by java.lang.Process
      extended by com.phoenix_int.aserver.util.PHXProcess
All Implemented Interfaces:
com.phoenix_int.aserver.util.IPHXStreamRegExListener

public class PHXProcess
extends java.lang.Process
implements com.phoenix_int.aserver.util.IPHXStreamRegExListener

This is a utility class that extends java.lang.Process with a system dependent process ID. This is combined with the phxspawn and phxps utilities to provide information on sub-processes in a semi-platform independent way.


Constructor Summary
PHXProcess(java.lang.Process p)
          Constructs a PHXProcess out of a regular process but does not provide extended functionality because the process ID will not be known.
PHXProcess(java.lang.Process p, boolean readPID, java.lang.String jobIdRegex, java.lang.String jobNodeRegex, com.phoenix_int.aserver.util.IPHXProcessJobInfoListener listener)
           
PHXProcess(java.lang.Process p, boolean readPID, java.lang.String jobIdRegex, java.lang.String jobNodeRegex, com.phoenix_int.aserver.util.IPHXProcessJobInfoListener listener, java.lang.String fname)
          Constructs a PHXProcess out of a process and optionally reads the PID of the sub-process.
 
Method Summary
 void destroy()
           
 int exitValue()
           
 java.io.InputStream getErrorStream()
           
 java.io.InputStream getInputStream()
           
 java.lang.String getJobID()
           
 java.lang.String getJobNode()
           
 java.io.OutputStream getOutputStream()
           
 java.lang.Process getProcess()
          Returns the java Process instance for this PHXProcess
 int getProcessID()
          Returns the platform dependent process ID associated with this process.
 java.lang.String getTempScriptFileName()
           
 PHXProcessInfo[] listProcesses()
          This function lists all the processes and sub-processes of this PHXProcess.
 boolean matchFound(int patNum, com.oroinc.text.regex.Pattern pat, java.lang.String line, com.oroinc.text.regex.MatchResult match)
           
 int waitFor()
           
 com.phoenix_int.aserver.util.PHXStreamRegExMonitor wrapErrorStream(com.phoenix_int.aserver.util.IPHXStreamRegExListener l)
           
 com.phoenix_int.aserver.util.PHXStreamRegExMonitor wrapInputStream(com.phoenix_int.aserver.util.IPHXStreamRegExListener l)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PHXProcess

public PHXProcess(java.lang.Process p,
                  boolean readPID,
                  java.lang.String jobIdRegex,
                  java.lang.String jobNodeRegex,
                  com.phoenix_int.aserver.util.IPHXProcessJobInfoListener listener,
                  java.lang.String fname)
Constructs a PHXProcess out of a process and optionally reads the PID of the sub-process. Typically you do not create instances of this class yourself, but use PHXRuntime.exec2() to generate instances.

Parameters:
readPID - If true, the PID of this process will be read off of the process's standard output. The pid should be a number and should be on the very first line of output all by itself.

PHXProcess

public PHXProcess(java.lang.Process p,
                  boolean readPID,
                  java.lang.String jobIdRegex,
                  java.lang.String jobNodeRegex,
                  com.phoenix_int.aserver.util.IPHXProcessJobInfoListener listener)

PHXProcess

public PHXProcess(java.lang.Process p)
Constructs a PHXProcess out of a regular process but does not provide extended functionality because the process ID will not be known. Use PHXRuntime to execute processes and automatically generate correct PHXProcess instances.

Method Detail

matchFound

public boolean matchFound(int patNum,
                          com.oroinc.text.regex.Pattern pat,
                          java.lang.String line,
                          com.oroinc.text.regex.MatchResult match)
Specified by:
matchFound in interface com.phoenix_int.aserver.util.IPHXStreamRegExListener

getJobID

public java.lang.String getJobID()

getJobNode

public java.lang.String getJobNode()

getProcess

public java.lang.Process getProcess()
Returns the java Process instance for this PHXProcess


getProcessID

public int getProcessID()
                 throws java.io.IOException
Returns the platform dependent process ID associated with this process. If there was any error reading the process ID, or there is no process ID, an exception explaining the problem will be thrown (every time you call this function).

Throws:
java.io.IOException

listProcesses

public PHXProcessInfo[] listProcesses()
                               throws java.io.IOException
This function lists all the processes and sub-processes of this PHXProcess. This is a suitable list to return from IPHXMonitorable.listProcesses()

Throws:
java.io.IOException

destroy

public void destroy()
Specified by:
destroy in class java.lang.Process

exitValue

public int exitValue()
Specified by:
exitValue in class java.lang.Process

waitFor

public int waitFor()
            throws java.lang.InterruptedException
Specified by:
waitFor in class java.lang.Process
Throws:
java.lang.InterruptedException

wrapInputStream

public com.phoenix_int.aserver.util.PHXStreamRegExMonitor wrapInputStream(com.phoenix_int.aserver.util.IPHXStreamRegExListener l)

wrapErrorStream

public com.phoenix_int.aserver.util.PHXStreamRegExMonitor wrapErrorStream(com.phoenix_int.aserver.util.IPHXStreamRegExListener l)

getInputStream

public java.io.InputStream getInputStream()
Specified by:
getInputStream in class java.lang.Process

getErrorStream

public java.io.InputStream getErrorStream()
Specified by:
getErrorStream in class java.lang.Process

getOutputStream

public java.io.OutputStream getOutputStream()
Specified by:
getOutputStream in class java.lang.Process

getTempScriptFileName

public java.lang.String getTempScriptFileName()