com.atlassian.confluence.web.filter
Class ConfluenceOpenSessionInViewFilter

java.lang.Object
  extended by org.springframework.web.filter.GenericFilterBean
      extended by org.springframework.web.filter.OncePerRequestFilter
          extended by org.springframework.orm.hibernate.support.OpenSessionInViewFilter
              extended by com.atlassian.confluence.web.filter.ConfluenceOpenSessionInViewFilter
All Implemented Interfaces:
javax.servlet.Filter, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.web.context.ServletContextAware

public class ConfluenceOpenSessionInViewFilter
extends org.springframework.orm.hibernate.support.OpenSessionInViewFilter

Extracted from com.atlassian.spring.filter.FlushingSpringSessionInViewFilter and FlushingSpringSessionInViewFilterForHibernate. We don't need all those subclasses and a library dependency. Simplifying to one subclass that extends the default OpenSessionInViewFilter and moving into core. Also added the ability to control whether the session should be flushed, by adding a check against the FlushMode of the session. For requests that perform read-only operations (such as Session.get() and Session.find()) against the database, flushing is unnecessary. Flushing does a dirty check against all objects attached to the session and attempts a synchronization with the database if necessary. This can be potentially very expensive as more objects are loaded into the session. It can also cause hibernate to acquire locks on the database for objects attached to the session that the client had absolutely no intention to change. In summary, performing read-only Session operations with a flush can produce unnecessary locking risks.


Field Summary
 
Fields inherited from class org.springframework.orm.hibernate.support.OpenSessionInViewFilter
DEFAULT_SESSION_FACTORY_BEAN_NAME
 
Fields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX
 
Fields inherited from class org.springframework.web.filter.GenericFilterBean
logger
 
Constructor Summary
ConfluenceOpenSessionInViewFilter()
           
 
Method Summary
protected  void closeSession(net.sf.hibernate.Session session, net.sf.hibernate.SessionFactory sessionFactory)
           
protected  void doFilterInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain)
           
 
Methods inherited from class org.springframework.orm.hibernate.support.OpenSessionInViewFilter
getSession, getSessionFactoryBeanName, isSingleSession, lookupSessionFactory, lookupSessionFactory, openSession, setSessionFactoryBeanName, setSingleSession
 
Methods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, getAlreadyFilteredAttributeName, shouldNotFilter
 
Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setServletContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfluenceOpenSessionInViewFilter

public ConfluenceOpenSessionInViewFilter()
Method Detail

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
Overrides:
doFilterInternal in class org.springframework.orm.hibernate.support.OpenSessionInViewFilter
Throws:
javax.servlet.ServletException
java.io.IOException

closeSession

protected void closeSession(net.sf.hibernate.Session session,
                            net.sf.hibernate.SessionFactory sessionFactory)
Overrides:
closeSession in class org.springframework.orm.hibernate.support.OpenSessionInViewFilter


Copyright © 2003-2014 Atlassian. All Rights Reserved.