org.apache.catalina.util
Class ProcessHelper

java.lang.Object
  extended byorg.apache.catalina.util.ProcessHelper

public class ProcessHelper
extends java.lang.Object

Encapsulates the knowledge of how to run a CGI script, given the script's desired environment and (optionally) input/output streams

Exposes a run method used to actually invoke the CGI.

The CGI environment and settings are derived from the information passed to the constuctor.

The input and output streams can be set by the setInput and setResponse methods, respectively.

Version:
$Revision: 1.4 $, $Date: 2004/08/26 21:43:16 $
Author:
Martin Dengler [root@martindengler.com]

Constructor Summary
ProcessHelper(java.lang.String command, java.util.Hashtable env, java.io.File wd, java.util.Hashtable params)
          Creates a ProcessHelper and initializes its environment, working directory, and query parameters.
 
Method Summary
 int getIClientInputTimeout()
           
protected  java.lang.String getPostInput(java.util.Hashtable params)
          Gets a string for input to a POST cgi script
 boolean isReady()
          Gets ready status
 void run()
          Executes a process script with the desired environment, current working directory, and input/output streams
 void setIClientInputTimeout(int iClientInputTimeout)
           
 void setInput(java.io.InputStream stdin)
          Sets standard input to be passed on to the invoked cgi script
 void setResponse(javax.servlet.http.HttpServletResponse response)
          Sets HttpServletResponse object used to set headers and send output to
protected  void updateReadyStatus()
          Checks & sets ready status
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessHelper

public ProcessHelper(java.lang.String command,
                     java.util.Hashtable env,
                     java.io.File wd,
                     java.util.Hashtable params)
Creates a ProcessHelper and initializes its environment, working directory, and query parameters.
Input/output streams (optional) are set using the setInput and setResponse methods, respectively.

Parameters:
command - string full path to command to be executed
env - Hashtable with the desired script environment
wd - File with the script's desired working directory
params - Hashtable with the script's query parameters
Method Detail

updateReadyStatus

protected void updateReadyStatus()
Checks & sets ready status


isReady

public boolean isReady()
Gets ready status

Returns:
false if not ready (run will throw an exception), true if ready

setResponse

public void setResponse(javax.servlet.http.HttpServletResponse response)
Sets HttpServletResponse object used to set headers and send output to

Parameters:
response - HttpServletResponse to be used

setInput

public void setInput(java.io.InputStream stdin)
Sets standard input to be passed on to the invoked cgi script

Parameters:
stdin - InputStream to be used

run

public void run()
         throws java.io.IOException
Executes a process script with the desired environment, current working directory, and input/output streams

This implements the following CGI specification recommedations:

For more information, see java.lang.Runtime#exec(String command, String[] envp, File dir)

Throws:
java.io.IOException - if problems during reading/writing occur

getPostInput

protected java.lang.String getPostInput(java.util.Hashtable params)
Gets a string for input to a POST cgi script

Parameters:
params - Hashtable of query parameters to be passed to the CGI script
Returns:
for use as input to the CGI script

getIClientInputTimeout

public int getIClientInputTimeout()

setIClientInputTimeout

public void setIClientInputTimeout(int iClientInputTimeout)


Copyright 2000-2002 Apache Software Foundation. All Rights Reserved.