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".
OpenPersistenceManagerInViewInterceptor
,
JdoTransactionManager
,
PersistenceManagerFactoryUtils.getPersistenceManager(javax.jdo.PersistenceManagerFactory, boolean)
,
TransactionSynchronizationManager
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_PERSISTENCE_MANAGER_FACTORY_BEAN_NAME |
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 String |
getPersistenceManagerFactoryBeanName()
Return the bean name of the PersistenceManagerFactory to fetch from Spring's
root application context.
|
protected javax.jdo.PersistenceManagerFactory |
lookupPersistenceManagerFactory()
Look up the PersistenceManagerFactory that this filter should use.
|
protected javax.jdo.PersistenceManagerFactory |
lookupPersistenceManagerFactory(HttpServletRequest request)
Look up the PersistenceManagerFactory that this filter should use,
taking the current HTTP request as argument.
|
void |
setPersistenceManagerFactoryBeanName(String persistenceManagerFactoryBeanName)
Set the bean name of the PersistenceManagerFactory to fetch from Spring's
root application context.
|
protected boolean |
shouldNotFilterAsyncDispatch()
Returns "false" so that the filter may re-bind the opened
PersistenceManager
to each asynchronously dispatched thread and postpone closing it until the very
last asynchronous dispatch. |
protected boolean |
shouldNotFilterErrorDispatch()
Returns "false" so that the filter may provide an
PersistenceManager
to each error dispatches. |
doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
public static final String DEFAULT_PERSISTENCE_MANAGER_FACTORY_BEAN_NAME
public void setPersistenceManagerFactoryBeanName(String persistenceManagerFactoryBeanName)
protected String getPersistenceManagerFactoryBeanName()
protected boolean shouldNotFilterAsyncDispatch()
PersistenceManager
to each asynchronously dispatched thread and postpone closing it until the very
last asynchronous dispatch.shouldNotFilterAsyncDispatch
in class OncePerRequestFilter
protected boolean shouldNotFilterErrorDispatch()
PersistenceManager
to each error dispatches.shouldNotFilterErrorDispatch
in class OncePerRequestFilter
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, 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
IOException
protected javax.jdo.PersistenceManagerFactory lookupPersistenceManagerFactory(HttpServletRequest request)
Default implementation delegates to the lookupPersistenceManagerFactory
without arguments.
lookupPersistenceManagerFactory()
protected javax.jdo.PersistenceManagerFactory lookupPersistenceManagerFactory()
getPersistenceManagerFactoryBeanName()