Package com.sun.enterprise.web
Class WebContainer
- java.lang.Object
-
- com.sun.enterprise.web.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.glassfish.api.event.EventListener
EventListener.Event<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_debug
Controls the verbosity of the web container subsystem's debug messages.protected 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 WebConfigListener
configListener
protected int
defaultRedirectPort
The default-redirect portstatic String
DISPATCHER_MAX_DEPTH
protected String
globalAccessLogBufferSize
AccessLog buffer size for storing logs.protected boolean
globalAccessLoggingEnabled
Allow disabling accessLog mechanismprotected String
globalAccessLogPrefix
AccessLog prefixprotected 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 HttpServiceStatsProviderBootstrap
httpStatsProviderBootstrap
protected ServerEnvironment
instance
protected JspProbeProvider
jspProbeProvider
static String
JWS_APPCLIENT_EAR_NAME
static String
JWS_APPCLIENT_WAR_NAME
protected RequestProbeProvider
requestProbeProvider
protected ServletProbeProvider
servletProbeProvider
protected SessionProbeProvider
sessionProbeProvider
protected WebContainerFeatureFactory
webContainerFeatureFactory
protected WebModuleProbeProvider
webModuleProbeProvider
-
Constructor Summary
Constructors Constructor Description WebContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description WebConnector
addConnector(NetworkListener httpListener, HttpService httpService, boolean start)
protected void
configureHost(VirtualServer virtualServer, SecurityService securityService)
Configures the given virtual server.protected void
configureHostPortNumbers(VirtualServer virtualServer, HashSet<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.VirtualServer
createHost(VirtualServer vsBean, HttpService httpService, SecurityService securityService)
Creates a Host from a virtual-server config bean.VirtualServer
createHost(String virtualServerId, VirtualServer virtualServerBean, String docroot, MimeMap mimeMap)
Create a virtual server/host.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(NetworkListener listener, HttpService httpService)
Use an network-listener subelements and creates a corresponding Tomcat Connector for each.protected WebConnector
createHttpListener(NetworkListener listener, HttpService httpService, org.glassfish.grizzly.http.server.util.Mapper mapper)
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.<T extends jakarta.servlet.jsp.tagext.JspTag>
TcreateTagHandlerInstance(WebModule module, Class<T> clazz)
Instantiates and injects the given tag handler class for the given WebModulevoid
deleteConnector(WebConnector connector)
Stops and deletes the specified http listener.void
deleteConnector(NetworkListener httpListener)
Stops and deletes the specified http listener.void
deleteHost(HttpService httpService)
Delete virtual-server.void
event(EventListener.Event<?> event)
Process a Glassfish/Payara eventLifecycleListener[]
findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle.String
getApplicationId(WebModule webModule)
The application id for this web module HERCULES:addMap<String,WebConnector>
getConnectorMap()
Class<? extends WebDeployer>
getDeployer()
Returns the Deployer implementation capable of deploying applications to this container.Engine
getEngine()
Return the parent/top-level container in _embedded for virtual servers.HttpService
getHttpService()
WebConnector
getJkConnector()
JspProbeProvider
getJspProbeProvider()
Gets the probe provider for jsp related events.File
getModulesRoot()
Return the Absolute path for location where all the deployed standalone modules are stored for this Server Instance.String
getName()
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.RequestProbeProvider
getRequestProbeProvider()
Gets the probe provider for request/response related events.ServerContext
getServerContext()
Utility Method to access the ServerContextServletProbeProvider
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(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()
Returns true if the container has been shut down.protected boolean
isTomcatUsingDefaultDomain()
is Tomcat using default domain name as its domainClass<?>
loadCommonClass(String className)
void
loadDefaultWebModule(VirtualServer vsBean)
Load a default-web-module on the specified virtual server.void
loadDefaultWebModule(VirtualServer virtualServer)
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 virtualServer, WebModuleConfig webModuleConfig)
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 "/"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.void
postConstruct()
void
preDestroy()
void
registerAdHocPath(String path, String ctxtRoot, String appName, AdHocServletInfo servletInfo)
Registers the given ad-hoc path at the given context root.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.void
stop()
Gracefully terminate the active use of the public methods of this component.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.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.void
unloadWebModule(String contextRoot, String appName, String virtualServers, boolean dummy, Properties props)
Undeploy a web application.void
unloadWebModule(String contextRoot, String appName, String virtualServers, Properties props)
Undeploy a web application.void
unregisterAdHocPath(String path, String ctxtRoot)
Unregisters the given ad-hoc path from the given context root.void
unregisterAdHocPathAndSubtree(String path, String subtree, 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 theelement from domain.xml. void
updateConnector(NetworkListener networkListener, HttpService httpService)
Update an network-listenervoid
updateConnectorProperty(NetworkListener listener, String propName, String propValue)
Update an http-listener propertyprotected void
updateDefaultWebModule(VirtualServer virtualServer, String[] listenerNames, WebModuleConfig webModuleConfig)
Updates the given virtual server with the given default path.void
updateHost(VirtualServer vsBean)
Updates a virtual-server element.void
updateHostProperties(VirtualServer vsBean, String name, String value, SecurityService securityService, VirtualServer virtualServer)
Update virtual-server properties.void
updateHttpService(HttpService httpService)
Processes an update to the http-service elementvoid
updateJvmRoute(HttpService httpService, String jvmOption)
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.protected void
validateDocroot(String docroot, String virtualServerId, String defaultWebModule)
Validate the docroot properties of a virtual-server.
-
-
-
Field Detail
-
DISPATCHER_MAX_DEPTH
public static final String DISPATCHER_MAX_DEPTH
- See Also:
- Constant Field Values
-
JWS_APPCLIENT_EAR_NAME
public static final String JWS_APPCLIENT_EAR_NAME
- See Also:
- Constant Field Values
-
JWS_APPCLIENT_WAR_NAME
public static final String JWS_APPCLIENT_WAR_NAME
- See Also:
- Constant Field Values
-
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
-
instance
@Inject 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 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
-
httpStatsProviderBootstrap
protected HttpServiceStatsProviderBootstrap httpStatsProviderBootstrap
-
-
Method Detail
-
postConstruct
public void postConstruct()
- Specified by:
postConstruct
in interfaceorg.glassfish.hk2.api.PostConstruct
-
event
public void event(EventListener.Event<?> event)
Description copied from interface:EventListener
Process a Glassfish/Payara event- Specified by:
event
in interfaceEventListener
-
preDestroy
public void preDestroy()
- Specified by:
preDestroy
in interfaceorg.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.
-
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 interfaceContainer
- Returns:
- the Deployer implementation
-
getJkConnector
public WebConnector getJkConnector()
-
getConnectorMap
public Map<String,WebConnector> getConnectorMap()
-
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:
-
createHttpListener
protected WebConnector createHttpListener(NetworkListener listener, HttpService httpService, org.glassfish.grizzly.http.server.util.Mapper mapper)
-
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 checksConfigure 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 elementsecurityService
- 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 beanhttpService
- 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 configuredsecurityService
- 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 configurelisteners
- 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 startedLifecycleException
- 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 updateports
- The port numbers of the HTTP listeners with which the given virtual server is associateddefaultContextPath
- 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 undeployappName
- the J2EE appname used at deployment timevirtualServers
- 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 undeployappName
- the J2EE appname used at deployment timevirtualServers
- 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 docrootprops
-
-
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 rootappName
- the J2EE appname used at deployment timehosts
- 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 rootappName
- the J2EE appname used at deployment timehosts
- the list of virtual serversfromDisableStartEvent
- 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:
-
getHttpService
public HttpService getHttpService()
-
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 registerctxtRoot
- The context root at which to registerappName
- The name of the application with which the ad-hoc path is associatedservletInfo
- 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 registersubtree
- The ad-hoc subtree path to registerctxtRoot
- The context root at which to registerappName
- The name of the application with which the ad-hoc path and subtree are associatedservletInfo
- 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 unregisterctxtRoot
- 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 unregistersubtree
- The ad-hoc subtree to unregisterctxtRoot
- 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, String name, String value, SecurityService securityService, VirtualServer virtualServer)
Update virtual-server properties.- Parameters:
vsBean
-name
-value
-virtualServer
-securityService
-
-
updateHttpService
public void updateHttpService(HttpService httpService) throws LifecycleException
Processes an update to the http-service element- Parameters:
httpService
-- Throws:
LifecycleException
-
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 namepropValue
- the property value- Throws:
LifecycleException
-
updateConnector
public void updateConnector(NetworkListener networkListener, HttpService httpService) throws LifecycleException
Update an network-listener- Parameters:
networkListener
-httpService
- the configuration bean.- 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
, whichMapper
was changedmapper
- newMapper
value
-
addConnector
public WebConnector addConnector(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.- Parameters:
connector
-- Throws:
LifecycleException
-
deleteConnector
public void deleteConnector(NetworkListener httpListener) throws LifecycleException
Stops and deletes the specified http listener.- Parameters:
httpListener
-- Throws:
LifecycleException
-
updateAccessLog
public void updateAccessLog(HttpService httpService)
Reconfigures the access log valve of each virtual server with the updated attributes of theelement 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
-
-