Class 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 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 API
        context - 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 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​(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
        Overrides:
        toString in class Object
        Returns:
        HTML string containing process environment info
      • 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 necessary
        subForNulls - 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 necessary
        subForBlanks - 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()