com.ervacon.springframework.web.servlet.mvc.webflow
Class WebFlowCleanupFilter

java.lang.Object
  extended byorg.springframework.web.filter.GenericFilterBean
      extended byorg.springframework.web.filter.OncePerRequestFilter
          extended bycom.ervacon.springframework.web.servlet.mvc.webflow.WebFlowCleanupFilter
All Implemented Interfaces:
javax.servlet.Filter

public class WebFlowCleanupFilter
extends org.springframework.web.filter.OncePerRequestFilter

Servlet 2.3 filter that cleans up expired web flows in the HTTP session associated with the request being filtered. A flow has expired when it has not handled any requests for more that a specified timeout period.

This filter can be configured in the web.xml deployment descriptor of your web application. Here's an example:

 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 	"http://java.sun.com/dtd/web-app_2_3.dtd">
 <web-app>
 	<filter>
 		<filter-name>webFlowCleanup</filter-name>
 		<filter-class>com.ervacon.springframework.web.servlet.mvc.webflow.WebFlowCleanupFilter</filter-class>
 	</filter>
 	<filter-mapping>
 		<filter-name>webFlowCleanup</filter-name>
 		<url-pattern>/*</url-pattern>
 	</filter-mapping>
 
 	...
 

Exposed configuration properties:

name default description
timeout 10 Specifies the flow timeout in minutes. If the flow is inactive for more that this period of time it will expire and be removed from the HTTP session.
These parameters can be configured using init-param values in the deployment descriptor.

Author:
Erwin Vervaet

Field Summary
static int DEFAULT_TIMEOUT
          Default web flow timout: 10 minutes.
 
Fields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX
 
Fields inherited from class org.springframework.web.filter.GenericFilterBean
logger
 
Constructor Summary
WebFlowCleanupFilter()
           
 
Method Summary
protected  void doCleanup(javax.servlet.http.HttpServletRequest request)
          Remove expired flows from the HTTP session associated with given request.
protected  void doFilterInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain)
           
 int getTimeout()
          Get the flow timout (expiry), expressed in minutes.
protected  boolean hasExpired(javax.servlet.http.HttpServletRequest request, WebFlowMementoStack mementos)
          Check if given web flow memento stack, found in the session associated with given request, has expired.
 void setTimeout(int timeout)
          Set the flow timout (expiry), expressed in minutes.
 
Methods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, getAlreadyFilteredAttributeName, shouldNotFilter
 
Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setFilterConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT

Default web flow timout: 10 minutes.

See Also:
Constant Field Values
Constructor Detail

WebFlowCleanupFilter

public WebFlowCleanupFilter()
Method Detail

getTimeout

public int getTimeout()

Get the flow timout (expiry), expressed in minutes.


setTimeout

public void setTimeout(int timeout)

Set the flow timout (expiry), expressed in minutes.


doFilterInternal

protected void doFilterInternal(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                javax.servlet.FilterChain filterChain)
                         throws javax.servlet.ServletException,
                                java.io.IOException
Throws:
javax.servlet.ServletException
java.io.IOException

doCleanup

protected void doCleanup(javax.servlet.http.HttpServletRequest request)

Remove expired flows from the HTTP session associated with given request.


hasExpired

protected boolean hasExpired(javax.servlet.http.HttpServletRequest request,
                             WebFlowMementoStack mementos)

Check if given web flow memento stack, found in the session associated with given request, has expired.

Subclasses can override this method if they want to change the expiry logic, e.g. to keep flows alive in certain situations.

Parameters:
request - current HTTP request
mementos - the web flow memento stack that needs to be checked for expiry