Class AbstractReactiveWebInitializer
- java.lang.Object
- org.springframework.web.server.adapter.AbstractReactiveWebInitializer
- All Implemented Interfaces:
WebApplicationInitializer
public abstract class AbstractReactiveWebInitializer extends Object implements WebApplicationInitializer
Base class for aWebApplicationInitializer
that installs a Spring Reactive Web Application on a Servlet container.Spring configuration is loaded and given to
WebHttpHandlerBuilder
which scans the context looking for specific beans and creates a reactiveHttpHandler
. The resulting handler is installed as a Servlet through theServletHttpHandlerAdapter
.- Since:
- 5.0.2
- Author:
- Rossen Stoyanchev
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_SERVLET_NAME
The default servlet name to use.
Constructor Summary
Constructors Constructor Description AbstractReactiveWebInitializer()
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ApplicationContext
createApplicationContext()
Return the Spring configuration that contains application beans including the ones detected byWebHttpHandlerBuilder.applicationContext
.protected abstract Class<?>[]
getConfigClasses()
Specify@Configuration
and/or@Component
classes that make up the application configuration.protected String
getServletMapping()
Return the Servlet mapping to use.protected String
getServletName()
Return the name to use to register theServletHttpHandlerAdapter
.void
onStartup(ServletContext servletContext)
Configure the givenServletContext
with any servlets, filters, listeners context-params and attributes necessary for initializing this web application.protected void
refreshApplicationContext(ApplicationContext context)
Refresh the given application context, if necessary.protected void
registerCloseListener(ServletContext servletContext, ApplicationContext applicationContext)
Register aServletContextListener
that closes the given application context when the servlet context is destroyed.
Field Detail
DEFAULT_SERVLET_NAME
public static final String DEFAULT_SERVLET_NAME
The default servlet name to use. SeegetServletName()
.- See Also:
- Constant Field Values
Constructor Detail
AbstractReactiveWebInitializer
public AbstractReactiveWebInitializer()
Method Detail
onStartup
public void onStartup(ServletContext servletContext) throws ServletException
Description copied from interface:WebApplicationInitializer
Configure the givenServletContext
with any servlets, filters, listeners context-params and attributes necessary for initializing this web application. See examples above.- Specified by:
onStartup
in interfaceWebApplicationInitializer
- Parameters:
servletContext
- theServletContext
to initialize- Throws:
ServletException
- if any call against the givenServletContext
throws aServletException
getServletName
protected String getServletName()
Return the name to use to register theServletHttpHandlerAdapter
.By default this is
DEFAULT_SERVLET_NAME
.
createApplicationContext
protected ApplicationContext createApplicationContext()
Return the Spring configuration that contains application beans including the ones detected byWebHttpHandlerBuilder.applicationContext
.
getConfigClasses
protected abstract Class<?>[] getConfigClasses()
Specify@Configuration
and/or@Component
classes that make up the application configuration. The config classes are given to createApplicationContext().
refreshApplicationContext
protected void refreshApplicationContext(ApplicationContext context)
Refresh the given application context, if necessary.
registerCloseListener
protected void registerCloseListener(ServletContext servletContext, ApplicationContext applicationContext)
Register aServletContextListener
that closes the given application context when the servlet context is destroyed.- Parameters:
servletContext
- the servlet context to listen toapplicationContext
- the application context that is to be closed whenservletContext
is destroyed
getServletMapping
protected String getServletMapping()
Return the Servlet mapping to use. Only the default Servlet mapping '/' and path-based Servlet mappings such as '/api/*' are supported.By default this is set to '/'.