public class WebSessionFilter extends Object implements javax.servlet.Filter
This is a request filter, that you need to specify in your web.xml along
with ServletContextListenerStartup to enable web sessions caching:
<listener>
<listener-class>org.apache.ignite.startup.servlet.ServletContextListenerStartup</listener-class>
</listener>
<filter>
<filter-name>WebSessionFilter</filter-name>
<filter-class>org.apache.ignite.cache.websession.WebSessionFilter</filter-class>
</filter>
<!-- You can also specify a custom URL pattern. -->
<filter-mapping>
<filter-name>IgniteWebSessionsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
It is also possible to specify a servlet name in a filter mapping, and a servlet URL pattern will
be used in this case:
<filter>
<filter-name>WebSessionFilter</filter-name>
<filter-class>org.apache.ignite.cache.websession.WebSessionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>WebSessionFilter</filter-name>
<servlet-name>YourServletName</servlet-name>
</filter-mapping>
The filter has the following optional configuration parameters:
| Name | Description | Default |
|---|---|---|
| IgniteWebSessionsGridName | Name of the grid that contains cache for web session storage. | null (default grid) |
| IgniteWebSessionsCacheName | Name of the cache for web session storage. | null (default cache) |
| IgniteWebSessionsMaximumRetriesOnFail |
Valid for ATOMIC caches only. Maximum number of retries for session updates in case
node leaves topology and update fails. If retry is enabled,
some updates can be applied more than once, otherwise some
updates can be lost.
To disable retries, set this parameter to |
3 |
| IgniteWebSessionsRetriesTimeout |
Retry timeout. Related to IgniteWebSessionsMaximumRetriesOnFail param.
Further attempts will be cancelled in case timeout was exceeded. |
10000 (10 seconds) |
<filter>
<filter-name>WebSessionFilter</filter-name>
<filter-class>org.apache.ignite.cache.websession.WebSessionFilter</filter-class>
<init-param>
<param-name>IgniteWebSessionsGridName</param-name>
<param-value>WebGrid</param-value>
</init-param>
<init-param>
<param-name>IgniteWebSessionsCacheName</param-name>
<param-value>WebCache</param-value>
</init-param>
<!-- Valid for ATOMIC caches only. -->
<init-param>
<param-name>IgniteWebSessionsMaximumRetriesOnFail</param-name>
<param-value>10</param-value>
</init-param>
</filter>
Note: filter init parameter has a priority over servlet context
parameter; if you specify both, the servlet context parameter will be ignored.
CacheAtomicityMode.TRANSACTIONAL cache
instead of CacheAtomicityMode.ATOMIC. In this case each request
be processed inside pessimistic transaction which will guarantee that all
updates will be applied in correct order. This is important, for example,
if you get some attribute from the session, update its value and set new
value back to the session. In case of CacheAtomicityMode.ATOMIC
cache concurrent requests can get equal value, but CacheAtomicityMode.TRANSACTIONAL
cache will always process such updates one after another.| Modifier and Type | Field and Description |
|---|---|
static int |
DFLT_MAX_RETRIES_ON_FAIL
Default retry on fail flag value.
|
static int |
DFLT_RETRIES_ON_FAIL_TIMEOUT
Default retry on fail timeout flag value.
|
static String |
WEB_SES_CACHE_NAME_PARAM
Web sessions caching cache name parameter name.
|
static String |
WEB_SES_MAX_RETRIES_ON_FAIL_NAME_PARAM
Web sessions caching retry on fail parameter name (valid for ATOMIC cache only).
|
static String |
WEB_SES_NAME_PARAM
Web sessions caching grid name parameter name.
|
static String |
WEB_SES_RETRIES_TIMEOUT_NAME_PARAM
Web sessions caching retry on fail timeout parameter name.
|
| Constructor and Description |
|---|
WebSessionFilter() |
public static final String WEB_SES_NAME_PARAM
public static final String WEB_SES_CACHE_NAME_PARAM
public static final String WEB_SES_MAX_RETRIES_ON_FAIL_NAME_PARAM
public static final String WEB_SES_RETRIES_TIMEOUT_NAME_PARAM
public static final int DFLT_MAX_RETRIES_ON_FAIL
public static final int DFLT_RETRIES_ON_FAIL_TIMEOUT
public void init(javax.servlet.FilterConfig cfg)
throws javax.servlet.ServletException
init in interface javax.servlet.Filterjavax.servlet.ServletExceptionpublic void destroy()
destroy in interface javax.servlet.Filterpublic void doFilter(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse res,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
doFilter in interface javax.servlet.FilterIOExceptionjavax.servlet.ServletException
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.11 Release Date : April 8 2016