Package org.apache.catalina.util
Class ProcessEnvironment
- java.lang.Object
-
- org.apache.catalina.util.ProcessEnvironment
-
public class ProcessEnvironment extends 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: 2006/03/12 01:27:08 $
- Author:
- Martin Dengler [root@martindengler.com]
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringcommandcommand to be invokedprotected intdebugthe debugging detail level for this instance.protected Hashtable<String,String>envderived process environmentprotected StringpathInfopathInfo for the current requestprotected booleanvalidwhether or not this object is valid or notprotected FileworkingDirectoryprocess' desired working directory
-
Constructor Summary
Constructors Constructor Description ProcessEnvironment(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.ServletContext context)Creates a ProcessEnvironment and derives the necessary environment, working directory, command, etc.ProcessEnvironment(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.ServletContext context, int debug)Creates a ProcessEnvironment and derives the necessary environment, working directory, command, etc.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringblanksToString(String couldBeBlank, String subForBlanks)Converts blank strings to another stringprotected booleanderiveProcessEnvironment(jakarta.servlet.http.HttpServletRequest req)Constructs the Process environment to be supplied to the invoked process.StringgetCommand()Gets derived command stringjakarta.servlet.ServletContextgetContext()StringgetContextPath()Hashtable<String,String>getEnvironment()Gets process' environmentStringgetServletPath()StringgetWebAppRootDir()Gets the root directory of the web application to which this process\ belongsFilegetWorkingDirectory()Gets this process' derived working directorybooleanisValid()Gets validity statusprotected voidlog(String s)protected StringnullsToBlanks(String s)Converts null strings to blank strings ("")protected StringnullsToString(String couldBeNull, String subForNulls)Converts null strings to another stringprotected StringsetCommand(String command)Sets the desired command stringHashtable<String,String>setEnvironment(Hashtable<String,String> env)Sets process' environmentprotected voidsetupFromContext(jakarta.servlet.ServletContext context)Uses the ServletContext to set some process variablesprotected voidsetupFromRequest(jakarta.servlet.http.HttpServletRequest req)Uses the HttpServletRequest to set most process variablesStringtoString()Print important process environment information in an easy-to-read HTML table
-
-
-
Field Detail
-
pathInfo
protected String pathInfo
pathInfo for the current request
-
command
protected 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 File workingDirectory
process' desired working directory
-
-
Constructor Detail
-
ProcessEnvironment
public ProcessEnvironment(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.ServletContext context)Creates a ProcessEnvironment and derives the necessary environment, working directory, command, etc.- Parameters:
req- HttpServletRequest for information provided by the Servlet APIcontext- ServletContext for information provided by the Servlet API
-
ProcessEnvironment
public ProcessEnvironment(jakarta.servlet.http.HttpServletRequest req, jakarta.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 APIcontext- ServletContext for information provided by the Servlet APIdebug- int debug level (0 == none, 4 == medium, 6 == lots)
-
-
Method Detail
-
setupFromContext
protected void setupFromContext(jakarta.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(jakarta.servlet.http.HttpServletRequest req)
Uses the HttpServletRequest to set most process variables- Parameters:
req- HttpServletRequest for information provided by the Servlet API
-
toString
public String toString()
Print important process environment information in an easy-to-read HTML table
-
getCommand
public String getCommand()
Gets derived command string- Returns:
- command string
-
setCommand
protected String setCommand(String command)
Sets the desired command string- Parameters:
command- string as desired- Returns:
- command string
-
getWorkingDirectory
public File getWorkingDirectory()
Gets this process' derived working directory- Returns:
- working directory
-
getEnvironment
public Hashtable<String,String> getEnvironment()
Gets process' environment- Returns:
- process' environment
-
setEnvironment
public Hashtable<String,String> setEnvironment(Hashtable<String,String> env)
Sets process' environment- Parameters:
env- 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 String nullsToBlanks(String s)
Converts null strings to blank strings ("")- Parameters:
s- string to be converted if necessary- Returns:
- a non-null string, either the original or the empty string
("") if the original was
null
-
nullsToString
protected String nullsToString(String couldBeNull, String subForNulls)
Converts null strings to another string- Parameters:
couldBeNull- string to be converted if necessarysubForNulls- string to return instead of a null string- Returns:
- a non-null string, either the original or the substitute
string if the original was
null
-
blanksToString
protected String blanksToString(String couldBeBlank, String subForBlanks)
Converts blank strings to another string- Parameters:
couldBeBlank- string to be converted if necessarysubForBlanks- string to return instead of a blank string- Returns:
- a non-null string, either the original or the substitute
string if the original was
nullor empty ("")
-
log
protected void log(String s)
-
deriveProcessEnvironment
protected boolean deriveProcessEnvironment(jakarta.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.
- Parameters:
req- HttpServletRequest request associated with the Process' invocation- Returns:
- true if environment was set OK, false if there was a problem and no environment was set
-
getWebAppRootDir
public String getWebAppRootDir()
Gets the root directory of the web application to which this process\ belongs- Returns:
- root directory
-
getContextPath
public String getContextPath()
-
getContext
public jakarta.servlet.ServletContext getContext()
-
getServletPath
public String getServletPath()
-
-