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
Modifier and TypeFieldDescriptionstatic final String
The default name for Spring Session's repository filter. -
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a new instance that assumes the Spring Session configuration is loaded by some other means than this class.protected
AbstractHttpSessionApplicationInitializer
(Class<?>... configurationClasses) Creates a new instance that will instantiate theContextLoaderListener
with the specified classes. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
afterSessionRepositoryFilter
(jakarta.servlet.ServletContext servletContext) Invoked after the springSessionRepositoryFilter is added.protected final void
appendFilters
(jakarta.servlet.ServletContext servletContext, jakarta.servlet.Filter... filters) Inserts the providedFilter
s after existingFilter
s using default generated names,getSessionDispatcherTypes()
, andisAsyncSessionSupported()
.protected void
beforeSessionRepositoryFilter
(jakarta.servlet.ServletContext servletContext) Invoked before the springSessionRepositoryFilter is added.protected String
Return the<servlet-name>
to use the DispatcherServlet'sWebApplicationContext
to find theDelegatingFilterProxy
or null to use the parentApplicationContext
.protected EnumSet<jakarta.servlet.DispatcherType>
Get theDispatcherType
for the springSessionRepositoryFilter.protected final void
insertFilters
(jakarta.servlet.ServletContext servletContext, jakarta.servlet.Filter... filters) Inserts the providedFilter
s before existingFilter
s using default generated names,getSessionDispatcherTypes()
, andisAsyncSessionSupported()
.protected boolean
Determine if the springSessionRepositoryFilter should be marked as supporting asynch.void
onStartup
(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 aContextLoaderListener
using a subclass ofAbstractContextLoaderInitializer
.- See Also:
-
ContextLoaderListener
-
AbstractHttpSessionApplicationInitializer
Creates a new instance that will instantiate theContextLoaderListener
with the specified classes.- Parameters:
configurationClasses
-@Configuration
classes that will be used to configure the context
-
-
Method Details
-
onStartup
public void onStartup(jakarta.servlet.ServletContext servletContext) - Specified by:
onStartup
in interfaceorg.springframework.web.WebApplicationInitializer
-
insertFilters
protected final void insertFilters(jakarta.servlet.ServletContext servletContext, jakarta.servlet.Filter... filters) Inserts the providedFilter
s before existingFilter
s using default generated names,getSessionDispatcherTypes()
, andisAsyncSessionSupported()
.- Parameters:
servletContext
- theServletContext
to usefilters
- theFilter
s to register
-
appendFilters
protected final void appendFilters(jakarta.servlet.ServletContext servletContext, jakarta.servlet.Filter... filters) Inserts the providedFilter
s after existingFilter
s using default generated names,getSessionDispatcherTypes()
, andisAsyncSessionSupported()
.- Parameters:
servletContext
- theServletContext
to usefilters
- theFilter
s to register
-
getDispatcherWebApplicationContextSuffix
Return the<servlet-name>
to use the DispatcherServlet'sWebApplicationContext
to find theDelegatingFilterProxy
or 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 itsWebApplicationContext
or 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 theDispatcherType
for the springSessionRepositoryFilter.- Returns:
- the
DispatcherType
for 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
-