|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.click.extras.cayenne.DataContextFilter
Provides a servlet filter which binds DataContext objects to the request. This filter will automatically rollback any uncommitted changes at which binds the user's session scope DataContext to the current thread. This filter will automatically rollback any uncommitted changes at the end of each request.
When the click application is in debug or trace mode this filter will log any uncommitted data objects at the end of each request. For units of work spanning multiple requests, such as a multi-page work flow, it is recommended that you add a separate DataContext to the session for the unit of work.<web-app> <filter> <filter-name>data-context-filter</filter-name> <filter-class>net.sf.click.extras.cayenne.DataContextFilter</filter-class> </filter> <filter-mapping> <filter-name>data-context-filter</filter-name> <servlet-name>click-servlet</servlet-name> </filter-mapping> <servlet> <servlet-name>click-servlet</servlet-name> .. </web-app>An example data context filter configuration in the web application's /WEB-INF/web.xml file is provided below. This example creates a new DataContext object for each request and does not use the Cayenne shared cache when creating DataContext objects. This configuration is useful when multiple applications are making changes to the database.
<web-app> <filter> <filter-name>data-context-filter</filter-name> <filter-class>net.sf.click.extras.cayenne.DataContextFilter</filter-class> <init-param> <param-name>session-scope</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>shared-cache</param-name> <param-value>false</param-value> </init-param> </filter> <filter-mapping> <filter-name>data-context-filter</filter-name> <servlet-name>click-servlet</servlet-name> </filter-mapping> <servlet> <servlet-name>click-servlet</servlet-name> .. </web-app>
WebApplicationContextFilter
.
Field Summary | |
protected boolean |
autoRollback
Automatically rollback any changes to the DataContext at the end of each request, the default value is true. |
protected org.apache.log4j.Logger |
logger
The DataContextFilter logger. |
protected boolean |
sessionScope
Maintain user HttpSession scope DataContext object, the default value is true. |
protected boolean |
sharedCache
Create DataContext objects using the shared cache. |
Constructor Summary | |
DataContextFilter()
|
Method Summary | |
void |
destroy()
Destroy the DataContextFilter. |
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
This filter binds the session DataContext to the current thread, and removes the DataContext from the thread once the chained request has completed. |
protected org.apache.cayenne.access.DataContext |
getDataContext(HttpServletRequest request)
Return a DataContext instance. |
void |
init(FilterConfig config)
Initialize the shared Cayenne configuration. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean autoRollback
protected boolean sessionScope
protected boolean sharedCache
protected org.apache.log4j.Logger logger
Constructor Detail |
public DataContextFilter()
Method Detail |
public void init(FilterConfig config) throws ServletException
init
in interface Filter
config
- the filter configuration
ServletException
- if an initialization error occursFilter.init(FilterConfig)
public void destroy()
destroy
in interface Filter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
doFilter
in interface Filter
request
- the servlet requestresponse
- the servlet responsechain
- the filter chain
IOException
- if an I/O error occurs
ServletException
- if a servlet error occursprotected org.apache.cayenne.access.DataContext getDataContext(HttpServletRequest request)
request
- the page request
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |