org.dellroad.stuff.servlet
Class OpenTransactionInViewFilter

java.lang.Object
  extended by org.springframework.web.filter.GenericFilterBean
      extended by org.springframework.web.filter.OncePerRequestFilter
          extended by org.dellroad.stuff.servlet.OpenTransactionInViewFilter
All Implemented Interfaces:
Filter, BeanNameAware, DisposableBean, InitializingBean, ServletContextAware

public class OpenTransactionInViewFilter
extends OncePerRequestFilter

Servlet filter that wraps execution in a transaction. A TransactionTemplate must exist in the associated WebApplicationContext and is identified by name via setTransactionManagerBeanName() (by default, DEFAULT_TRANSACTION_MANAGER_BEAN_NAME).

Transaction properties are configurable via filter <init-param>'s isolation, propagation, and readOnly.


Field Summary
static String DEFAULT_TRANSACTION_MANAGER_BEAN_NAME
           
protected  Logger log
           
 
Fields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX
 
Fields inherited from class org.springframework.web.filter.GenericFilterBean
logger
 
Constructor Summary
OpenTransactionInViewFilter()
           
 
Method Summary
protected  void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
           
protected  PlatformTransactionManager getTransactionManager()
           
protected  void initFilterBean()
           
 void setIsolation(String isolation)
           
 void setPropagation(String propagation)
           
 void setReadOnly(boolean readOnly)
           
 void setTransactionManagerBeanName(String transactionManagerBeanName)
           
 
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, setBeanName, setServletContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TRANSACTION_MANAGER_BEAN_NAME

public static final String DEFAULT_TRANSACTION_MANAGER_BEAN_NAME
See Also:
Constant Field Values

log

protected final Logger log
Constructor Detail

OpenTransactionInViewFilter

public OpenTransactionInViewFilter()
Method Detail

initFilterBean

protected void initFilterBean()
                       throws ServletException
Overrides:
initFilterBean in class GenericFilterBean
Throws:
ServletException

setIsolation

public void setIsolation(String isolation)

setPropagation

public void setPropagation(String propagation)

setReadOnly

public void setReadOnly(boolean readOnly)

setTransactionManagerBeanName

public void setTransactionManagerBeanName(String transactionManagerBeanName)

getTransactionManager

protected PlatformTransactionManager getTransactionManager()

doFilterInternal

protected void doFilterInternal(HttpServletRequest request,
                                HttpServletResponse response,
                                FilterChain filterChain)
                         throws ServletException,
                                IOException
Specified by:
doFilterInternal in class OncePerRequestFilter
Throws:
ServletException
IOException