类 AbstractContextLoaderInitializer
- java.lang.Object
- org.springframework.web.context.AbstractContextLoaderInitializer
- 所有已实现的接口:
WebApplicationInitializer
public abstract class AbstractContextLoaderInitializer extends Object implements WebApplicationInitializer
Convenient base class forWebApplicationInitializer
implementations that register aContextLoaderListener
in the servlet context.The only method required to be implemented by subclasses is
createRootApplicationContext()
, which gets invoked fromregisterContextLoaderListener(ServletContext)
.- 从以下版本开始:
- 3.2
- 作者:
- Arjen Poutsma, Chris Beams, Juergen Hoeller
构造器概要
构造器 构造器 说明 AbstractContextLoaderInitializer()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected abstract WebApplicationContext
createRootApplicationContext()
Create the "root" application context to be provided to theContextLoaderListener
.protected ApplicationContextInitializer<?>[]
getRootApplicationContextInitializers()
Specify application context initializers to be applied to the root application context that theContextLoaderListener
is being created with.void
onStartup(ServletContext servletContext)
Configure the givenServletContext
with any servlets, filters, listeners context-params and attributes necessary for initializing this web application.protected void
registerContextLoaderListener(ServletContext servletContext)
Register aContextLoaderListener
against the given servlet context.
构造器详细资料
AbstractContextLoaderInitializer
public AbstractContextLoaderInitializer()
方法详细资料
onStartup
public void onStartup(ServletContext servletContext) throws ServletException
从接口复制的说明:WebApplicationInitializer
Configure the givenServletContext
with any servlets, filters, listeners context-params and attributes necessary for initializing this web application. See examples above.- 指定者:
onStartup
在接口中WebApplicationInitializer
- 参数:
servletContext
- theServletContext
to initialize- 抛出:
ServletException
- if any call against the givenServletContext
throws aServletException
registerContextLoaderListener
protected void registerContextLoaderListener(ServletContext servletContext)
Register aContextLoaderListener
against the given servlet context. TheContextLoaderListener
is initialized with the application context returned from thecreateRootApplicationContext()
template method.- 参数:
servletContext
- the servlet context to register the listener against
createRootApplicationContext
@Nullable protected abstract WebApplicationContext createRootApplicationContext()
Create the "root" application context to be provided to theContextLoaderListener
.The returned context is delegated to
ContextLoaderListener(WebApplicationContext)
and will be established as the parent context for anyDispatcherServlet
application contexts. As such, it typically contains middle-tier services, data sources, etc.- 返回:
- the root application context, or
null
if a root context is not desired - 另请参阅:
AbstractDispatcherServletInitializer
getRootApplicationContextInitializers
@Nullable protected ApplicationContextInitializer<?>[] getRootApplicationContextInitializers()
Specify application context initializers to be applied to the root application context that theContextLoaderListener
is being created with.