Class StandardHost

  • All Implemented Interfaces:
    javax.management.MBeanRegistration, Container, Host, JmxEnabled, Lifecycle

    public class StandardHost
    extends ContainerBase
    implements Host
    Standard implementation of the Host interface. Each child container must be a Context implementation to process the requests directed to a particular web application.
    Author:
    Craig R. McClanahan, Remy Maucherat
    • Constructor Detail

      • StandardHost

        public StandardHost()
        Create a new StandardHost component with the default basic Valve.
    • Method Detail

      • getUndeployOldVersions

        public boolean getUndeployOldVersions()
        Specified by:
        getUndeployOldVersions in interface Host
        Returns:
        true of the Host is configured to automatically undeploy old versions of applications deployed using parallel deployment. This only takes effect is Host.getAutoDeploy() also returns true.
      • setUndeployOldVersions

        public void setUndeployOldVersions​(boolean undeployOldVersions)
        Description copied from interface: Host
        Set to true if the Host should automatically undeploy old versions of applications deployed using parallel deployment. This only takes effect if Host.getAutoDeploy() returns true.
        Specified by:
        setUndeployOldVersions in interface Host
        Parameters:
        undeployOldVersions - The new value for this flag
      • getStartStopExecutor

        public java.util.concurrent.ExecutorService getStartStopExecutor()
        Specified by:
        getStartStopExecutor in interface Host
        Returns:
        the executor that is used for starting and stopping contexts. This is primarily for use by components deploying contexts that want to do this in a multithreaded manner.
      • getAppBase

        public java.lang.String getAppBase()
        Specified by:
        getAppBase in interface Host
        Returns:
        the application root for this Host. This can be an absolute pathname, a relative pathname, or a URL.
      • getAppBaseFile

        public java.io.File getAppBaseFile()
        Specified by:
        getAppBaseFile in interface Host
        Returns:
        an absolute File for the appBase of this Host. The file will be canonical if possible. There is no guarantee that the appBase exists.
      • setAppBase

        public void setAppBase​(java.lang.String appBase)
        Description copied from interface: Host
        Set the application root for this Host. This can be an absolute pathname, a relative pathname, or a URL.
        Specified by:
        setAppBase in interface Host
        Parameters:
        appBase - The new application root
      • getLegacyAppBase

        public java.lang.String getLegacyAppBase()
        Specified by:
        getLegacyAppBase in interface Host
        Returns:
        the legacy (Java EE) application root for this Host. This can be an absolute pathname, a relative pathname, or a URL.
      • getLegacyAppBaseFile

        public java.io.File getLegacyAppBaseFile()
        Specified by:
        getLegacyAppBaseFile in interface Host
        Returns:
        an absolute File for the legacy (Java EE) appBase of this Host. The file will be canonical if possible. There is no guarantee that the appBase exists.
      • setLegacyAppBase

        public void setLegacyAppBase​(java.lang.String legacyAppBase)
        Description copied from interface: Host
        Set the legacy (Java EE) application root for this Host. This can be an absolute pathname, a relative pathname, or a URL.
        Specified by:
        setLegacyAppBase in interface Host
        Parameters:
        legacyAppBase - The new legacy application root
      • getXmlBase

        public java.lang.String getXmlBase()
        Specified by:
        getXmlBase in interface Host
        Returns:
        the XML root for this Host. This can be an absolute pathname or a relative pathname. If null, the base path defaults to ${catalina.base}/conf/<engine name>/<host name> directory
      • setXmlBase

        public void setXmlBase​(java.lang.String xmlBase)
        Description copied from interface: Host
        Set the Xml root for this Host. This can be an absolute pathname or a relative pathname. If null, the base path defaults to ${catalina.base}/conf/<engine name>/<host name> directory
        Specified by:
        setXmlBase in interface Host
        Parameters:
        xmlBase - The new XML root
      • getConfigBaseFile

        public java.io.File getConfigBaseFile()
        Specified by:
        getConfigBaseFile in interface Host
        Returns:
        a default configuration path of this Host. The file will be canonical if possible.
      • getCreateDirs

        public boolean getCreateDirs()
        Returns true if the Host will attempt to create directories for appBase and xmlBase unless they already exist.

        The default value for this implementation is true.

        Specified by:
        getCreateDirs in interface Host
        Returns:
        true if the Host will attempt to create directories
      • setCreateDirs

        public void setCreateDirs​(boolean createDirs)
        Description copied from interface: Host
        Should the Host attempt to create directories for xmlBase and appBase upon startup.
        Specified by:
        setCreateDirs in interface Host
        Parameters:
        createDirs - The new value for this flag
      • getAutoDeploy

        public boolean getAutoDeploy()

        The default value for this implementation is true.

        Specified by:
        getAutoDeploy in interface Host
        Returns:
        the value of the auto deploy flag. If true, it indicates that this host's child webapps should be discovered and automatically deployed dynamically.
      • setAutoDeploy

        public void setAutoDeploy​(boolean autoDeploy)
        Description copied from interface: Host
        Set the auto deploy flag value for this host.
        Specified by:
        setAutoDeploy in interface Host
        Parameters:
        autoDeploy - The new auto deploy flag
      • getConfigClass

        public java.lang.String getConfigClass()
        Specified by:
        getConfigClass in interface Host
        Returns:
        the Java class name of the context configuration class for new web applications.
      • setConfigClass

        public void setConfigClass​(java.lang.String configClass)
        Description copied from interface: Host
        Set the Java class name of the context configuration class for new web applications.
        Specified by:
        setConfigClass in interface Host
        Parameters:
        configClass - The new context configuration class
      • getContextClass

        public java.lang.String getContextClass()
        Returns:
        the Java class name of the Context implementation class for new web applications.
      • setContextClass

        public void setContextClass​(java.lang.String contextClass)
        Set the Java class name of the Context implementation class for new web applications.
        Parameters:
        contextClass - The new context implementation class
      • getDeployOnStartup

        public boolean getDeployOnStartup()

        The default value for this implementation is true.

        Specified by:
        getDeployOnStartup in interface Host
        Returns:
        the value of the deploy on startup flag. If true, it indicates that this host's child webapps should be discovered and automatically deployed.
      • setDeployOnStartup

        public void setDeployOnStartup​(boolean deployOnStartup)
        Description copied from interface: Host
        Set the deploy on startup flag value for this host.
        Specified by:
        setDeployOnStartup in interface Host
        Parameters:
        deployOnStartup - The new deploy on startup flag
      • isDeployXML

        public boolean isDeployXML()
        Returns:
        true if XML context descriptors should be deployed.
      • setDeployXML

        public void setDeployXML​(boolean deployXML)
        Deploy XML Context config files flag mutator.
        Parameters:
        deployXML - true if context descriptors should be deployed
      • isCopyXML

        public boolean isCopyXML()
        Returns:
        the copy XML config file flag for this component.
      • setCopyXML

        public void setCopyXML​(boolean copyXML)
        Set the copy XML config file flag for this component.
        Parameters:
        copyXML - The new copy XML flag
      • getErrorReportValveClass

        public java.lang.String getErrorReportValveClass()
        Returns:
        the Java class name of the error report valve class for new web applications.
      • setErrorReportValveClass

        public void setErrorReportValveClass​(java.lang.String errorReportValveClass)
        Set the Java class name of the error report valve class for new web applications.
        Parameters:
        errorReportValveClass - The new error report valve class
      • getName

        public java.lang.String getName()
        Description copied from interface: Container
        Return a name string (suitable for use by humans) that describes this Container. Within the set of child containers belonging to a particular parent, Container names must be unique.
        Specified by:
        getName in interface Container
        Overrides:
        getName in class ContainerBase
        Returns:
        The human readable name of this container.
      • setName

        public void setName​(java.lang.String name)
        Description copied from interface: Container
        Set a name string (suitable for use by humans) that describes this Container. Within the set of child containers belonging to a particular parent, Container names must be unique.
        Specified by:
        setName in interface Container
        Overrides:
        setName in class ContainerBase
        Parameters:
        name - New name of this container
      • isUnpackWARs

        public boolean isUnpackWARs()
        Returns:
        true if WARs should be unpacked on deployment.
      • setUnpackWARs

        public void setUnpackWARs​(boolean unpackWARs)
        Unpack WARs flag mutator.
        Parameters:
        unpackWARs - true to unpack WARs on deployment
      • getWorkDir

        public java.lang.String getWorkDir()
        Returns:
        host work directory base.
      • setWorkDir

        public void setWorkDir​(java.lang.String workDir)
        Set host work directory base.
        Parameters:
        workDir - the new base work folder for this host
      • getDeployIgnore

        public java.lang.String getDeployIgnore()
        Specified by:
        getDeployIgnore in interface Host
        Returns:
        the regular expression that defines the files and directories in the host's appBase that will be ignored by the automatic deployment process.
      • getDeployIgnorePattern

        public java.util.regex.Pattern getDeployIgnorePattern()
        Specified by:
        getDeployIgnorePattern in interface Host
        Returns:
        the compiled regular expression that defines the files and directories in the host's appBase that will be ignored by the automatic deployment process.
      • setDeployIgnore

        public void setDeployIgnore​(java.lang.String deployIgnore)
        Description copied from interface: Host
        Set the regular expression that defines the files and directories in the host's appBase that will be ignored by the automatic deployment process.
        Specified by:
        setDeployIgnore in interface Host
        Parameters:
        deployIgnore - A regular expression matching file names
      • isFailCtxIfServletStartFails

        public boolean isFailCtxIfServletStartFails()
        Returns:
        true if a webapp start should fail if a Servlet startup fails
      • setFailCtxIfServletStartFails

        public void setFailCtxIfServletStartFails​(boolean failCtxIfServletStartFails)
        Change the behavior of Servlet startup errors on web application starts.
        Parameters:
        failCtxIfServletStartFails - false to ignore errors on Servlets which are stated when the web application starts
      • addAlias

        public void addAlias​(java.lang.String alias)
        Description copied from interface: Host
        Add an alias name that should be mapped to this same Host.
        Specified by:
        addAlias in interface Host
        Parameters:
        alias - The alias to be added
      • addChild

        public void addChild​(Container child)
        Add a new child Container to those associated with this Container, if supported. Prior to adding this Container to the set of children, the child's setParent() method must be called, with this Container as an argument. This method may throw an IllegalArgumentException if this Container chooses not to be attached to the specified Container, in which case it is not added

        The child must be an implementation of Context.

        Specified by:
        addChild in interface Container
        Overrides:
        addChild in class ContainerBase
        Parameters:
        child - New child Container to be added
      • findReloadedContextMemoryLeaks

        public java.lang.String[] findReloadedContextMemoryLeaks()
        Attempt to identify the contexts that have a class loader memory leak. This is usually triggered on context reload. Note: This method attempts to force a full garbage collection. This should be used with extreme caution on a production system.
        Returns:
        an array of possibly leaking contexts
      • findAliases

        public java.lang.String[] findAliases()
        Specified by:
        findAliases in interface Host
        Returns:
        the array of alias names for this Host. If none are defined, a zero length array is returned.
      • removeAlias

        public void removeAlias​(java.lang.String alias)
        Description copied from interface: Host
        Remove the specified alias name from the aliases for this Host.
        Specified by:
        removeAlias in interface Host
        Parameters:
        alias - Alias name to be removed
      • getValveNames

        public java.lang.String[] getValveNames()
                                         throws java.lang.Exception
        Returns:
        the MBean Names of the Valves associated with this Host
        Throws:
        java.lang.Exception - if an MBean cannot be created or registered
      • getAliases

        public java.lang.String[] getAliases()
      • getObjectNameKeyProperties

        protected java.lang.String getObjectNameKeyProperties()
        Description copied from class: LifecycleMBeanBase
        Allow subclasses to specify the key properties component of the ObjectName that will be used to register this component.
        Specified by:
        getObjectNameKeyProperties in class LifecycleMBeanBase
        Returns:
        The string representation of the key properties component of the desired ObjectName