类 ContextLoaderListener
- 所有已实现的接口:
ServletContextListener,EventListener
WebApplicationContext.
Simply delegates to ContextLoader as well as to ContextCleanupListener.
ContextLoaderListener supports injecting the root web
application context via the ContextLoaderListener(WebApplicationContext)
constructor, allowing for programmatic configuration in Servlet initializers.
See ApplicationContextInitializer for usage examples.
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Chris Beams
- 另请参阅:
-
ContextLoader.setContextInitializers(cn.taketoday.context.ApplicationContextInitializer...)ApplicationContextInitializer
-
字段概要
从类继承的字段 cn.taketoday.web.servlet.ContextLoader
CONFIG_LOCATION_PARAM, CONTEXT_CLASS_PARAM, CONTEXT_ID_PARAM, CONTEXT_INITIALIZER_CLASSES_PARAM, GLOBAL_INITIALIZER_CLASSES_PARAM -
构造器概要
构造器构造器说明Create a newContextLoaderListenerthat will create a web application context based on the "contextClass" and "contextConfigLocation" servlet context-params.Create a newContextLoaderListenerwith the given application context. -
方法概要
修饰符和类型方法说明voidClose the root web application context.voidInitialize the root web application context.从类继承的方法 cn.taketoday.web.servlet.ContextLoader
closeWebApplicationContext, configureAndRefreshWebApplicationContext, createWebApplicationContext, customizeContext, determineContextClass, determineContextInitializerClasses, getCurrentWebApplicationContext, initWebApplicationContext, loadParentContext, setContextInitializers
-
构造器详细资料
-
ContextLoaderListener
public ContextLoaderListener()Create a newContextLoaderListenerthat will create a web application context based on the "contextClass" and "contextConfigLocation" servlet context-params. SeeContextLoadersuperclass documentation for details on default values for each.This constructor is typically used when declaring
ContextLoaderListeneras a<listener>withinweb.xml, where a no-arg constructor is required.The created application context will be registered into the ServletContext under the attribute name
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTEand the Framework application context will be closed when thecontextDestroyed(jakarta.servlet.ServletContextEvent)lifecycle method is invoked on this listener. -
ContextLoaderListener
Create a newContextLoaderListenerwith the given application context. This constructor is useful in Servlet initializers where instance-based registration of listeners is possible through theServletContext.addListener(java.lang.String)API.The context may or may not yet be refreshed. If it (a) is an implementation of
ConfigurableWebApplicationContextand (b) has not already been refreshed (the recommended approach), then the following will occur:- If the given context has not already been assigned an id, one will be assigned to it
ServletContextandServletConfigobjects will be delegated to the application contextContextLoader.customizeContext(jakarta.servlet.ServletContext, cn.taketoday.web.servlet.ConfigurableWebApplicationContext)will be called- Any
ApplicationContextInitializer cn.taketoday.context.ApplicationContextInitializer ApplicationContextInitializersspecified through the "contextInitializerClasses" init-param will be applied. refresh()will be called
ConfigurableWebApplicationContext, none of the above will occur under the assumption that the user has performed these actions (or not) per his or her specific needs.See
ApplicationContextInitializerfor usage examples.In any case, the given application context will be registered into the ServletContext under the attribute name
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTEand the Framework application context will be closed when thecontextDestroyed(jakarta.servlet.ServletContextEvent)lifecycle method is invoked on this listener.- 参数:
context- the application context to manage- 另请参阅:
-
-
方法详细资料
-
contextInitialized
Initialize the root web application context.- 指定者:
contextInitialized在接口中ServletContextListener
-
contextDestroyed
Close the root web application context.- 指定者:
contextDestroyed在接口中ServletContextListener
-