org.apache.catalina.util
Class ProcessEnvironment

java.lang.Object
  extended byorg.apache.catalina.util.ProcessEnvironment
Direct Known Subclasses:
CGIProcessEnvironment

public class ProcessEnvironment
extends java.lang.Object

Encapsulates the Process environment and rules to derive that environment from the servlet container and request information.

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

Field Summary
protected  java.lang.String command
          command to be invoked
protected  int debug
          the debugging detail level for this instance.
protected  java.util.Hashtable env
          derived process environment
protected  java.lang.String pathInfo
          pathInfo for the current request
protected  boolean valid
          whether or not this object is valid or not
protected  java.io.File workingDirectory
          process' desired working directory
 
Constructor Summary
ProcessEnvironment(javax.servlet.http.HttpServletRequest req, javax.servlet.ServletContext context)
          Creates a ProcessEnvironment and derives the necessary environment, working directory, command, etc.
ProcessEnvironment(javax.servlet.http.HttpServletRequest req, javax.servlet.ServletContext context, int debug)
          Creates a ProcessEnvironment and derives the necessary environment, working directory, command, etc.
 
Method Summary
protected  java.lang.String blanksToString(java.lang.String couldBeBlank, java.lang.String subForBlanks)
          Converts blank strings to another string
protected  boolean deriveProcessEnvironment(javax.servlet.http.HttpServletRequest req)
          Constructs the Process environment to be supplied to the invoked process.
 java.lang.String getCommand()
          Gets derived command string
 javax.servlet.ServletContext getContext()
           
 java.lang.String getContextPath()
           
 java.util.Hashtable getEnvironment()
          Gets process' environment
 java.lang.String getServletPath()
           
 java.lang.String getWebAppRootDir()
          Gets the root directory of the web application to which this process\ belongs
 java.io.File getWorkingDirectory()
          Gets this process' derived working directory
 boolean isValid()
          Gets validity status
protected  void log(java.lang.String s)
           
protected  java.lang.String nullsToBlanks(java.lang.String s)
          Converts null strings to blank strings ("")
protected  java.lang.String nullsToString(java.lang.String couldBeNull, java.lang.String subForNulls)
          Converts null strings to another string
protected  java.lang.String setCommand(java.lang.String command)
          Sets the desired command string
 java.util.Hashtable setEnvironment(java.util.Hashtable env)
          Sets process' environment
protected  void setupFromContext(javax.servlet.ServletContext context)
          Uses the ServletContext to set some process variables
protected  void setupFromRequest(javax.servlet.http.HttpServletRequest req)
          Uses the HttpServletRequest to set most process variables
 java.lang.String toString()
          Print important process environment information in an easy-to-read HTML table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pathInfo

protected java.lang.String pathInfo
pathInfo for the current request


env

protected java.util.Hashtable env
derived process environment


command

protected java.lang.String command
command to be invoked


valid

protected boolean valid
whether or not this object is valid or not


debug

protected int debug
the debugging detail level for this instance.


workingDirectory

protected java.io.File workingDirectory
process' desired working directory

Constructor Detail

ProcessEnvironment

public ProcessEnvironment(javax.servlet.http.HttpServletRequest req,
                          javax.servlet.ServletContext context)
Creates a ProcessEnvironment and derives the necessary environment, working directory, command, etc.

Parameters:
req - HttpServletRequest for information provided by the Servlet API
context - ServletContext for information provided by the Servlet API

ProcessEnvironment

public ProcessEnvironment(javax.servlet.http.HttpServletRequest req,
                          javax.servlet.ServletContext context,
                          int debug)
Creates a ProcessEnvironment and derives the necessary environment, working directory, command, etc.

Parameters:
req - HttpServletRequest for information provided by the Servlet API
context - ServletContext for information provided by the Servlet API
debug - int debug level (0 == none, 4 == medium, 6 == lots)
Method Detail

setupFromContext

protected void setupFromContext(javax.servlet.ServletContext context)
Uses the ServletContext to set some process variables

Parameters:
context - ServletContext for information provided by the Servlet API

setupFromRequest

protected void setupFromRequest(javax.servlet.http.HttpServletRequest req)
Uses the HttpServletRequest to set most process variables

Parameters:
req - HttpServletRequest for information provided by the Servlet API

toString

public java.lang.String toString()
Print important process environment information in an easy-to-read HTML table

Returns:
HTML string containing process environment info

getCommand

public java.lang.String getCommand()
Gets derived command string

Returns:
command string

setCommand

protected java.lang.String setCommand(java.lang.String command)
Sets the desired command string

Returns:
command string

getWorkingDirectory

public java.io.File getWorkingDirectory()
Gets this process' derived working directory

Returns:
working directory

getEnvironment

public java.util.Hashtable getEnvironment()
Gets process' environment

Returns:
process' environment

setEnvironment

public java.util.Hashtable setEnvironment(java.util.Hashtable env)
Sets process' environment

Returns:
Hashtable to which the process' environment was set

isValid

public boolean isValid()
Gets validity status

Returns:
true if this environment is valid, false otherwise

nullsToBlanks

protected java.lang.String nullsToBlanks(java.lang.String s)
Converts null strings to blank strings ("")

Returns:
a non-null string, either the original or the empty string ("") if the original was null

nullsToString

protected java.lang.String nullsToString(java.lang.String couldBeNull,
                                         java.lang.String subForNulls)
Converts null strings to another string

Returns:
a non-null string, either the original or the substitute string if the original was null

blanksToString

protected java.lang.String blanksToString(java.lang.String couldBeBlank,
                                          java.lang.String subForBlanks)
Converts blank strings to another string

Returns:
a non-null string, either the original or the substitute string if the original was null or empty ("")

log

protected void log(java.lang.String s)

deriveProcessEnvironment

protected boolean deriveProcessEnvironment(javax.servlet.http.HttpServletRequest req)
Constructs the Process environment to be supplied to the invoked process. Defines an environment no environment variables.

Should be overriden by subclasses to perform useful setup.

Returns:
true if environment was set OK, false if there was a problem and no environment was set

getWebAppRootDir

public java.lang.String getWebAppRootDir()
Gets the root directory of the web application to which this process\ belongs

Returns:
root directory

getContextPath

public java.lang.String getContextPath()

getContext

public javax.servlet.ServletContext getContext()

getServletPath

public java.lang.String getServletPath()


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