net.sf.click.extras.hibernate
Class SessionFilter
java.lang.Object
net.sf.click.extras.hibernate.SessionFilter
- All Implemented Interfaces:
- Filter
- public class SessionFilter
- extends Object
- implements Filter
Provides a Hibernate session filter to support the SessionContext class,
closing sessions at the end of each request.
To use SessionContext
configure the SessionFilter in you
web application's /WEB-INF/web.xml file.
<web-app>
<filter>
<filter-name>session-filter</filter-name>
<filter-class>net.sf.click.extras.hibernate.SessionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>session-filter</filter-name>
<servlet-name>click-servlet</servlet-name>
</filter-mapping>
<servlet>
<servlet-name>click-servlet</servlet-name>
..
</web-app>
The SessionFilter init() method loads the SessionContext class
which in turn initializes the Hibernate runtime.
- Author:
- Malcolm Edgar
- See Also:
SessionContext
,
HibernateForm
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SessionFilter
public SessionFilter()
init
public void init(FilterConfig filterConfig)
throws ServletException
- Initialize the Hibernate Configuration and SessionFactory.
- Specified by:
init
in interface Filter
- Parameters:
filterConfig
- the filter configuration
- Throws:
ServletException
- if an initialization error occurs- See Also:
Filter.init(FilterConfig)
destroy
public void destroy()
- Specified by:
destroy
in interface Filter
- See Also:
Filter.destroy()
doFilter
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException,
ServletException
- Close any user defined sessions if present.
- Specified by:
doFilter
in interface Filter
- Parameters:
request
- the servlet requestresponse
- the servlet responsechain
- the filter chain
- Throws:
IOException
- if an I/O error occurs
ServletException
- if a servlet error occurs- See Also:
Filter.doFilter(ServletRequest, ServletResponse, FilterChain)