org.apache.cayenne.conf
Class WebApplicationContextFilter
java.lang.Object
org.apache.cayenne.conf.WebApplicationContextFilter
- All Implemented Interfaces:
- Filter
public class WebApplicationContextFilter
- extends Object
- implements 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
Method Summary |
void |
destroy()
Cleanup callback method that does nothing, as the filter doesn't store any state. |
void |
doFilter(ServletRequest request,
ServletResponse response,
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(FilterConfig filterConfig)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WebApplicationContextFilter
public WebApplicationContextFilter()
init
public void init(FilterConfig filterConfig)
throws ServletException
- Specified by:
init
in interface Filter
- Throws:
ServletException
destroy
public void destroy()
- Cleanup callback method that does nothing, as the filter doesn't store any state.
- Specified by:
destroy
in interface Filter
doFilter
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException,
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 Filter
- Throws:
IOException
ServletException
Copyright © 2001-2007 Apache Cayenne. All Rights Reserved.