Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.orm.jdo.support
Class OpenPersistenceManagerInViewInterceptor

    java.lang.Object
      org.springframework.orm.jdo.support.OpenPersistenceManagerInViewInterceptor

All Implemented Interfaces:
  WebRequestInterceptor

    public class OpenPersistenceManagerInViewInterceptor

extends Object
implements 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 `JdoTransactionManager` or `JtaTransactionManager` as 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. It inherits common JDO configuration properties from `JdoAccessor`, to be configured in a bean definition.

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(WebRequest request, Exception ex)` Callback after completion of request processing, that is, after rendering the view.
`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.
`void` | `postHandle(WebRequest request, ModelMap model)` Intercept the execution of a request handler after its successful invocation, right before view rendering (if any).
`void` | `preHandle(WebRequest request)` Intercept the execution of a request handler before its invocation.
`void` | `setPersistenceManagerFactory(javax.jdo.PersistenceManagerFactory pmf)` Set the JDO PersistenceManagerFactory that should be used to create PersistenceManagers.

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 void preHandle(WebRequest request)
                   throws DataAccessException

  Description copied from interface: `WebRequestInterceptor`
  Intercept the execution of a request handler before its invocation.

  Allows for preparing context resources (such as a Hibernate Session) and expose them as request attributes or as thread-local objects.

  Specified by:
    `preHandle` in interface `WebRequestInterceptor`
  Parameters:
    `request` - the current web request
  Throws:
    `DataAccessException`

### postHandle

    public void postHandle(WebRequest request,
                           ModelMap model)

  Description copied from interface: `WebRequestInterceptor`
  Intercept the execution of a request handler after its successful invocation, right before view rendering (if any).

  Allows for modifying context resources after successful handler execution (for example, flushing a Hibernate Session).

  Specified by:
    `postHandle` in interface `WebRequestInterceptor`
  Parameters:
    `request` - the current web request
    `model` - the map of model objects that will be exposed to the view (may be `null`). Can be used to analyze the exposed model and/or to add further model attributes, if desired.

### afterCompletion

    public void afterCompletion(WebRequest request,
                                Exception ex)
                         throws DataAccessException

  Description copied from interface: `WebRequestInterceptor`
  Callback after completion of request processing, that is, after rendering the view. Will be called on any outcome of handler execution, thus allows for proper resource cleanup.

  Note: Will only be called if this interceptor's `preHandle` method has successfully completed!

  Specified by:
    `afterCompletion` in interface `WebRequestInterceptor`
  Parameters:
    `request` - the current web request
    `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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2007 The Spring Framework.