|
Spring Framework | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.web.context.AbstractContextLoaderInitializer
org.springframework.web.servlet.support.AbstractDispatcherServletInitializer
public abstract class AbstractDispatcherServletInitializer
Base class for WebApplicationInitializer
implementations that register a DispatcherServlet
in
the servlet context.
Concrete implementations are required to implement createServletApplicationContext()
, as well as getServletMappings()
, both of
which gets invoked from registerDispatcherServlet(ServletContext)
. Further
customization can be achieved by overriding
customizeRegistration(ServletRegistration.Dynamic)
.
Because this class extends from AbstractContextLoaderInitializer
, concrete
implementations are also required to implement AbstractContextLoaderInitializer.createRootApplicationContext()
to set up a parent "root" application context. If a root context is
not desired, implementations can simply return null
in the
createRootApplicationContext()
implementation.
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_SERVLET_NAME
The default servlet name. |
Fields inherited from class org.springframework.web.context.AbstractContextLoaderInitializer |
---|
logger |
Constructor Summary | |
---|---|
AbstractDispatcherServletInitializer()
|
Method Summary | |
---|---|
protected abstract WebApplicationContext |
createServletApplicationContext()
Create a servlet application context to be provided to the DispatcherServlet . |
protected void |
customizeRegistration(javax.servlet.ServletRegistration.Dynamic registration)
Optionally perform further registration customization once registerDispatcherServlet(ServletContext) has completed. |
protected abstract java.lang.String[] |
getServletMappings()
Specify the servlet mapping(s) for the DispatcherServlet , e.g. |
protected java.lang.String |
getServletName()
Return the name under which the DispatcherServlet will be registered. |
void |
onStartup(javax.servlet.ServletContext servletContext)
Configure the given ServletContext with any servlets, filters, listeners
context-params and attributes necessary for initializing this web application. |
protected void |
registerDispatcherServlet(javax.servlet.ServletContext servletContext)
Register a DispatcherServlet against the given servlet context. |
Methods inherited from class org.springframework.web.context.AbstractContextLoaderInitializer |
---|
createRootApplicationContext, registerContextLoaderListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_SERVLET_NAME
getServletName()
.
Constructor Detail |
---|
public AbstractDispatcherServletInitializer()
Method Detail |
---|
public void onStartup(javax.servlet.ServletContext servletContext) throws javax.servlet.ServletException
WebApplicationInitializer
ServletContext
with any servlets, filters, listeners
context-params and attributes necessary for initializing this web application. See
examples above.
onStartup
in interface WebApplicationInitializer
onStartup
in class AbstractContextLoaderInitializer
servletContext
- the ServletContext
to initialize
javax.servlet.ServletException
- if any call against the given ServletContext
throws a ServletException
protected void registerDispatcherServlet(javax.servlet.ServletContext servletContext)
DispatcherServlet
against the given servlet context.
This method will create a DispatcherServlet
with the name returned by
getServletName()
, initializing it with the application context returned
from createServletApplicationContext()
, and mapping it to the patterns
returned from getServletMappings()
.
Further customization can be achieved by overriding customizeRegistration(ServletRegistration.Dynamic)
.
servletContext
- the context to register the servlet againstprotected java.lang.String getServletName()
DispatcherServlet
will be registered.
Defaults to DEFAULT_SERVLET_NAME
.
registerDispatcherServlet(ServletContext)
protected abstract WebApplicationContext createServletApplicationContext()
DispatcherServlet
.
The returned context is delegated to Spring's
DispatcherServlet.DispatcherServlet(WebApplicationContext)
As such, it
typically contains controllers, view resolvers, locale resolvers, and other
web-related beans.
registerDispatcherServlet(ServletContext)
protected abstract java.lang.String[] getServletMappings()
DispatcherServlet
, e.g. '/', '/app',
etc.
registerDispatcherServlet(ServletContext)
protected void customizeRegistration(javax.servlet.ServletRegistration.Dynamic registration)
registerDispatcherServlet(ServletContext)
has completed.
registration
- the DispatcherServlet
registration to be customizedregisterDispatcherServlet(ServletContext)
|
Spring Framework | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |