com.sun.enterprise.web
Class WebContainer

java.lang.Object
  extended by com.sun.enterprise.web.WebContainer
All Implemented Interfaces:
Container, EventListener, org.jvnet.hk2.component.PostConstruct, org.jvnet.hk2.component.PreDestroy

@Service(name="com.sun.enterprise.web.WebContainer")
@Scoped(value=org.jvnet.hk2.component.Singleton.class)
public class WebContainer
extends java.lang.Object
implements Container, org.jvnet.hk2.component.PostConstruct, org.jvnet.hk2.component.PreDestroy, EventListener

Web container service

Author:
jluehe, amyroh, swchan2

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.glassfish.api.event.EventListener
EventListener.Event<T>
 
Field Summary
protected  int _debug
          Controls the verbosity of the web container subsystem's debug messages.
protected static java.util.logging.Logger _logger
          The logger to use for logging ALL web container related messages.
protected  java.io.File _modulesRoot
          Absolute path for location where all the deployed standalone modules are stored for this Server Instance.
protected  boolean _started
          Has this component been started yet?
protected  boolean catalinaCachingAllowed
          false when the Grizzly File Cache is enabled.
protected  WebConfigListener configListener
           
protected  int defaultRedirectPort
          The default-redirect port
static java.lang.String DISPATCHER_MAX_DEPTH
           
protected  java.lang.String globalAccessLogBufferSize
          AccessLog buffer size for storing logs.
protected  boolean globalAccessLoggingEnabled
          Allow disabling accessLog mechanism
protected  java.lang.String globalAccessLogWriteInterval
          AccessLog interval before the valve flush its buffer to the disk.
protected  boolean globalSSOEnabled
          The global (at the http-service level) ssoEnabled property.
protected  ServerEnvironment instance
           
protected  JspProbeProvider jspProbeProvider
           
static java.lang.String JWS_APPCLIENT_EAR_NAME
           
static java.lang.String JWS_APPCLIENT_WAR_NAME
           
protected static java.util.ResourceBundle rb
           
protected  RequestProbeProvider requestProbeProvider
           
protected  ServletProbeProvider servletProbeProvider
           
protected  SessionProbeProvider sessionProbeProvider
           
protected static boolean useDOLforDeployment
          Are we using Tomcat deployment backend or DOL?
protected static WebContainer webContainer
          The current WebContainer instance used (single).
protected  WebContainerFeatureFactory webContainerFeatureFactory
           
protected  WebModuleProbeProvider webModuleProbeProvider
           
 
Constructor Summary
WebContainer()
           
 
Method Summary
 WebConnector addConnector(com.sun.grizzly.config.dom.NetworkListener httpListener, HttpService httpService, boolean start)
           
protected  void configureHost(VirtualServer vs, SecurityService securityService)
          Configures the given virtual server.
protected  void configureHostPortNumbers(VirtualServer vs, java.util.HashSet<com.sun.grizzly.config.dom.NetworkListener> listeners)
          Configures the given virtual server with the port numbers of its associated http listeners.
 void configureHttpServiceProperties(HttpService httpService, PECoyoteConnector connector)
          Deprecated. most of these properties are handled elsewhere. validate and remove outdated properties checks
 VirtualServer createHost(java.lang.String vsID, VirtualServer vsBean, java.lang.String docroot, MimeMap mimeMap)
          Create a virtual server/host.
 VirtualServer createHost(VirtualServer vsBean, HttpService httpService, SecurityService securityService)
          Creates a Host from a virtual-server config bean.
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.
protected  WebConnector createHttpListener(com.sun.grizzly.config.dom.NetworkListener listener, HttpService httpService)
          Use an network-listener subelements and creates a corresponding Tomcat Connector for each.
protected  WebConnector createHttpListener(com.sun.grizzly.config.dom.NetworkListener listener, HttpService httpService, com.sun.grizzly.util.http.mapper.Mapper mapper)
           
protected  WebConnector createJKConnector(com.sun.grizzly.config.dom.NetworkListener listener, HttpService httpService)
          Starts the AJP connector that will listen to call from Apache using mod_jk, mod_jk2 or mod_ajp.
<T extends javax.servlet.jsp.tagext.JspTag>
T
createTagHandlerInstance(WebModule module, java.lang.Class<T> clazz)
          Instantiates and injects the given tag handler class for the given WebModule
 void deleteConnector(com.sun.grizzly.config.dom.NetworkListener httpListener)
          Stops and deletes the specified http listener.
 void deleteConnector(WebConnector connector)
          Stops and deletes the specified http listener.
 void deleteHost(HttpService httpService)
          Delete virtual-server.
 void event(EventListener.Event event)
           
 LifecycleListener[] findLifecycleListeners()
          Get the lifecycle listeners associated with this lifecycle.
 java.lang.String getApplicationId(WebModule wm)
          The application id for this web module HERCULES:add
 java.util.HashMap<java.lang.String,WebConnector> getConnectorMap()
           
 java.lang.Class<? extends WebDeployer> getDeployer()
           
 Engine getEngine()
          Return the parent/top-level container in _embedded for virtual servers.
 WebConnector getJkConnector()
           
 JspProbeProvider getJspProbeProvider()
          Gets the probe provider for jsp related events.
 java.io.File getModulesRoot()
          Return the Absolute path for location where all the deployed standalone modules are stored for this Server Instance.
 java.lang.String getName()
           
 RequestProbeProvider getRequestProbeProvider()
          Gets the probe provider for request/response related events.
 ServerContext getServerContext()
          Utility Method to access the ServerContext
 ServletProbeProvider getServletProbeProvider()
          Gets the probe provider for servlet related events.
 SessionProbeProvider getSessionProbeProvider()
          Gets the probe provider for session related events.
 WebModuleProbeProvider getWebModuleProbeProvider()
          Gets the probe provider for web module related events.
protected  boolean isEnabled(java.lang.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.
 boolean isShutdown()
           
protected  boolean isTomcatUsingDefaultDomain()
          is Tomcat using default domain name as its domain
 java.lang.Class loadCommonClass(java.lang.String className)
           
 void loadDefaultWebModule(VirtualServer vsBean)
          Load a default-web-module on the specified virtual server.
 void loadDefaultWebModule(VirtualServer vs)
          Load a default-web-module on the specified virtual server.
 void loadDefaultWebModulesAfterAllAppsProcessed()
          Configures a default web module for each virtual server if default-web-module is defined.
protected  void loadStandaloneWebModule(VirtualServer vs, WebModuleConfig wmInfo)
          Load the specified web module as a standalone module on the specified virtual server.
 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

 java.util.List<Result<WebModule>> loadWebModule(WebModuleConfig wmInfo, java.lang.String j2eeApplication, java.util.Properties deploymentProperties)
          Creates and configures a web module for each virtual server that the web module is hosted under.
 void postConstruct()
           
 void preDestroy()
           
 void registerAdHocPath(java.lang.String path, java.lang.String ctxtRoot, java.lang.String appName, AdHocServletInfo servletInfo)
          Registers the given ad-hoc path at the given context root.
 void registerAdHocPathAndSubtree(java.lang.String path, java.lang.String subtree, java.lang.String ctxtRoot, java.lang.String appName, AdHocServletInfo servletInfo)
          Registers the given ad-hoc path and subtree at the given context root.
 void stop()
          Gracefully terminate the active use of the public methods of this component.
 boolean suspendWebModule(java.lang.String contextRoot, java.lang.String appName, java.lang.String hosts)
          Suspends the web application with the given appName that has been deployed at the given contextRoot on the given virtual servers.
 void unloadWebModule(java.lang.String contextRoot, java.lang.String appName, java.lang.String virtualServers, boolean dummy, java.util.Properties props)
          Undeploy a web application.
 void unloadWebModule(java.lang.String contextRoot, java.lang.String appName, java.lang.String virtualServers, java.util.Properties props)
          Undeploy a web application.
 void unregisterAdHocPath(java.lang.String path, java.lang.String ctxtRoot)
          Unregisters the given ad-hoc path from the given context root.
 void unregisterAdHocPathAndSubtree(java.lang.String path, java.lang.String subtree, java.lang.String ctxtRoot)
          Unregisters the given ad-hoc path and subtree from the given context root.
 void updateAccessLog(HttpService httpService)
          Reconfigures the access log valve of each virtual server with the updated attributes of the element from domain.xml.
 void updateConnector(com.sun.grizzly.config.dom.NetworkListener networkListener, HttpService httpService)
          Update an network-listener
 void updateConnectorProperty(com.sun.grizzly.config.dom.NetworkListener listener, java.lang.String propName, java.lang.String propValue)
          Update an http-listener property
protected  void updateDefaultWebModule(VirtualServer virtualServer, java.lang.String[] listenerNames, WebModuleConfig wmInfo)
           
 void updateHost(VirtualServer vsBean)
          Updates a virtual-server element.
 void updateHostProperties(VirtualServer vsBean, java.lang.String name, java.lang.String value, SecurityService securityService, VirtualServer vs)
          Update virtual-server properties.
 void updateHttpService(HttpService httpService)
          Processes an update to the http-service element
 void updateMapper(HttpService httpService, com.sun.grizzly.config.dom.NetworkListener httpListener, com.sun.grizzly.util.http.mapper.Mapper mapper)
          Method gets called, when GrizzlyService changes HTTP Mapper, associated with specific port.
protected  void validateDocroot(java.lang.String docroot, java.lang.String vs_id, java.lang.String defaultWebModule)
          Validate the docroot properties of a virtual-server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPATCHER_MAX_DEPTH

public static final java.lang.String DISPATCHER_MAX_DEPTH
See Also:
Constant Field Values

JWS_APPCLIENT_EAR_NAME

public static final java.lang.String JWS_APPCLIENT_EAR_NAME
See Also:
Constant Field Values

JWS_APPCLIENT_WAR_NAME

public static final java.lang.String JWS_APPCLIENT_WAR_NAME
See Also:
Constant Field Values

_logger

protected static final java.util.logging.Logger _logger
The logger to use for logging ALL web container related messages.


rb

protected static final java.util.ResourceBundle rb

webContainer

protected static WebContainer webContainer
The current WebContainer instance used (single).


useDOLforDeployment

protected static boolean useDOLforDeployment
Are we using Tomcat deployment backend or DOL?


globalAccessLoggingEnabled

protected boolean globalAccessLoggingEnabled
Allow disabling accessLog mechanism


globalAccessLogBufferSize

protected java.lang.String globalAccessLogBufferSize
AccessLog buffer size for storing logs.


globalAccessLogWriteInterval

protected java.lang.String globalAccessLogWriteInterval
AccessLog interval before the valve flush its buffer to the disk.


defaultRedirectPort

protected int defaultRedirectPort
The default-redirect port


catalinaCachingAllowed

protected boolean catalinaCachingAllowed
false when the Grizzly File Cache is enabled. When disabled the Servlet Container temporary Naming cache is used when loading the resources.


instance

protected ServerEnvironment instance

_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 java.io.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.


webContainerFeatureFactory

protected volatile WebContainerFeatureFactory webContainerFeatureFactory

jspProbeProvider

protected JspProbeProvider jspProbeProvider

requestProbeProvider

protected RequestProbeProvider requestProbeProvider

servletProbeProvider

protected ServletProbeProvider servletProbeProvider

sessionProbeProvider

protected SessionProbeProvider sessionProbeProvider

webModuleProbeProvider

protected WebModuleProbeProvider webModuleProbeProvider

configListener

protected WebConfigListener configListener
Constructor Detail

WebContainer

public WebContainer()
Method Detail

postConstruct

public void postConstruct()
Specified by:
postConstruct in interface org.jvnet.hk2.component.PostConstruct

event

public void event(EventListener.Event event)
Specified by:
event in interface EventListener

preDestroy

public void preDestroy()
Specified by:
preDestroy in interface org.jvnet.hk2.component.PreDestroy

isShutdown

public boolean isShutdown()

getServletProbeProvider

public ServletProbeProvider getServletProbeProvider()
Gets the probe provider for servlet related events.


getJspProbeProvider

public JspProbeProvider getJspProbeProvider()
Gets the probe provider for jsp related events.


getSessionProbeProvider

public SessionProbeProvider getSessionProbeProvider()
Gets the probe provider for session related events.


getRequestProbeProvider

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


getWebModuleProbeProvider

public WebModuleProbeProvider getWebModuleProbeProvider()
Gets the probe provider for web module related events.


getName

public java.lang.String getName()
Specified by:
getName in interface Container

getDeployer

public java.lang.Class<? extends WebDeployer> getDeployer()
Specified by:
getDeployer in interface Container

getJkConnector

public WebConnector getJkConnector()

getConnectorMap

public java.util.HashMap<java.lang.String,WebConnector> getConnectorMap()

createTagHandlerInstance

public <T extends javax.servlet.jsp.tagext.JspTag> T createTagHandlerInstance(WebModule module,
                                                                              java.lang.Class<T> clazz)
                                                                   throws java.lang.Exception
Instantiates and injects the given tag handler class for the given WebModule

Throws:
java.lang.Exception

createHttpListener

protected WebConnector createHttpListener(com.sun.grizzly.config.dom.NetworkListener listener,
                                          HttpService httpService)
Use an network-listener subelements and creates a corresponding Tomcat Connector for each.

Parameters:
httpService - The http-service element
listener - the configuration element.

createHttpListener

protected WebConnector createHttpListener(com.sun.grizzly.config.dom.NetworkListener listener,
                                          HttpService httpService,
                                          com.sun.grizzly.util.http.mapper.Mapper mapper)

createJKConnector

protected WebConnector createJKConnector(com.sun.grizzly.config.dom.NetworkListener listener,
                                         HttpService httpService)
Starts the AJP connector that will listen to call from Apache using mod_jk, mod_jk2 or mod_ajp.


configureHttpServiceProperties

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.


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

validateDocroot

protected void validateDocroot(java.lang.String docroot,
                               java.lang.String vs_id,
                               java.lang.String defaultWebModule)
Validate the docroot properties of a virtual-server.


configureHost

protected void configureHost(VirtualServer vs,
                             SecurityService securityService)
Configures the given virtual server.

Parameters:
vs - The virtual server to be configured
securityService - The security-service element

configureHostPortNumbers

protected void configureHostPortNumbers(VirtualServer vs,
                                        java.util.HashSet<com.sun.grizzly.config.dom.NetworkListener> listeners)
Configures the given virtual server with the port numbers of its associated http listeners.

Parameters:
vs - The virtual server to configure
listeners - The http listeners with which the given virtual server is associated

createHost

public VirtualServer createHost(java.lang.String vsID,
                                VirtualServer vsBean,
                                java.lang.String docroot,
                                MimeMap mimeMap)
Create a virtual server/host.


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:
java.lang.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


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.


loadDefaultWebModule

public void loadDefaultWebModule(VirtualServer vs)
Load a default-web-module on the specified virtual server.


loadStandaloneWebModule

protected void loadStandaloneWebModule(VirtualServer vs,
                                       WebModuleConfig wmInfo)
Load the specified web module as a standalone module on the specified virtual server.


isEnabled

protected boolean isEnabled(java.lang.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 java.util.List<Result<WebModule>> loadWebModule(WebModuleConfig wmInfo,
                                                       java.lang.String j2eeApplication,
                                                       java.util.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.


updateDefaultWebModule

protected void updateDefaultWebModule(VirtualServer virtualServer,
                                      java.lang.String[] listenerNames,
                                      WebModuleConfig wmInfo)
                               throws LifecycleException
Throws:
LifecycleException

getServerContext

public ServerContext getServerContext()
Utility Method to access the ServerContext


getApplicationId

public java.lang.String getApplicationId(WebModule wm)
The application id for this web module HERCULES:add


getModulesRoot

public java.io.File getModulesRoot()
Return the Absolute path for location where all the deployed standalone modules are stored for this Server Instance.


unloadWebModule

public void unloadWebModule(java.lang.String contextRoot,
                            java.lang.String appName,
                            java.lang.String virtualServers,
                            java.util.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.

unloadWebModule

public void unloadWebModule(java.lang.String contextRoot,
                            java.lang.String appName,
                            java.lang.String virtualServers,
                            boolean dummy,
                            java.util.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

suspendWebModule

public boolean suspendWebModule(java.lang.String contextRoot,
                                java.lang.String appName,
                                java.lang.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

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.


getEngine

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


registerAdHocPath

public void registerAdHocPath(java.lang.String path,
                              java.lang.String ctxtRoot,
                              java.lang.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(java.lang.String path,
                                        java.lang.String subtree,
                                        java.lang.String ctxtRoot,
                                        java.lang.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(java.lang.String path,
                                java.lang.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(java.lang.String path,
                                          java.lang.String subtree,
                                          java.lang.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

deleteHost

public void deleteHost(HttpService httpService)
                throws LifecycleException
Delete virtual-server.

Parameters:
httpService - element which contains the configuration info.
Throws:
LifecycleException

updateHost

public void updateHost(VirtualServer vsBean)
                throws LifecycleException
Updates a virtual-server element.

Parameters:
vsBean - the virtual-server config bean.
Throws:
LifecycleException

updateHostProperties

public void updateHostProperties(VirtualServer vsBean,
                                 java.lang.String name,
                                 java.lang.String value,
                                 SecurityService securityService,
                                 VirtualServer vs)
Update virtual-server properties.


updateHttpService

public void updateHttpService(HttpService httpService)
                       throws LifecycleException
Processes an update to the http-service element

Throws:
LifecycleException

updateConnectorProperty

public void updateConnectorProperty(com.sun.grizzly.config.dom.NetworkListener listener,
                                    java.lang.String propName,
                                    java.lang.String propValue)
                             throws LifecycleException
Update an http-listener property

Parameters:
listener - the configuration bean.
propName - the property name
propValue - the property value
Throws:
LifecycleException

updateConnector

public void updateConnector(com.sun.grizzly.config.dom.NetworkListener networkListener,
                            HttpService httpService)
                     throws LifecycleException
Update an network-listener

Parameters:
httpService - the configuration bean.
Throws:
LifecycleException

updateMapper

public void updateMapper(HttpService httpService,
                         com.sun.grizzly.config.dom.NetworkListener httpListener,
                         com.sun.grizzly.util.http.mapper.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

addConnector

public WebConnector addConnector(com.sun.grizzly.config.dom.NetworkListener httpListener,
                                 HttpService httpService,
                                 boolean start)
                          throws LifecycleException
Throws:
LifecycleException

deleteConnector

public void deleteConnector(WebConnector connector)
                     throws LifecycleException
Stops and deletes the specified http listener.

Throws:
LifecycleException

deleteConnector

public void deleteConnector(com.sun.grizzly.config.dom.NetworkListener httpListener)
                     throws LifecycleException
Stops and deletes the specified http listener.

Throws:
LifecycleException

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.


isTomcatUsingDefaultDomain

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


loadCommonClass

public java.lang.Class loadCommonClass(java.lang.String className)
                                throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2012 GlassFish Community. All Rights Reserved.