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 [[email protected]]
-
-
Field Summary
Fields Modifier and Type Field Description protected String
command
command to be invokedprotected int
debug
the debugging detail level for this instance.protected Hashtable<String,String>
env
derived process environmentprotected String
pathInfo
pathInfo for the current requestprotected boolean
valid
whether or not this object is valid or notprotected File
workingDirectory
process' 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 String
blanksToString(String couldBeBlank, String subForBlanks)
Converts blank strings to another stringprotected boolean
deriveProcessEnvironment(jakarta.servlet.http.HttpServletRequest req)
Constructs the Process environment to be supplied to the invoked process.String
getCommand()
Gets derived command stringjakarta.servlet.ServletContext
getContext()
String
getContextPath()
Hashtable<String,String>
getEnvironment()
Gets process' environmentString
getServletPath()
String
getWebAppRootDir()
Gets the root directory of the web application to which this process\ belongsFile
getWorkingDirectory()
Gets this process' derived working directoryboolean
isValid()
Gets validity statusprotected void
log(String s)
protected String
nullsToBlanks(String s)
Converts null strings to blank strings ("")protected String
nullsToString(String couldBeNull, String subForNulls)
Converts null strings to another stringprotected String
setCommand(String command)
Sets the desired command stringHashtable<String,String>
setEnvironment(Hashtable<String,String> env)
Sets process' environmentprotected void
setupFromContext(jakarta.servlet.ServletContext context)
Uses the ServletContext to set some process variablesprotected void
setupFromRequest(jakarta.servlet.http.HttpServletRequest req)
Uses the HttpServletRequest to set most process variablesString
toString()
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
null
or 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()
-
-