org.springframework.orm.jdo.support
Class OpenPersistenceManagerInViewInterceptor

java.lang.Object
  extended by org.springframework.web.servlet.handler.HandlerInterceptorAdapter
      extended by org.springframework.orm.jdo.support.OpenPersistenceManagerInViewInterceptor
All Implemented Interfaces:
HandlerInterceptor

public class OpenPersistenceManagerInViewInterceptor
extends HandlerInterceptorAdapter

Spring web HandlerInterceptor 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 filter works similar to the AOP JdoInterceptor: It just makes JDO PersistenceManagers available via the thread. It is suitable for non-transactional execution but also for middle tier transactions via JdoTransactionManager or JtaTransactionManager. In the latter case, PersistenceManagers pre-bound by this filter will automatically be used for the transactions.

In contrast to OpenPersistenceManagerInViewFilter, this interceptor is set up in a Spring application context and can thus take advantage of bean wiring. It derives from JdoAccessor to inherit common JDO configuration properties.

Since:
1.1
Author:
Juergen Hoeller
See Also:
OpenPersistenceManagerInViewFilter, JdoInterceptor, JdoTransactionManager, PersistenceManagerFactoryUtils.getPersistenceManager(javax.jdo.PersistenceManagerFactory, boolean), TransactionSynchronizationManager

Field Summary
protected  Log logger
           
static String PARTICIPATE_SUFFIX
          Suffix that gets appended to the PersistenceManagerFactory toString representation for the "participate in existing persistence manager handling" request attribute.
 
Constructor Summary
OpenPersistenceManagerInViewInterceptor()
           
 
Method Summary
 void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
          This implementation is empty.
protected  String getParticipateAttributeName()
          Return the name of the request attribute that identifies that a request is already filtered.
 javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()
          Return the JDO PersistenceManagerFactory that should be used to create PersistenceManagers.
 boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
          This implementation always returns true.
 void setPersistenceManagerFactory(javax.jdo.PersistenceManagerFactory pmf)
          Set the JDO PersistenceManagerFactory that should be used to create PersistenceManagers.
 
Methods inherited from class org.springframework.web.servlet.handler.HandlerInterceptorAdapter
postHandle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.

See Also:
getParticipateAttributeName(), Constant Field Values

logger

protected final 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 boolean preHandle(HttpServletRequest request,
                         HttpServletResponse response,
                         Object handler)
                  throws DataAccessException
Description copied from class: HandlerInterceptorAdapter
This implementation always returns true.

Specified by:
preHandle in interface HandlerInterceptor
Overrides:
preHandle in class HandlerInterceptorAdapter
Parameters:
request - current HTTP request
response - current HTTP response
handler - chosen handler to execute, for type and/or instance evaluation
Returns:
true if the execution chain should proceed with the next interceptor or the handler itself. Else, DispatcherServlet assumes that this interceptor has already dealt with the response itself.
Throws:
DataAccessException

afterCompletion

public void afterCompletion(HttpServletRequest request,
                            HttpServletResponse response,
                            Object handler,
                            Exception ex)
                     throws DataAccessException
Description copied from class: HandlerInterceptorAdapter
This implementation is empty.

Specified by:
afterCompletion in interface HandlerInterceptor
Overrides:
afterCompletion in class HandlerInterceptorAdapter
Parameters:
request - current HTTP request
response - current HTTP response
handler - chosen handler to execute, for type and/or instance examination
ex - exception thrown on handler execution, if any
Throws:
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


Copyright (c) 2002-2007 The Spring Framework Project.