Class StandardHost

  • All Implemented Interfaces:
    Container, Deployer, Host, Lifecycle, Pipeline
    Direct Known Subclasses:
    VirtualServer

    public class StandardHost
    extends ContainerBase
    implements Deployer, 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.
    Version:
    $Revision: 1.13 $ $Date: 2007/04/17 21:33:22 $
    Author:
    Craig R. McClanahan, Remy Maucherat
    • Field Detail

      • aliases

        protected String[] aliases
        The set of aliases for this Host.
    • Constructor Detail

      • StandardHost

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

      • setPipeline

        public void setPipeline​(Pipeline pl)
      • getAppBase

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

        public void setAppBase​(String appBase)
        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
      • getAutoDeploy

        public boolean getAutoDeploy()
        Return the value of the auto deploy flag. If true, it indicates that this host's child webapps will be dynamically deployed.
        Specified by:
        getAutoDeploy in interface Host
      • setAutoDeploy

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

        public String getConfigClass()
        Return the Java class name of the context configuration class for new web applications.
      • setConfigClass

        public void setConfigClass​(String configClass)
        Set the Java class name of the context configuration class for new web applications.
        Parameters:
        configClass - The new context configuration class
      • getContextClass

        public String getContextClass()
        Return the Java class name of the Context implementation class for new web applications.
      • setContextClass

        public void setContextClass​(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()
        Return the value of the deploy on startup flag. If true, it indicates that this host's child webapps should be discovered and automatically deployed at startup time.
        Specified by:
        getDeployOnStartup in interface Host
      • setDeployOnStartup

        public void setDeployOnStartup​(boolean deployOnStartup)
        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()
        Deploy XML Context config files flag accessor.
      • setDeployXML

        public void setDeployXML​(boolean deployXML)
        Deploy XML Context config files flag mutator.
      • getErrorReportValveClass

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

        public void setErrorReportValveClass​(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
      • isUnpackWARs

        public boolean isUnpackWARs()
        Unpack WARs flag accessor.
      • setUnpackWARs

        public void setUnpackWARs​(boolean unpackWARs)
        Unpack WARs flag mutator.
      • setXmlValidation

        public void setXmlValidation​(boolean xmlValidation)
        Set the validation feature of the XML parser used when parsing xml instances.
        Specified by:
        setXmlValidation in interface Host
        Parameters:
        xmlValidation - true to enable xml instance validation
      • getXmlValidation

        public boolean getXmlValidation()
        Get the server.xml attribute's xmlValidation.
        Specified by:
        getXmlValidation in interface Host
        Returns:
        true if validation is enabled.
      • getXmlNamespaceAware

        public boolean getXmlNamespaceAware()
        Get the server.xml attribute's xmlNamespaceAware.
        Specified by:
        getXmlNamespaceAware in interface Host
        Returns:
        true if namespace awareness is enabled.
      • setXmlNamespaceAware

        public void setXmlNamespaceAware​(boolean xmlNamespaceAware)
        Set the namespace aware feature of the XML parser used when parsing xml instances.
        Specified by:
        setXmlNamespaceAware in interface Host
        Parameters:
        xmlNamespaceAware - true to enable namespace awareness
      • getWorkDir

        public String getWorkDir()
        Host work directory base.
      • setWorkDir

        public void setWorkDir​(String workDir)
        Host work directory base.
      • setNetworkListenerNames

        public void setNetworkListenerNames​(String[] networkListenerNames)
        Associates this StandardHost with the given network listener names.
        Specified by:
        setNetworkListenerNames in interface Host
        Parameters:
        networkListenerNames - The network listener names with which to associate this StandardHost
      • getNetworkListenerNames

        public String[] getNetworkListenerNames()
        Gets the network listener names with which this StandardHost is associated.
        Specified by:
        getNetworkListenerNames in interface Host
        Returns:
        The network listener names with which this StandardHost is associated, or null if this StandardHost has not been associated with any ports
      • getNetworkListeners

        public String getNetworkListeners()
      • getDefaultContextXmlLocation

        public String getDefaultContextXmlLocation()
        Gets the default-context.xml location of web modules deployed on this virtual server.
        Returns:
        default-context.xml location of web modules deployed on this virtual server
      • setDefaultContextXmlLocation

        public void setDefaultContextXmlLocation​(String defaultContextXmlLocation)
        Sets the default-context.xml location for web modules deployed on this virtual server.
        Parameters:
        defaultContextXmlLocation - default-context.xml location for web modules deployed on this virtual server
      • getDefaultWebXmlLocation

        public String getDefaultWebXmlLocation()
        Gets the default-web.xml location of web modules deployed on this virtual server.
        Returns:
        default-web.xml location of web modules deployed on this virtual server
      • setDefaultWebXmlLocation

        public void setDefaultWebXmlLocation​(String defaultWebXmlLocation)
        Sets the default-web.xml location for web modules deployed on this virtual server.
        Parameters:
        defaultWebXmlLocation - default-web.xml location for web modules deployed on this virtual server
      • addAlias

        public void addAlias​(String alias)
        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 child Container, only if the proposed child is an implementation of Context.
        Specified by:
        addChild in interface Container
        Overrides:
        addChild in class ContainerBase
        Parameters:
        child - Child container to be added
      • findChild

        public Container findChild​(String contextRoot)
        Returns the context deployed at the given context root.
        Specified by:
        findChild in interface Container
        Overrides:
        findChild in class ContainerBase
        Parameters:
        contextRoot - The context root whose associated context to return
        Returns:
        The context deployed at the given context root, or null
      • findAliases

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

        public Host findMappingObject()
      • getInfo

        public String getInfo()
        Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
        Specified by:
        getInfo in interface Container
        Overrides:
        getInfo in class ContainerBase
      • map

        public Context map​(String uri)
        Return the Context that would be used to process the specified host-relative request URI, if any; otherwise return null.
        Specified by:
        map in interface Host
        Parameters:
        uri - Request URI to be mapped
      • removeAlias

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

        public void addErrorPage​(ErrorPage errorPage)
        Adds the given error page to this StandardHost.
        Parameters:
        errorPage - The error page definition to be added
      • findErrorPage

        public ErrorPage findErrorPage​(int errorCode)
        Gets the error page for the specified HTTP error code.
        Parameters:
        errorCode - Error code to look up
        Returns:
        The error page that is mapped to the specified HTTP error code, or null if no error page exists for that HTTP error code
      • configureSingleSignOnCookieSecure

        public void configureSingleSignOnCookieSecure​(jakarta.servlet.http.Cookie cookie,
                                                      jakarta.servlet.http.HttpServletRequest hreq)
        Configures the Secure attribute of the given SSO cookie.
        Parameters:
        cookie - the SSO cookie to be configured
        hreq - the HttpServletRequest that has initiated the SSO session
      • configureSingleSignOnCookieHttpOnly

        public void configureSingleSignOnCookieHttpOnly​(jakarta.servlet.http.Cookie cookie)
        Configures the HttpOnly attribute of the given SSO cookie.
        Parameters:
        cookie - the SSO ccokie to be configured
      • toString

        public String toString()
        Return a String representation of this component.
        Overrides:
        toString in class Object
      • sendNotification

        public void sendNotification​(Notification notification)
      • install

        public void install​(String contextPath,
                            URL war)
                     throws IOException
        Install a new web application, whose web application archive is at the specified URL, into this container with the specified context path. A context path of "" (the empty string) should be used for the root application for this container. Otherwise, the context path must start with a slash.

        If this application is successfully installed, a ContainerEvent of type INSTALL_EVENT will be sent to all registered listeners, with the newly created Context as an argument.

        Specified by:
        install in interface Deployer
        Parameters:
        contextPath - The context path to which this application should be installed (must be unique)
        war - A URL of type "jar:" that points to a WAR file, or type "file:" that points to an unpacked directory structure containing the web application to be installed
        Throws:
        IllegalArgumentException - if the specified context path is malformed (it must be "" or start with a slash)
        IllegalStateException - if the specified context path is already attached to an existing web application
        IOException - if an input/output error was encountered during install
      • install

        public void install​(URL config,
                            URL war)
                     throws IOException

        Install a new web application, whose context configuration file (consisting of a <Context> element) and web application archive are at the specified URLs.

        If this application is successfully installed, a ContainerEvent of type INSTALL_EVENT will be sent to all registered listeners, with the newly created Context as an argument.

        Specified by:
        install in interface Deployer
        Parameters:
        config - A URL that points to the context configuration file to be used for configuring the new Context
        war - A URL of type "jar:" that points to a WAR file, or type "file:" that points to an unpacked directory structure containing the web application to be installed
        Throws:
        IllegalArgumentException - if one of the specified URLs is null
        IllegalStateException - if the context path specified in the context configuration file is already attached to an existing web application
        IOException - if an input/output error was encountered during installation
      • findDeployedApp

        public Context findDeployedApp​(String contextPath)
        Return the Context for the deployed application that is associated with the specified context path (if any); otherwise return null.
        Specified by:
        findDeployedApp in interface Deployer
        Parameters:
        contextPath - The context path of the requested web application
      • findDeployedApps

        public String[] findDeployedApps()
        Return the context paths of all deployed web applications in this Container. If there are no deployed applications, a zero-length array is returned.
        Specified by:
        findDeployedApps in interface Deployer
      • remove

        public void remove​(String contextPath)
                    throws IOException
        Remove an existing web application, attached to the specified context path. If this application is successfully removed, a ContainerEvent of type REMOVE_EVENT will be sent to all registered listeners, with the removed Context as an argument.
        Specified by:
        remove in interface Deployer
        Parameters:
        contextPath - The context path of the application to be removed
        Throws:
        IllegalArgumentException - if the specified context path is malformed (it must be "" or start with a slash)
        IllegalArgumentException - if the specified context path does not identify a currently installed web application
        IOException - if an input/output error occurs during removal
      • remove

        public void remove​(String contextPath,
                           boolean undeploy)
                    throws IOException
        Remove an existing web application, attached to the specified context path. If this application is successfully removed, a ContainerEvent of type REMOVE_EVENT will be sent to all registered listeners, with the removed Context as an argument. Deletes the web application war file and/or directory if they exist in the Host's appBase.
        Specified by:
        remove in interface Deployer
        Parameters:
        contextPath - The context path of the application to be removed
        undeploy - boolean flag to remove web application from server
        Throws:
        IllegalArgumentException - if the specified context path is malformed (it must be "" or start with a slash)
        IllegalArgumentException - if the specified context path does not identify a currently installed web application
        IOException - if an input/output error occurs during removal
      • start

        public void start​(String contextPath)
                   throws IOException
        Start an existing web application, attached to the specified context path. Only starts a web application if it is not running.
        Specified by:
        start in interface Deployer
        Parameters:
        contextPath - The context path of the application to be started
        Throws:
        IllegalArgumentException - if the specified context path is malformed (it must be "" or start with a slash)
        IllegalArgumentException - if the specified context path does not identify a currently installed web application
        IOException - if an input/output error occurs during startup
      • stop

        public void stop​(String contextPath)
                  throws IOException
        Stop an existing web application, attached to the specified context path. Only stops a web application if it is running.
        Specified by:
        stop in interface Deployer
        Parameters:
        contextPath - The context path of the application to be stopped
        Throws:
        IllegalArgumentException - if the specified context path is malformed (it must be "" or start with a slash)
        IllegalArgumentException - if the specified context path does not identify a currently installed web application
        IOException - if an input/output error occurs while stopping the web application
      • isSecurePagesWithPragma

        public boolean isSecurePagesWithPragma()
        Returns the value of the securePagesWithPragma property.
      • setSecurePagesWithPragma

        public void setSecurePagesWithPragma​(boolean securePagesWithPragma)
        Sets the securePagesWithPragma property of this Context. Setting this property to true will result in Pragma and Cache-Control headers with a value of "No-cache" if proxy caching has been disabled. Setting this property to false will not add any Pragma header, but will set the Cache-Control header to "private".
        Parameters:
        securePagesWithPragma - true if Pragma and Cache-Control headers are to be set to "No-cache" if proxy caching has been disabled, false otherwise
      • addValve

        public void addValve​(GlassFishValve valve)
        Description copied from class: ContainerBase
        Add a new Valve to the end of the pipeline associated with this Container. Prior to adding the Valve, the Valve's setContainer method must be called, with this Container as an argument. The method may throw an IllegalArgumentException if this Valve chooses not to be associated with this Container, or IllegalStateException if it is already associated with a different Container.
        Specified by:
        addValve in interface Pipeline
        Overrides:
        addValve in class ContainerBase
        Parameters:
        valve - Valve to be added
      • removeValve

        public void removeValve​(GlassFishValve valve)
        Description copied from class: ContainerBase
        Remove the specified Valve from the pipeline associated with this Container, if it is found; otherwise, do nothing.
        Specified by:
        removeValve in interface Pipeline
        Overrides:
        removeValve in class ContainerBase
        Parameters:
        valve - Valve to be removed
      • getDeployer

        public Deployer getDeployer()
      • setDeployer

        public void setDeployer​(Deployer d)
      • getValveNames

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

        public String[] getAliases()
      • init

        public void init()
        Description copied from class: ContainerBase
        Init method, part of the MBean lifecycle. If the container was added via JMX, it'll register itself with the parent, using the ObjectName conventions to locate the parent. If the container was added directly and it doesn't have an ObjectName, it'll create a name and register itself with the JMX console. On destroy(), the object will unregister.
        Overrides:
        init in class ContainerBase