com.hazelcast.web
Class WebFilter

java.lang.Object
  extended by com.hazelcast.web.WebFilter
All Implemented Interfaces:
javax.servlet.Filter
Direct Known Subclasses:
SpringAwareWebFilter

public class WebFilter
extends Object
implements javax.servlet.Filter

Provides clustered sessions by backing session data with an IMap.

Using this filter requires also registering a SessionListener to provide session timeout notifications. Failure to register the listener when using this filter will result in session state getting out of sync between the servlet container and Hazelcast.

This filter supports the following <init-param> values:


Nested Class Summary
protected  class WebFilter.HazelcastHttpSession
           
protected static class WebFilter.LocalCacheEntry
           
protected  class WebFilter.RequestWrapper
           
protected static class WebFilter.ResponseWrapper
           
 
Field Summary
protected  javax.servlet.FilterConfig filterConfig
           
protected static String HAZELCAST_REQUEST
           
protected static String HAZELCAST_SESSION_ATTRIBUTE_SEPARATOR
           
protected static String HAZELCAST_SESSION_COOKIE_NAME
           
protected static ILogger LOGGER
           
protected static WebFilter.LocalCacheEntry NULL_ENTRY
           
protected  javax.servlet.ServletContext servletContext
           
static String WEB_FILTER_ATTRIBUTE_KEY
           
 
Constructor Summary
WebFilter()
           
WebFilter(Properties properties)
           
 
Method Summary
protected  WebFilter.HazelcastHttpSession createHazelcastHttpSession(String id, javax.servlet.http.HttpSession originalSession, boolean deferredWrite)
          HazelcastHttpSession instance creation is split off to a separate method to allow subclasses to return a customized / extended version of HazelcastHttpSession.
protected  WebFilter.HazelcastHttpSession createNewSession(WebFilter.RequestWrapper requestWrapper, String existingSessionId)
           
 void destroy()
           
protected  void destroySession(WebFilter.HazelcastHttpSession session, boolean invalidate)
          Destroys a session, determining if it should be destroyed clusterwide automatically or via expiry.
 void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain)
           
protected  HazelcastInstance getInstance(Properties properties)
           
 void init(javax.servlet.FilterConfig config)
           
protected  void shutdownInstance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEB_FILTER_ATTRIBUTE_KEY

public static final String WEB_FILTER_ATTRIBUTE_KEY

HAZELCAST_SESSION_ATTRIBUTE_SEPARATOR

protected static final String HAZELCAST_SESSION_ATTRIBUTE_SEPARATOR
See Also:
Constant Field Values

LOGGER

protected static final ILogger LOGGER

NULL_ENTRY

protected static final WebFilter.LocalCacheEntry NULL_ENTRY

HAZELCAST_REQUEST

protected static final String HAZELCAST_REQUEST
See Also:
Constant Field Values

HAZELCAST_SESSION_COOKIE_NAME

protected static final String HAZELCAST_SESSION_COOKIE_NAME
See Also:
Constant Field Values

servletContext

protected javax.servlet.ServletContext servletContext

filterConfig

protected javax.servlet.FilterConfig filterConfig
Constructor Detail

WebFilter

public WebFilter()

WebFilter

public WebFilter(Properties properties)
Method Detail

init

public final void init(javax.servlet.FilterConfig config)
                throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

createNewSession

protected WebFilter.HazelcastHttpSession createNewSession(WebFilter.RequestWrapper requestWrapper,
                                                          String existingSessionId)

createHazelcastHttpSession

protected WebFilter.HazelcastHttpSession createHazelcastHttpSession(String id,
                                                                    javax.servlet.http.HttpSession originalSession,
                                                                    boolean deferredWrite)
HazelcastHttpSession instance creation is split off to a separate method to allow subclasses to return a customized / extended version of HazelcastHttpSession.

Parameters:
id - the session id
originalSession - the original session
deferredWrite - whether writes are deferred
Returns:
a new HazelcastHttpSession instance

destroySession

protected void destroySession(WebFilter.HazelcastHttpSession session,
                              boolean invalidate)
Destroys a session, determining if it should be destroyed clusterwide automatically or via expiry.

Parameters:
session - the session to be destroyed locally
invalidate - true if the session has been invalidated and should be destroyed on all nodes in the cluster; otherwise, false to only remove the session globally if this node was the final node referencing it

doFilter

public final void doFilter(javax.servlet.ServletRequest req,
                           javax.servlet.ServletResponse res,
                           javax.servlet.FilterChain chain)
                    throws IOException,
                           javax.servlet.ServletException
Specified by:
doFilter in interface javax.servlet.Filter
Throws:
IOException
javax.servlet.ServletException

destroy

public final void destroy()
Specified by:
destroy in interface javax.servlet.Filter

getInstance

protected HazelcastInstance getInstance(Properties properties)
                                 throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

shutdownInstance

protected void shutdownInstance()


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.