Class WebContainer

  • All Implemented Interfaces:
    Container, EventListener, org.glassfish.hk2.api.PostConstruct, org.glassfish.hk2.api.PreDestroy

    @Service(name="com.sun.enterprise.web.WebContainer")
    @Singleton
    public class WebContainer
    extends Object
    implements Container, org.glassfish.hk2.api.PostConstruct, org.glassfish.hk2.api.PreDestroy, EventListener
    Web container service
    Author:
    jluehe, amyroh, swchan2
    • Field Detail

      • globalAccessLoggingEnabled

        protected boolean globalAccessLoggingEnabled
        Allow disabling accessLog mechanism
      • globalAccessLogBufferSize

        protected String globalAccessLogBufferSize
        AccessLog buffer size for storing logs.
      • globalAccessLogWriteInterval

        protected String globalAccessLogWriteInterval
        AccessLog interval before the valve flush its buffer to the disk.
      • globalAccessLogPrefix

        protected String globalAccessLogPrefix
        AccessLog prefix
      • defaultRedirectPort

        protected int defaultRedirectPort
        The default-redirect port
      • _debug

        protected int _debug
        Controls the verbosity of the web container subsystem's debug messages.

        This value is non-zero only when the iAS level is one of FINE, FINER or FINEST.

      • _modulesRoot

        protected File _modulesRoot
        Absolute path for location where all the deployed standalone modules are stored for this Server Instance.
      • _started

        protected boolean _started
        Has this component been started yet?
      • globalSSOEnabled

        protected boolean globalSSOEnabled
        The global (at the http-service level) ssoEnabled property.
    • Constructor Detail

      • WebContainer

        public WebContainer()
    • Method Detail

      • postConstruct

        public void postConstruct()
        Specified by:
        postConstruct in interface org.glassfish.hk2.api.PostConstruct
      • preDestroy

        public void preDestroy()
        Specified by:
        preDestroy in interface org.glassfish.hk2.api.PreDestroy
      • isShutdown

        public boolean isShutdown()
        Returns true if the container has been shut down.
        Returns:
        false if the container has never been started.
      • getServletProbeProvider

        public ServletProbeProvider getServletProbeProvider()
        Gets the probe provider for servlet related events.
        Returns:
      • getJspProbeProvider

        public JspProbeProvider getJspProbeProvider()
        Gets the probe provider for jsp related events.
        Returns:
      • getSessionProbeProvider

        public SessionProbeProvider getSessionProbeProvider()
        Gets the probe provider for session related events.
        Returns:
      • getRequestProbeProvider

        public RequestProbeProvider getRequestProbeProvider()
        Gets the probe provider for request/response related events.
        Returns:
      • getWebModuleProbeProvider

        public WebModuleProbeProvider getWebModuleProbeProvider()
        Gets the probe provider for web module related events.
        Returns:
      • getName

        public String getName()
        Description copied from interface: Container
        Returns a human redeable name for this container, this name is not used for identifying the container but can be used to display messages belonging to the container.
        Specified by:
        getName in interface Container
        Returns:
        a human readable name for this container.
      • getDeployer

        public Class<? extends WebDeployer> getDeployer()
        Description copied from interface: Container
        Returns the Deployer implementation capable of deploying applications to this container.
        Specified by:
        getDeployer in interface Container
        Returns:
        the Deployer implementation
      • createTagHandlerInstance

        public <T extends jakarta.servlet.jsp.tagext.JspTag> T createTagHandlerInstance​(WebModule module,
                                                                                        Class<T> clazz)
                                                                                 throws Exception
        Instantiates and injects the given tag handler class for the given WebModule
        Type Parameters:
        T -
        Parameters:
        module -
        clazz -
        Returns:
        Throws:
        Exception
      • createHttpListener

        protected WebConnector createHttpListener​(NetworkListener listener,
                                                  HttpService httpService)
        Use an network-listener subelements and creates a corresponding Tomcat Connector for each.
        Parameters:
        listener - the NetworkListener config object.
        httpService - the http-service element.
        Returns:
      • createJKConnector

        protected WebConnector createJKConnector​(NetworkListener listener,
                                                 HttpService httpService)
        Starts the AJP connector that will listen to call from Apache using mod_jk, mod_jk2 or mod_ajp.
        Parameters:
        listener -
        httpService -
        Returns:
      • configureHttpServiceProperties

        @Deprecated
        public void configureHttpServiceProperties​(HttpService httpService,
                                                   PECoyoteConnector connector)
        Deprecated.
        most of these properties are handled elsewhere. validate and remove outdated properties checks
        Configure http-service properties.
        Parameters:
        httpService -
        connector -
      • createHosts

        protected void createHosts​(HttpService httpService,
                                   SecurityService securityService)
        Enumerates the virtual-server subelements of the given http-service element, and creates a corresponding Host for each.
        Parameters:
        httpService - The http-service element
        securityService - The security-service element
      • createHost

        public VirtualServer createHost​(VirtualServer vsBean,
                                        HttpService httpService,
                                        SecurityService securityService)
        Creates a Host from a virtual-server config bean.
        Parameters:
        vsBean - The virtual-server configuration bean
        httpService - The http-service element.
        securityService - The security-service element
        Returns:
      • validateDocroot

        protected void validateDocroot​(String docroot,
                                       String virtualServerId,
                                       String defaultWebModule)
        Validate the docroot properties of a virtual-server.
        Parameters:
        docroot -
        virtualServerId -
        defaultWebModule -
      • configureHost

        protected void configureHost​(VirtualServer virtualServer,
                                     SecurityService securityService)
        Configures the given virtual server.
        Parameters:
        virtualServer - The virtual server to be configured
        securityService - The security-service element
      • configureHostPortNumbers

        protected void configureHostPortNumbers​(VirtualServer virtualServer,
                                                HashSet<NetworkListener> listeners)
        Configures the given virtual server with the port numbers of its associated http listeners.
        Parameters:
        virtualServer - The virtual server to configure
        listeners - The http listeners with which the given virtual server is associated
      • createHost

        public VirtualServer createHost​(String virtualServerId,
                                        VirtualServer virtualServerBean,
                                        String docroot,
                                        MimeMap mimeMap)
        Create a virtual server/host.
        Parameters:
        virtualServerId -
        virtualServerBean -
        docroot -
        mimeMap -
        Returns:
      • stop

        public void stop()
                  throws LifecycleException
        Gracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.
        Throws:
        IllegalStateException - if this component has not been started
        LifecycleException - if this component detects a fatal error that needs to be reported
      • loadSystemDefaultWebModules

        public void loadSystemDefaultWebModules()
        Configures a default web module for each virtual server based on the virtual server's docroot if a virtual server does not specify any default-web-module, and none of its web modules are loaded at "/"

        Needed in postConstruct before Deployment.ALL_APPLICATIONS_PROCESSED for "jsp from docroot before web container start" scenario

        See Also:
        -
      • loadDefaultWebModulesAfterAllAppsProcessed

        public void loadDefaultWebModulesAfterAllAppsProcessed()
        Configures a default web module for each virtual server if default-web-module is defined.
      • loadDefaultWebModule

        public void loadDefaultWebModule​(VirtualServer vsBean)
        Load a default-web-module on the specified virtual server.
        Parameters:
        vsBean -
      • loadDefaultWebModule

        public void loadDefaultWebModule​(VirtualServer virtualServer)
        Load a default-web-module on the specified virtual server.
        Parameters:
        virtualServer -
      • loadStandaloneWebModule

        protected void loadStandaloneWebModule​(VirtualServer virtualServer,
                                               WebModuleConfig webModuleConfig)
        Load the specified web module as a standalone module on the specified virtual server.
        Parameters:
        virtualServer -
        webModuleConfig -
      • isEnabled

        protected boolean isEnabled​(String moduleName)
        Whether or not a component (either an application or a module) should be enabled is defined by the "enable" attribute on both the application/module element and the application-ref element.
        Parameters:
        moduleName - The name of the component (application or module)
        Returns:
        boolean
      • loadWebModule

        public List<Result<WebModule>> loadWebModule​(WebModuleConfig webModuleConfig,
                                                     String j2eeApplication,
                                                     Properties deploymentProperties)
        Creates and configures a web module for each virtual server that the web module is hosted under.

        If no virtual servers have been specified, then the web module will not be loaded.

        Parameters:
        webModuleConfig -
        j2eeApplication -
        deploymentProperties -
        Returns:
      • updateDefaultWebModule

        protected void updateDefaultWebModule​(VirtualServer virtualServer,
                                              String[] listenerNames,
                                              WebModuleConfig webModuleConfig)
                                       throws LifecycleException
        Updates the given virtual server with the given default path. The given default path corresponds to the context path of one of the web contexts deployed on the virtual server that has been designated as the virtual server's new default-web-module.
        Parameters:
        virtualServer - The virtual server to update
        ports - The port numbers of the HTTP listeners with which the given virtual server is associated
        defaultContextPath - The context path of the web module that has been designated as the virtual server's new default web module, or null if the virtual server no longer has any default-web-module
        Throws:
        LifecycleException
      • getServerContext

        public ServerContext getServerContext()
        Utility Method to access the ServerContext
        Returns:
      • getApplicationId

        public String getApplicationId​(WebModule webModule)
        The application id for this web module HERCULES:add
        Parameters:
        webModule -
        Returns:
      • getModulesRoot

        public File getModulesRoot()
        Return the Absolute path for location where all the deployed standalone modules are stored for this Server Instance.
        Returns:
      • unloadWebModule

        public void unloadWebModule​(String contextRoot,
                                    String appName,
                                    String virtualServers,
                                    Properties props)
        Undeploy a web application.
        Parameters:
        contextRoot - the context's name to undeploy
        appName - the J2EE appname used at deployment time
        virtualServers - List of current virtual-server object.
        props -
      • unloadWebModule

        public void unloadWebModule​(String contextRoot,
                                    String appName,
                                    String virtualServers,
                                    boolean dummy,
                                    Properties props)
        Undeploy a web application.
        Parameters:
        contextRoot - the context's name to undeploy
        appName - the J2EE appname used at deployment time
        virtualServers - List of current virtual-server object.
        dummy - true if the web module to be undeployed is a dummy web module, that is, a web module created off of a virtual server's docroot
        props -
      • suspendWebModule

        public boolean suspendWebModule​(String contextRoot,
                                        String appName,
                                        String hosts)
        Suspends the web application with the given appName that has been deployed at the given contextRoot on the given virtual servers.
        Parameters:
        contextRoot - the context root
        appName - the J2EE appname used at deployment time
        hosts - the list of virtual servers
      • suspendWebModule

        public boolean suspendWebModule​(String contextRoot,
                                        String appName,
                                        String hosts,
                                        boolean fromDisableStartEvent)
        Suspends the web application with the given appName that has been deployed at the given contextRoot on the given virtual servers.
        Parameters:
        contextRoot - the context root
        appName - the J2EE appname used at deployment time
        hosts - the list of virtual servers
        fromDisableStartEvent - whether or not this invocation came from the disable_start event - used to determine a log level about failing to disable the web module due to an "acceptable" race condition (unloaded before we managed to reach this point - nothing to do)
      • findLifecycleListeners

        public LifecycleListener[] findLifecycleListeners()
        Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.
        Returns:
      • getEngine

        public Engine getEngine()
        Return the parent/top-level container in _embedded for virtual servers.
        Returns:
      • registerAdHocPath

        public void registerAdHocPath​(String path,
                                      String ctxtRoot,
                                      String appName,
                                      AdHocServletInfo servletInfo)
        Registers the given ad-hoc path at the given context root.
        Parameters:
        path - The ad-hoc path to register
        ctxtRoot - The context root at which to register
        appName - The name of the application with which the ad-hoc path is associated
        servletInfo - Info about the ad-hoc servlet that will service requests on the given path
      • registerAdHocPathAndSubtree

        public void registerAdHocPathAndSubtree​(String path,
                                                String subtree,
                                                String ctxtRoot,
                                                String appName,
                                                AdHocServletInfo servletInfo)
        Registers the given ad-hoc path and subtree at the given context root.
        Parameters:
        path - The ad-hoc path to register
        subtree - The ad-hoc subtree path to register
        ctxtRoot - The context root at which to register
        appName - The name of the application with which the ad-hoc path and subtree are associated
        servletInfo - Info about the ad-hoc servlet that will service requests on the given ad-hoc path and subtree
      • unregisterAdHocPath

        public void unregisterAdHocPath​(String path,
                                        String ctxtRoot)
        Unregisters the given ad-hoc path from the given context root.
        Parameters:
        path - The ad-hoc path to unregister
        ctxtRoot - The context root from which to unregister
      • unregisterAdHocPathAndSubtree

        public void unregisterAdHocPathAndSubtree​(String path,
                                                  String subtree,
                                                  String ctxtRoot)
        Unregisters the given ad-hoc path and subtree from the given context root.
        Parameters:
        path - The ad-hoc path to unregister
        subtree - The ad-hoc subtree to unregister
        ctxtRoot - The context root from which to unregister
      • updateHostProperties

        public void updateHostProperties​(VirtualServer vsBean,
                                         String name,
                                         String value,
                                         SecurityService securityService,
                                         VirtualServer virtualServer)
        Update virtual-server properties.
        Parameters:
        vsBean -
        name -
        value -
        virtualServer -
        securityService -
      • updateConnectorProperty

        public void updateConnectorProperty​(NetworkListener listener,
                                            String propName,
                                            String propValue)
                                     throws LifecycleException
        Update an http-listener property
        Parameters:
        listener - the configuration bean.
        propName - the property name
        propValue - the property value
        Throws:
        LifecycleException
      • updateMapper

        public void updateMapper​(HttpService httpService,
                                 NetworkListener httpListener,
                                 org.glassfish.grizzly.http.server.util.Mapper mapper)
        Method gets called, when GrizzlyService changes HTTP Mapper, associated with specific port.
        Parameters:
        httpService - HttpService
        httpListener - NetworkListener, which Mapper was changed
        mapper - new Mapper value
      • updateAccessLog

        public void updateAccessLog​(HttpService httpService)
        Reconfigures the access log valve of each virtual server with the updated attributes of the element from domain.xml.
        Parameters:
        httpService -
      • updateJvmRoute

        public void updateJvmRoute​(HttpService httpService,
                                   String jvmOption)
      • isTomcatUsingDefaultDomain

        protected boolean isTomcatUsingDefaultDomain()
        is Tomcat using default domain name as its domain