com.Prominic.runtime
Class UnixProcess

java.lang.Object
  extended by com.Prominic.runtime.UnixProcess
All Implemented Interfaces:
java.lang.Runnable

public class UnixProcess
extends java.lang.Object
implements java.lang.Runnable

An unix process. It contains a lot of native methods. To used this class the libunixruntime.so must be in LD_LIBRARY_PATH. The class was tested on linux, aix and solaris machine Creation date: (8/13/2001 2:40:35 PM)


Field Summary
private  boolean canNotAllocateSharedMemory
           
private  boolean canNotExecute
           
private  boolean canNotMakeFork
           
private  int errorCode
           
private  int exitCode
           
private  int gid
           
private  java.util.Vector listeners
           
static int MAX_PROCESSES
           
private  java.lang.String[] param
           
private  int pid
           
private  boolean running
           
private  boolean setGidError
           
private  boolean setUidError
           
private  int signal
           
private  java.lang.String stderrfilename
           
private  java.lang.String stdinfilename
           
private  java.lang.String stdoutfilename
           
private  int uid
           
 
Constructor Summary
UnixProcess()
          Insert the method's description here.
UnixProcess(int uid, int gid, java.lang.String cmd)
          Create and start an unix process specified by command.
UnixProcess(int uid, int gid, java.lang.String[] cmd)
          Create and start an unix process specified by command.
UnixProcess(int uid, int gid, java.lang.String[] cmd, java.lang.String stdoutfilename, java.lang.String stderrfilename, java.lang.String stdinfilename)
          Create and start an unix process specified by command.
UnixProcess(int uid, int gid, java.lang.String cmd, java.lang.String stdoutfilename, java.lang.String stderrfilename, java.lang.String stdinfilename)
          Create and start an unix process specified by command.
UnixProcess(int uid, java.lang.String cmd)
          Create and start an unix process specified by command.
UnixProcess(int uid, java.lang.String[] cmd)
          Create and start an unix process specified by command.
UnixProcess(int uid, java.lang.String[] cmd, java.lang.String stdoutfilename, java.lang.String stderrfilename, java.lang.String stdinfilename)
          Create and start an unix process specified by command.
UnixProcess(int uid, java.lang.String cmd, java.lang.String stdoutfilename, java.lang.String stderrfilename, java.lang.String stdinfilename)
          Create and start an unix process specified by command.
UnixProcess(java.lang.String cmd)
          Create and start an unix process specified by command.
UnixProcess(java.lang.String[] cmd)
          Create and start an unix process specified by command.
UnixProcess(java.lang.String[] cmd, java.lang.String stdoutfilename, java.lang.String stderrfilename, java.lang.String stdinfilename)
          Create and start an unix process specified by command.
UnixProcess(java.lang.String cmd, java.lang.String stdoutfilename, java.lang.String stderrfilename, java.lang.String stdinfilename)
          Create and start an unix process specified by command.
 
Method Summary
 void addProcessEventListener(ProcessEventListener listener)
          Insert the method's description here.
 void destroy()
          Stoped the process.
protected  void dispatch(ProcessEvent event)
          Insert the method's description here.
private  int exec(int uid, int gid, java.lang.String[] cmd, java.lang.String stdoutfilename, java.lang.String stderrfilename, java.lang.String stdinfilename)
          Starts unix process specified by command.
 int exitValue()
          Returns exit code if the process is stoped Creation date: (8/19/2001 2:42:38 PM)
 void finalize()
          Insert the method's description here.
protected  java.util.Vector getListeners()
          Insert the method's description here.
protected  int getPid()
          Insert the method's description here.
 java.lang.String getStderrFilename()
          Returns the process error file name Creation date: (8/19/2001 2:42:38 PM)
 java.lang.String getStdinFilename()
          Returns the process input file name Creation date: (8/19/2001 2:42:38 PM)
 java.lang.String getStdoutFilename()
          Returns the process ouput file name Creation date: (8/19/2001 2:42:38 PM)
 boolean isRunning()
          Tells if the process is running or no.
private  void processDied(int status)
          Insert the method's description here.
private static void processDied(int pid, int status)
          Insert the method's description here.
 void removeProcessEventListener(ProcessEventListener listener)
          Insert the method's description here.
 void run()
          The thread start method.
protected  void setListeners(java.util.Vector newListeners)
          Insert the method's description here.
 void waitFor()
          Insert the method's description here.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_PROCESSES

public static final int MAX_PROCESSES
See Also:
Constant Field Values

running

private boolean running

exitCode

private int exitCode

canNotExecute

private boolean canNotExecute

canNotMakeFork

private boolean canNotMakeFork

canNotAllocateSharedMemory

private boolean canNotAllocateSharedMemory

setUidError

private boolean setUidError

setGidError

private boolean setGidError

errorCode

private int errorCode

pid

private int pid

signal

private int signal

param

private java.lang.String[] param

stdoutfilename

private java.lang.String stdoutfilename

stderrfilename

private java.lang.String stderrfilename

stdinfilename

private java.lang.String stdinfilename

gid

private int gid

uid

private int uid

listeners

private java.util.Vector listeners
Constructor Detail

UnixProcess

public UnixProcess()
Insert the method's description here. Creation date: (8/31/2001 2:17:32 PM)


UnixProcess

public UnixProcess(java.lang.String[] cmd)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
cmd - java.lang.String[] The command

UnixProcess

public UnixProcess(java.lang.String[] cmd,
                   java.lang.String stdoutfilename,
                   java.lang.String stderrfilename,
                   java.lang.String stdinfilename)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
cmd - java.lang.String[] The command
stdoutfilename - java.lang.String The output filename for the process
stderrfilename - java.lang.String The error filename for the process
stdinfilename - java.lang.String The input filename for the process

UnixProcess

public UnixProcess(int uid,
                   java.lang.String[] cmd)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
uid - int The process will be start by the user specified by its uid
cmd - java.lang.String[] The command

UnixProcess

public UnixProcess(int uid,
                   java.lang.String[] cmd,
                   java.lang.String stdoutfilename,
                   java.lang.String stderrfilename,
                   java.lang.String stdinfilename)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
uid - int The process will be start by the user specified by its uid
cmd - java.lang.String[] The command
stdoutfilename - java.lang.String The output filename for the process
stderrfilename - java.lang.String The error filename for the process
stdinfilename - java.lang.String The input filename for the process

UnixProcess

public UnixProcess(int uid,
                   int gid,
                   java.lang.String[] cmd)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
uid - int The process will be start by the user specified by its uid
gid - int The process will be start by the group specified by its gid
cmd - java.lang.String[] The command

UnixProcess

public UnixProcess(int uid,
                   int gid,
                   java.lang.String[] cmd,
                   java.lang.String stdoutfilename,
                   java.lang.String stderrfilename,
                   java.lang.String stdinfilename)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
uid - int The process will be start by the user specified by its uid
gid - int The process will be start by the group specified by its gid
cmd - java.lang.String[] The command
stdoutfilename - java.lang.String The output filename for the process
stderrfilename - java.lang.String The error filename for the process
stdinfilename - java.lang.String The input filename for the process

UnixProcess

public UnixProcess(int uid,
                   int gid,
                   java.lang.String cmd)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
uid - int The process will be start by the user specified by its uid
gid - int The process will be start by the group specified by its gid
cmd - java.lang.String The command

UnixProcess

public UnixProcess(int uid,
                   int gid,
                   java.lang.String cmd,
                   java.lang.String stdoutfilename,
                   java.lang.String stderrfilename,
                   java.lang.String stdinfilename)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
uid - int The process will be start by the user specified by its uid
gid - int The process will be start by the group specified by its gid
cmd - java.lang.String The command
stdoutfilename - java.lang.String The output filename for the process
stderrfilename - java.lang.String The error filename for the process
stdinfilename - java.lang.String The input filename for the process

UnixProcess

public UnixProcess(int uid,
                   java.lang.String cmd)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
uid - int The process will be start by the user specified by its uid
cmd - java.lang.String The command

UnixProcess

public UnixProcess(int uid,
                   java.lang.String cmd,
                   java.lang.String stdoutfilename,
                   java.lang.String stderrfilename,
                   java.lang.String stdinfilename)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
uid - int The process will be start by the user specified by its uid
cmd - java.lang.String The command
stdoutfilename - java.lang.String The output filename for the process
stderrfilename - java.lang.String The error filename for the process
stdinfilename - java.lang.String The input filename for the process

UnixProcess

public UnixProcess(java.lang.String cmd)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
cmd - java.lang.String The command

UnixProcess

public UnixProcess(java.lang.String cmd,
                   java.lang.String stdoutfilename,
                   java.lang.String stderrfilename,
                   java.lang.String stdinfilename)
Create and start an unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
cmd - java.lang.String The command
stdoutfilename - java.lang.String The output filename for the process
stderrfilename - java.lang.String The error filename for the process
stdinfilename - java.lang.String The input filename for the process
Method Detail

addProcessEventListener

public void addProcessEventListener(ProcessEventListener listener)
                             throws java.lang.IllegalThreadStateException
Insert the method's description here. Creation date: (10/31/2001 7:19:36 PM)

Parameters:
listener - com.Prominic.runtime.ProcessEventListener
Throws:
java.lang.IllegalThreadStateException - The exception description.

destroy

public void destroy()
Stoped the process. If the process is not runnig the method returns imediatly. Creation date: (8/21/2001 1:11:40 PM)


dispatch

protected void dispatch(ProcessEvent event)
Insert the method's description here. Creation date: (10/31/2001 7:21:03 PM)

Parameters:
event - com.Prominic.runtime.ProcessEvent

exec

private int exec(int uid,
                 int gid,
                 java.lang.String[] cmd,
                 java.lang.String stdoutfilename,
                 java.lang.String stderrfilename,
                 java.lang.String stdinfilename)
Starts unix process specified by command. Creation date: (8/21/2001 1:11:40 PM)

Parameters:
uid - int The process will be start by the user specified by its uid
gid - int The process will be start by the group specified by its gid
cmd - java.lang.String[] The command
stdoutfilename - java.lang.String The output filename for the process
stderrfilename - java.lang.String The error filename for the process
stdinfilename - java.lang.String The input filename for the process

exitValue

public int exitValue()
              throws java.lang.IllegalThreadStateException,
                     java.lang.InterruptedException,
                     java.io.IOException,
                     java.io.FileNotFoundException,
                     java.lang.SecurityException,
                     UnixRuntimeException
Returns exit code if the process is stoped Creation date: (8/19/2001 2:42:38 PM)

Returns:
int The exit code of the unix process
Throws:
java.lang.IllegalThreadStateException
java.lang.InterruptedException
java.io.IOException
java.io.FileNotFoundException
java.lang.SecurityException
UnixRuntimeException

finalize

public void finalize()
              throws java.lang.Throwable
Insert the method's description here. Creation date: (8/28/2001 1:15:07 PM)

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - The exception description.

getListeners

protected java.util.Vector getListeners()
Insert the method's description here. Creation date: (10/31/2001 7:19:09 PM)

Returns:
java.util.Vector

getPid

protected int getPid()
Insert the method's description here. Creation date: (8/31/2001 1:40:00 PM)

Returns:
int

getStderrFilename

public java.lang.String getStderrFilename()
Returns the process error file name Creation date: (8/19/2001 2:42:38 PM)

Returns:
java.lang.String The process' error file name

getStdinFilename

public java.lang.String getStdinFilename()
Returns the process input file name Creation date: (8/19/2001 2:42:38 PM)

Returns:
java.lang.String The process' input file name

getStdoutFilename

public java.lang.String getStdoutFilename()
Returns the process ouput file name Creation date: (8/19/2001 2:42:38 PM)

Returns:
java.lang.String The process' ouput file name

isRunning

public boolean isRunning()
Tells if the process is running or no. Creation date: (8/19/2001 2:42:38 PM)

Returns:
boolean True if the process is running, false else.

processDied

private void processDied(int status)
Insert the method's description here. Creation date: (8/29/2001 2:42:35 PM)

Parameters:
status - int

processDied

private static void processDied(int pid,
                                int status)
Insert the method's description here. Creation date: (8/29/2001 2:42:35 PM)

Parameters:
status - int

removeProcessEventListener

public void removeProcessEventListener(ProcessEventListener listener)
Insert the method's description here. Creation date: (10/31/2001 7:20:23 PM)

Parameters:
listener - com.Prominic.runtime.ProcessEventListener

run

public void run()
The thread start method. It starts the unix process using exec method. Creation date: (8/19/2001 2:42:38 PM)

Specified by:
run in interface java.lang.Runnable

setListeners

protected void setListeners(java.util.Vector newListeners)
Insert the method's description here. Creation date: (10/31/2001 7:19:09 PM)

Parameters:
newListeners - java.util.Vector

waitFor

public void waitFor()
             throws java.lang.InterruptedException
Insert the method's description here. Creation date: (8/31/2001 12:49:27 PM)

Throws:
java.lang.InterruptedException - The exception description.