Class OpenPersistenceManagerInViewInterceptor
- java.lang.Object
-
- org.apache.isis.persistence.jdo.spring.support.OpenPersistenceManagerInViewInterceptor
-
- All Implemented Interfaces:
org.springframework.web.context.request.WebRequestInterceptor
public class OpenPersistenceManagerInViewInterceptor extends Object implements org.springframework.web.context.request.WebRequestInterceptor
Spring web request interceptor that binds a JDO PersistenceManager to the thread for the entire processing of the request. Intended for the "Open PersistenceManager in View" pattern, i.e. to allow for lazy loading in web views despite the original transactions already being completed.This interceptor makes JDO PersistenceManagers available via the current thread, which will be autodetected by transaction managers. It is suitable for service layer transactions via
JdoTransactionManagerorJtaTransactionManageras well as for non-transactional read-only execution.In contrast to
OpenPersistenceManagerInViewFilter, this interceptor is set up in a Spring application context and can thus take advantage of bean wiring.- See Also:
OpenPersistenceManagerInViewFilter,JdoTransactionManager,PersistenceManagerFactoryUtils.getPersistenceManager(javax.jdo.PersistenceManagerFactory, boolean),TransactionSynchronizationManager
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.Logloggerstatic StringPARTICIPATE_SUFFIXSuffix that gets appended to the PersistenceManagerFactory toString representation for the "participate in existing persistence manager handling" request attribute.
-
Constructor Summary
Constructors Constructor Description OpenPersistenceManagerInViewInterceptor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterCompletion(org.springframework.web.context.request.WebRequest request, Exception ex)protected StringgetParticipateAttributeName()Return the name of the request attribute that identifies that a request is already filtered.javax.jdo.PersistenceManagerFactorygetPersistenceManagerFactory()Return the JDO PersistenceManagerFactory that should be used to create PersistenceManagers.voidpostHandle(org.springframework.web.context.request.WebRequest request, org.springframework.ui.ModelMap model)voidpreHandle(org.springframework.web.context.request.WebRequest request)voidsetPersistenceManagerFactory(javax.jdo.PersistenceManagerFactory pmf)Set the JDO PersistenceManagerFactory that should be used to create PersistenceManagers.
-
-
-
Field Detail
-
PARTICIPATE_SUFFIX
public static final String PARTICIPATE_SUFFIX
Suffix that gets appended to the PersistenceManagerFactory toString representation for the "participate in existing persistence manager handling" request attribute.
-
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Detail
-
OpenPersistenceManagerInViewInterceptor
public OpenPersistenceManagerInViewInterceptor()
-
-
Method Detail
-
setPersistenceManagerFactory
public void setPersistenceManagerFactory(javax.jdo.PersistenceManagerFactory pmf)
Set the JDO PersistenceManagerFactory that should be used to create PersistenceManagers.
-
getPersistenceManagerFactory
public javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()
Return the JDO PersistenceManagerFactory that should be used to create PersistenceManagers.
-
preHandle
public void preHandle(org.springframework.web.context.request.WebRequest request) throws org.springframework.dao.DataAccessException
- Specified by:
preHandlein interfaceorg.springframework.web.context.request.WebRequestInterceptor- Throws:
org.springframework.dao.DataAccessException
-
postHandle
public void postHandle(org.springframework.web.context.request.WebRequest request, org.springframework.ui.ModelMap model)
- Specified by:
postHandlein interfaceorg.springframework.web.context.request.WebRequestInterceptor
-
afterCompletion
public void afterCompletion(org.springframework.web.context.request.WebRequest request, Exception ex) throws org.springframework.dao.DataAccessException
- Specified by:
afterCompletionin interfaceorg.springframework.web.context.request.WebRequestInterceptor- Throws:
org.springframework.dao.DataAccessException
-
getParticipateAttributeName
protected String getParticipateAttributeName()
Return the name of the request attribute that identifies that a request is already filtered. Default implementation takes the toString representation of the PersistenceManagerFactory instance and appends ".FILTERED".- See Also:
PARTICIPATE_SUFFIX
-
-