com.interface21.orm.jdo
Class PersistenceManagerFactoryUtils
java.lang.Object
|
+--com.interface21.orm.jdo.PersistenceManagerFactoryUtils
- public abstract class PersistenceManagerFactoryUtils
- extends java.lang.Object
Helper class featuring methods for JDO PersistenceManager handling,
allowing for reuse of PersistenceManager instances within transactions.
Used by JdoTemplate, JdoInterceptor, and JdoTransactionManager.
- Since:
- 03.06.2003
- Author:
- Juergen Hoeller
- See Also:
JdoTemplate,
JdoInterceptor,
JdoTransactionManager
|
Method Summary |
static void |
closePersistenceManagerIfNecessary(javax.jdo.PersistenceManager pm,
javax.jdo.PersistenceManagerFactory pmf)
Close the given PersistenceManager, created via the given factory,
if it isn't bound to the thread. |
static DataAccessException |
convertJdoAccessException(javax.jdo.JDOException ex)
Convert the given JDOException to an appropriate exception from
the com.interface21.dao hierarchy. |
static javax.jdo.PersistenceManagerFactory |
createPersistenceManagerFactory(java.lang.String configLocation)
Create a JDO PersistenceManagerFactory with the given config file. |
static javax.jdo.PersistenceManager |
getPersistenceManager(javax.jdo.PersistenceManagerFactory pmf,
boolean allowCreate)
Get a JDO PersistenceManager via the given factory.
|
static ThreadObjectManager |
getThreadObjectManager()
Return the thread object manager for JDO PersistenceManagers keeping a
PersistenceManagerFactory/PersistenceManagerHolder map per thread for
JDO transactions. |
static boolean |
isPersistenceManagerBoundToThread(javax.jdo.PersistenceManager pm,
javax.jdo.PersistenceManagerFactory pmf)
Return if the given PersistenceManager is bound to the current thread,
for the given PersistenceManagerFactory. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PersistenceManagerFactoryUtils
public PersistenceManagerFactoryUtils()
getThreadObjectManager
public static ThreadObjectManager getThreadObjectManager()
- Return the thread object manager for JDO PersistenceManagers keeping a
PersistenceManagerFactory/PersistenceManagerHolder map per thread for
JDO transactions.
- Returns:
- the thread object manager
- See Also:
getPersistenceManager(javax.jdo.PersistenceManagerFactory, boolean),
JdoTransactionManager
isPersistenceManagerBoundToThread
public static boolean isPersistenceManagerBoundToThread(javax.jdo.PersistenceManager pm,
javax.jdo.PersistenceManagerFactory pmf)
- Return if the given PersistenceManager is bound to the current thread,
for the given PersistenceManagerFactory.
- Parameters:
pm - PersistenceManager that should be checkedpmf - PersistenceManagerFactory that the PersistenceManager was created with- Returns:
- if the PersistenceManager is bound for the PersistenceManagerFactory
createPersistenceManagerFactory
public static javax.jdo.PersistenceManagerFactory createPersistenceManagerFactory(java.lang.String configLocation)
throws DataAccessResourceFailureException
- Create a JDO PersistenceManagerFactory with the given config file.
- Parameters:
configLocation - location of the config file (can be a URL
or a classpath resource)- Returns:
- the new PersistenceManagerFactory instance
- Throws:
DataAccessResourceFailureException - if the PersistenceManagerFactory could not be created
getPersistenceManager
public static javax.jdo.PersistenceManager getPersistenceManager(javax.jdo.PersistenceManagerFactory pmf,
boolean allowCreate)
throws DataAccessResourceFailureException
- Get a JDO PersistenceManager via the given factory.
Is aware of a respective PersistenceManager bound to the current thread,
for example when using JdoTransactionManager.
Will create a new PersistenceManager else, if allowCreate is true.
- Parameters:
pmf - PersistenceManagerFactory to create the session withallowCreate - if a new PersistenceManager should be created if no thread-bound found- Returns:
- the PersistenceManager
- Throws:
DataAccessResourceFailureException - if the PersistenceManager couldn't be createdjava.lang.IllegalStateException - if no thread-bound PersistenceManager found and allowCreate false
convertJdoAccessException
public static DataAccessException convertJdoAccessException(javax.jdo.JDOException ex)
- Convert the given JDOException to an appropriate exception from
the com.interface21.dao hierarchy.
- Parameters:
ex - JDOException that occured- Returns:
- the corresponding DataAccessException instance
closePersistenceManagerIfNecessary
public static void closePersistenceManagerIfNecessary(javax.jdo.PersistenceManager pm,
javax.jdo.PersistenceManagerFactory pmf)
throws CleanupFailureDataAccessException
- Close the given PersistenceManager, created via the given factory,
if it isn't bound to the thread.
- Parameters:
pm - PersistenceManager to closepmf - PersistenceManagerFactory that the PersistenceManager was created with- Throws:
DataAccessResourceFailureException - if the PersistenceManager couldn't be closed
Rod Johnson and Spring contributors 2001-2003.