openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwsut...@apache.org
Subject svn commit: r915015 - /openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
Date Mon, 22 Feb 2010 18:53:45 GMT
Author: kwsutter
Date: Mon Feb 22 18:53:45 2010
New Revision: 915015

URL: http://svn.apache.org/viewvc?rev=915015&view=rev
Log:
OPENJPA-1516.  Introduce prepareForPooling method on EntityManagerImpl to allow for more efficient
EntityManager "clear" operations.  This also allows to go outside of the spec just a bit and
clean up resources before pooling as well.

Modified:
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java?rev=915015&r1=915014&r2=915015&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
Mon Feb 22 18:53:45 2010
@@ -1108,6 +1108,23 @@
         throw new ArgumentException(flushMode.toString(), null, null, false);
     }
 
+    /*
+     * Used by Java EE Containers that wish to pool OpenJPA EntityManagers.  The specification
+     * doesn't allow the closing of connections with the clear() method.  By introducing
this
+     * new method, we can do additional processing (and maybe more efficient processing)
to 
+     * properly prepare an EM for pooling.
+     */
+    public void prepareForPooling() {
+        assertNotCloseInvoked();
+        clear();
+        _broker.lock();  // since this direct close path is not protected...
+        try {
+            _broker.getStoreManager().close();
+        } finally {
+            _broker.unlock();
+        }
+    }
+    
     public void clear() {
         assertNotCloseInvoked();
         _broker.detachAll(this, false);



Mime
View raw message