org.apache.cayenne.conf
Class WebApplicationContextFilter

java.lang.Object
  extended by org.apache.cayenne.conf.WebApplicationContextFilter
All Implemented Interfaces:
javax.servlet.Filter

public class WebApplicationContextFilter
extends java.lang.Object
implements javax.servlet.Filter

A Servlet Filter that binds session DataContext to the current request thread. During the request application code without any knowledge of the servlet environment can access DataContext via DataContext.getThreadDataContext() method.

To enable the filter add XML similar to this in the web.xml descriptor of a web application:

  <filter>
   <filter-name>CayenneFilter</filter-name>
   <filter-class>org.apache.cayenne.conf.WebApplicationContextFilter</filter-class>
   </filter>
   <filter-mapping>
   <filter-name>CayenneFilter</filter-name>
   <url-pattern>/*</url-pattern>
   </filter-mapping>
 

Since:
1.2
Author:
Andrus Adamchik

Constructor Summary
WebApplicationContextFilter()
           
 
Method Summary
 void destroy()
          Cleanup callback method that does nothing, as the filter doesn't store any state.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          The main worker method that binds a DataContext to the current thread on entry and unbinds it on exit (regardless of whether any exceptions occured in the request).
 void init(javax.servlet.FilterConfig filterConfig)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebApplicationContextFilter

public WebApplicationContextFilter()
Method Detail

init

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

destroy

public void destroy()
Cleanup callback method that does nothing, as the filter doesn't store any state.

Specified by:
destroy in interface javax.servlet.Filter

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
The main worker method that binds a DataContext to the current thread on entry and unbinds it on exit (regardless of whether any exceptions occured in the request).

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
java.io.IOException
javax.servlet.ServletException


Copyright © 2001-2006 Apache.org All Rights Reserved.