public class OpenPersistenceManagerInViewFilter extends OncePerRequestFilter
This filter makes JDO PersistenceManagers available via the current thread,
which will be autodetected by transaction managers. It is suitable for service
layer transactions via JdoTransactionManager
or JtaTransactionManager
as well
as for non-transactional read-only execution.
Looks up the PersistenceManagerFactory in Spring's root web application context.
Supports a "persistenceManagerFactoryBeanName" filter init-param in web.xml
;
the default bean name is "persistenceManagerFactory". Looks up the PersistenceManagerFactory
on each request, to avoid initialization order issues (when using ContextLoaderServlet,
the root application context will get initialized after this filter).
OpenPersistenceManagerInViewInterceptor
,
JdoInterceptor
,
JdoTransactionManager
,
PersistenceManagerFactoryUtils.getPersistenceManager(PersistenceManagerFactory, boolean)
,
TransactionSynchronizationManager
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_PERSISTENCE_MANAGER_FACTORY_BEAN_NAME |
private java.lang.String |
persistenceManagerFactoryBeanName |
ALREADY_FILTERED_SUFFIX
logger
Constructor and Description |
---|
OpenPersistenceManagerInViewFilter() |
Modifier and Type | Method and Description |
---|---|
protected void |
doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain)
Same contract as for
doFilter , but guaranteed to be
just invoked once per request within a single request thread. |
protected java.lang.String |
getPersistenceManagerFactoryBeanName()
Return the bean name of the PersistenceManagerFactory to fetch from Spring's
root application context.
|
protected PersistenceManagerFactory |
lookupPersistenceManagerFactory()
Look up the PersistenceManagerFactory that this filter should use.
|
protected PersistenceManagerFactory |
lookupPersistenceManagerFactory(HttpServletRequest request)
Look up the PersistenceManagerFactory that this filter should use,
taking the current HTTP request as argument.
|
void |
setPersistenceManagerFactoryBeanName(java.lang.String persistenceManagerFactoryBeanName)
Set the bean name of the PersistenceManagerFactory to fetch from Spring's
root application context.
|
doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
public static final java.lang.String DEFAULT_PERSISTENCE_MANAGER_FACTORY_BEAN_NAME
private java.lang.String persistenceManagerFactoryBeanName
public void setPersistenceManagerFactoryBeanName(java.lang.String persistenceManagerFactoryBeanName)
protected java.lang.String getPersistenceManagerFactoryBeanName()
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, java.io.IOException
OncePerRequestFilter
doFilter
, but guaranteed to be
just invoked once per request within a single request thread.
See OncePerRequestFilter.shouldNotFilterAsyncDispatch()
for details.
Provides HttpServletRequest and HttpServletResponse arguments instead of the default ServletRequest and ServletResponse ones.
doFilterInternal
in class OncePerRequestFilter
ServletException
java.io.IOException
protected PersistenceManagerFactory lookupPersistenceManagerFactory(HttpServletRequest request)
Default implementation delegates to the lookupPersistenceManagerFactory
without arguments.
lookupPersistenceManagerFactory()
protected PersistenceManagerFactory lookupPersistenceManagerFactory()
getPersistenceManagerFactoryBeanName()