@Order(value=100)
public abstract class AbstractHttpSessionApplicationInitializer
extends java.lang.Object
implements 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)
.
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
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_FILTER_NAME
The default name for Spring Session's repository filter.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractHttpSessionApplicationInitializer()
Creates a new instance that assumes the Spring Session configuration is loaded by
some other means than this class.
|
protected |
AbstractHttpSessionApplicationInitializer(java.lang.Class<?>... configurationClasses)
Creates a new instance that will instantiate the
ContextLoaderListener with
the specified classes. |
Modifier and Type | Method and Description |
---|---|
protected void |
afterSessionRepositoryFilter(ServletContext servletContext)
Invoked after the springSessionRepositoryFilter is added.
|
protected void |
appendFilters(ServletContext servletContext,
Filter... filters)
Inserts the provided
Filter s after existing Filter s using default
generated names, getSessionDispatcherTypes() , and
isAsyncSessionSupported() . |
protected void |
beforeSessionRepositoryFilter(ServletContext servletContext)
Invoked before the springSessionRepositoryFilter is added.
|
protected java.lang.String |
getDispatcherWebApplicationContextSuffix()
Return the
<servlet-name> to use the DispatcherServlet's
WebApplicationContext to find the DelegatingFilterProxy or null to
use the parent ApplicationContext . |
protected java.util.EnumSet<DispatcherType> |
getSessionDispatcherTypes()
Get the
DispatcherType for the springSessionRepositoryFilter. |
protected void |
insertFilters(ServletContext servletContext,
Filter... filters)
Inserts the provided
Filter s before existing Filter s using default
generated names, getSessionDispatcherTypes() , and
isAsyncSessionSupported() . |
protected boolean |
isAsyncSessionSupported()
Determine if the springSessionRepositoryFilter should be marked as supporting
asynch.
|
void |
onStartup(ServletContext servletContext) |
public static final java.lang.String DEFAULT_FILTER_NAME
protected AbstractHttpSessionApplicationInitializer()
ContextLoaderListener
using a subclass of
AbstractContextLoaderInitializer
.ContextLoaderListener
protected AbstractHttpSessionApplicationInitializer(java.lang.Class<?>... configurationClasses)
ContextLoaderListener
with
the specified classes.configurationClasses
- @Configuration
classes that will be used to
configure the contextpublic void onStartup(ServletContext servletContext) throws ServletException
onStartup
in interface org.springframework.web.WebApplicationInitializer
ServletException
protected final void insertFilters(ServletContext servletContext, Filter... filters)
Filter
s before existing Filter
s using default
generated names, getSessionDispatcherTypes()
, and
isAsyncSessionSupported()
.servletContext
- the ServletContext
to usefilters
- the Filter
s to registerprotected final void appendFilters(ServletContext servletContext, Filter... filters)
Filter
s after existing Filter
s using default
generated names, getSessionDispatcherTypes()
, and
isAsyncSessionSupported()
.servletContext
- the ServletContext
to usefilters
- the Filter
s to registerprotected java.lang.String getDispatcherWebApplicationContextSuffix()
<servlet-name>
to use the DispatcherServlet's
WebApplicationContext
to find the DelegatingFilterProxy
or null to
use the parent ApplicationContext
.
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
.
<servlet-name>
of the DispatcherServlet to use its
WebApplicationContext
or null (default) to use the parent
ApplicationContext
.protected void beforeSessionRepositoryFilter(ServletContext servletContext)
servletContext
- the ServletContext
protected void afterSessionRepositoryFilter(ServletContext servletContext)
servletContext
- the ServletContext
protected java.util.EnumSet<DispatcherType> getSessionDispatcherTypes()
DispatcherType
for the springSessionRepositoryFilter.DispatcherType
for the filterprotected boolean isAsyncSessionSupported()