Class AbstractHttpSessionApplicationInitializer
- All Implemented Interfaces:
org.springframework.web.WebApplicationInitializer
DelegatingFilterProxy to use the springSessionRepositoryFilter
before any other registered Filter. When used with
AbstractHttpSessionApplicationInitializer(Class...), it will also register a
ContextLoaderListener. When used with
AbstractHttpSessionApplicationInitializer(), this class is typically used in
addition to a subclass of AbstractContextLoaderInitializer.
By default the DelegatingFilterProxy is registered with support for
asynchronous requests, but can be enabled by overriding
isAsyncSessionSupported() and getSessionDispatcherTypes().
Additional configuration before and after the springSecurityFilterChain can be added by
overriding afterSessionRepositoryFilter(ServletContext).
Caveats
Subclasses of AbstractDispatcherServletInitializer will register their filters
before any other Filter. This means that you will typically want to ensure
subclasses of AbstractDispatcherServletInitializer are invoked first. This can
be done by ensuring the Order or Ordered of
AbstractDispatcherServletInitializer are sooner than subclasses of
AbstractSecurityWebApplicationInitializer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default name for Spring Session's repository filter. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new instance that assumes the Spring Session configuration is loaded by some other means than this class.protectedAbstractHttpSessionApplicationInitializer(Class<?>... configurationClasses) Creates a new instance that will instantiate theContextLoaderListenerwith the specified classes. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterSessionRepositoryFilter(jakarta.servlet.ServletContext servletContext) Invoked after the springSessionRepositoryFilter is added.protected final voidappendFilters(jakarta.servlet.ServletContext servletContext, jakarta.servlet.Filter... filters) Inserts the providedFilters after existingFilters using default generated names,getSessionDispatcherTypes(), andisAsyncSessionSupported().protected voidbeforeSessionRepositoryFilter(jakarta.servlet.ServletContext servletContext) Invoked before the springSessionRepositoryFilter is added.protected StringReturn the<servlet-name>to use the DispatcherServlet'sWebApplicationContextto find theDelegatingFilterProxyor null to use the parentApplicationContext.protected EnumSet<jakarta.servlet.DispatcherType>Get theDispatcherTypefor the springSessionRepositoryFilter.protected final voidinsertFilters(jakarta.servlet.ServletContext servletContext, jakarta.servlet.Filter... filters) Inserts the providedFilters before existingFilters using default generated names,getSessionDispatcherTypes(), andisAsyncSessionSupported().protected booleanDetermine if the springSessionRepositoryFilter should be marked as supporting asynch.voidonStartup(jakarta.servlet.ServletContext servletContext)
-
Field Details
-
DEFAULT_FILTER_NAME
The default name for Spring Session's repository filter.- See Also:
-
-
Constructor Details
-
AbstractHttpSessionApplicationInitializer
protected AbstractHttpSessionApplicationInitializer()Creates a new instance that assumes the Spring Session configuration is loaded by some other means than this class. For example, a user might create aContextLoaderListenerusing a subclass ofAbstractContextLoaderInitializer.- See Also:
-
ContextLoaderListener
-
AbstractHttpSessionApplicationInitializer
Creates a new instance that will instantiate theContextLoaderListenerwith the specified classes.- Parameters:
configurationClasses-@Configurationclasses that will be used to configure the context
-
-
Method Details
-
onStartup
public void onStartup(jakarta.servlet.ServletContext servletContext) - Specified by:
onStartupin interfaceorg.springframework.web.WebApplicationInitializer
-
insertFilters
protected final void insertFilters(jakarta.servlet.ServletContext servletContext, jakarta.servlet.Filter... filters) Inserts the providedFilters before existingFilters using default generated names,getSessionDispatcherTypes(), andisAsyncSessionSupported().- Parameters:
servletContext- theServletContextto usefilters- theFilters to register
-
appendFilters
protected final void appendFilters(jakarta.servlet.ServletContext servletContext, jakarta.servlet.Filter... filters) Inserts the providedFilters after existingFilters using default generated names,getSessionDispatcherTypes(), andisAsyncSessionSupported().- Parameters:
servletContext- theServletContextto usefilters- theFilters to register
-
getDispatcherWebApplicationContextSuffix
Return the<servlet-name>to use the DispatcherServlet'sWebApplicationContextto find theDelegatingFilterProxyor null to use the parentApplicationContext.For example, if you are using AbstractDispatcherServletInitializer or AbstractAnnotationConfigDispatcherServletInitializer and using the provided Servlet name, you can return "dispatcher" from this method to use the DispatcherServlet's
WebApplicationContext.- Returns:
- the
<servlet-name>of the DispatcherServlet to use itsWebApplicationContextor null (default) to use the parentApplicationContext.
-
beforeSessionRepositoryFilter
protected void beforeSessionRepositoryFilter(jakarta.servlet.ServletContext servletContext) Invoked before the springSessionRepositoryFilter is added.- Parameters:
servletContext- theServletContext
-
afterSessionRepositoryFilter
protected void afterSessionRepositoryFilter(jakarta.servlet.ServletContext servletContext) Invoked after the springSessionRepositoryFilter is added.- Parameters:
servletContext- theServletContext
-
getSessionDispatcherTypes
Get theDispatcherTypefor the springSessionRepositoryFilter.- Returns:
- the
DispatcherTypefor the filter
-
isAsyncSessionSupported
protected boolean isAsyncSessionSupported()Determine if the springSessionRepositoryFilter should be marked as supporting asynch. Default is true.- Returns:
- true if springSessionRepositoryFilter should be marked as supporting asynch
-