Top Description Inners Fields Constructors Methods
org.springframework.web.server.adapter

public abstract Class AbstractReactiveWebInitializer

extends Object
implements WebApplicationInitializer
Class Inheritance
All Implemented Interfaces
org.springframework.web.WebApplicationInitializer
Imports
jakarta.servlet.ServletContext, .ServletContextEvent, .ServletContextListener, .ServletException, .ServletRegistration, org.springframework.context.ApplicationContext, .ConfigurableApplicationContext, org.springframework.context.annotation.AnnotationConfigApplicationContext, org.springframework.http.server.reactive.HttpHandler, .ServletHttpHandlerAdapter, org.springframework.util.Assert, .ObjectUtils, .StringUtils, org.springframework.web.WebApplicationInitializer

Base class for a org.springframework.web.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.

Authors
Rossen Stoyanchev, Sam Brannen
Since
5.0.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
public static final String
DEFAULT_SERVLET_NAME

The default servlet name to use.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected ApplicationContext
createApplicationContext()

Return the Spring configuration that contains application beans including the ones detected by WebHttpHandlerBuilder#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 the ServletHttpHandlerAdapter.

public void
onStartup(ServletContext
the ServletContext to initialize
servletContext
)

Implements org.springframework.web.WebApplicationInitializer.onStartup.

Configure the given ServletContext 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
the servlet context to listen to
servletContext
,
ApplicationContext
the application context that is to be closed when servletContext is destroyed
applicationContext
)

Register a ServletContextListener that closes the given application context when the servlet context is destroyed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_SERVLET_NAMEback to summary
public static final String DEFAULT_SERVLET_NAME

The default servlet name to use. See getServletName.

Constructor Detail

AbstractReactiveWebInitializerback to summary
public AbstractReactiveWebInitializer()

Method Detail

createApplicationContextback to summary
protected ApplicationContext createApplicationContext()

Return the Spring configuration that contains application beans including the ones detected by WebHttpHandlerBuilder#applicationContext.

getConfigClassesback to summary
protected abstract Class<?>[] getConfigClasses()

Specify @Configuration and/or @Component classes that make up the application configuration. The config classes are given to createApplicationContext().

getServletMappingback to summary
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 '/'.

getServletNameback to summary
protected String getServletName()

Return the name to use to register the ServletHttpHandlerAdapter.

By default this is DEFAULT_SERVLET_NAME.

onStartupback to summary
public void onStartup(ServletContext servletContext) throws ServletException

Implements org.springframework.web.WebApplicationInitializer.onStartup.

Doc from org.springframework.web.WebApplicationInitializer.onStartup.

Configure the given ServletContext with any servlets, filters, listeners context-params and attributes necessary for initializing this web application. See examples above.

Parameters
servletContext:ServletContext

the ServletContext to initialize

Annotations
@Override
Exceptions
ServletException:
if any call against the given ServletContext throws a ServletException
refreshApplicationContextback to summary
protected void refreshApplicationContext(ApplicationContext context)

Refresh the given application context, if necessary.

registerCloseListenerback to summary
protected void registerCloseListener(ServletContext servletContext, ApplicationContext applicationContext)

Register a ServletContextListener that closes the given application context when the servlet context is destroyed.

Parameters
servletContext:ServletContext

the servlet context to listen to

applicationContext:ApplicationContext

the application context that is to be closed when servletContext is destroyed

org.springframework.web.server.adapter back to summary

private Class AbstractReactiveWebInitializer.ServletContextDestroyedListener

extends Object
implements ServletContextListener
Class Inheritance
  • java.lang.Object
  • org.springframework.web.server.adapter.AbstractReactiveWebInitializer.ServletContextDestroyedListener
All Implemented Interfaces
jakarta.servlet.ServletContextListener, java.util.EventListener

Field Summary

Modifier and TypeField and Description
private final ConfigurableApplicationContext

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
contextDestroyed(ServletContextEvent
Information about the ServletContext that was destroyed
sce
)

Overrides default jakarta.servlet.ServletContextListener.contextDestroyed.

Notification that the servlet context is about to be shut down.

public void
contextInitialized(ServletContextEvent
Information about the ServletContext that was initialized
sce
)

Overrides default jakarta.servlet.ServletContextListener.contextInitialized.

Notification that the web application initialization process is starting.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationContextback to summary
private final ConfigurableApplicationContext applicationContext

Constructor Detail

ServletContextDestroyedListenerback to summary
public ServletContextDestroyedListener(ConfigurableApplicationContext applicationContext)

Method Detail

contextDestroyedback to summary
public void contextDestroyed(ServletContextEvent sce)

Overrides default jakarta.servlet.ServletContextListener.contextDestroyed.

Doc from jakarta.servlet.ServletContextListener.contextDestroyed.

Notification that the servlet context is about to be shut down. All servlets and filters have been destroyed before any ServletContextListeners are notified of context destruction. The default implementation is a NO-OP.

Parameters
sce:ServletContextEvent

Information about the ServletContext that was destroyed

Annotations
@Override
contextInitializedback to summary
public void contextInitialized(ServletContextEvent sce)

Overrides default jakarta.servlet.ServletContextListener.contextInitialized.

Doc from jakarta.servlet.ServletContextListener.contextInitialized.

Notification that the web application initialization process is starting. All ServletContextListeners are notified of context initialization before any filter or servlet in the web application is initialized. The default implementation is a NO-OP.

Parameters
sce:ServletContextEvent

Information about the ServletContext that was initialized

Annotations
@Override