Class AbstractReactiveWebInitializer

All Implemented Interfaces:

public abstract class AbstractReactiveWebInitializer extends Object implements WebApplicationInitializer
Base class for a WebApplicationInitializer 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 reactive HttpHandler. The resulting handler is installed as a Servlet through the ServletHttpHandlerAdapter.

Rossen Stoyanchev, Sam Brannen
  • Field Details

  • Constructor Details

    • AbstractReactiveWebInitializer

      public AbstractReactiveWebInitializer()
  • Method Details

    • onStartup

      public void onStartup(ServletContext servletContext) throws ServletException
      Description copied from interface: WebApplicationInitializer
      Configure the given ServletContext with any servlets, filters, listeners context-params and attributes necessary for initializing this web application. See examples above.
      Specified by:
      onStartup in interface WebApplicationInitializer
      servletContext - the ServletContext to initialize
      ServletException - if any call against the given ServletContext throws a ServletException
    • getServletName

      protected String getServletName()
      Return the name to use to register the ServletHttpHandlerAdapter.

      By default this is DEFAULT_SERVLET_NAME.

    • createApplicationContext

      protected ApplicationContext createApplicationContext()
      Return the Spring configuration that contains application beans including the ones detected by WebHttpHandlerBuilder.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 a ServletContextListener that closes the given application context when the servlet context is destroyed.
      servletContext - the servlet context to listen to
      applicationContext - the application context that is to be closed when servletContext 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 '/'.