aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1652028 - /aries/trunk/jpa/jpa-container-context/src/main/java/org/apache/aries/jpa/container/context/transaction/impl/JTAEntityManagerHandler.java
Date Thu, 15 Jan 2015 10:13:11 GMT
Author: cschneider
Date: Thu Jan 15 10:13:11 2015
New Revision: 1652028

URL: http://svn.apache.org/r1652028
Log:
Factor out duplicate code

Modified:
    aries/trunk/jpa/jpa-container-context/src/main/java/org/apache/aries/jpa/container/context/transaction/impl/JTAEntityManagerHandler.java

Modified: aries/trunk/jpa/jpa-container-context/src/main/java/org/apache/aries/jpa/container/context/transaction/impl/JTAEntityManagerHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-context/src/main/java/org/apache/aries/jpa/container/context/transaction/impl/JTAEntityManagerHandler.java?rev=1652028&r1=1652027&r2=1652028&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container-context/src/main/java/org/apache/aries/jpa/container/context/transaction/impl/JTAEntityManagerHandler.java
(original)
+++ aries/trunk/jpa/jpa-container-context/src/main/java/org/apache/aries/jpa/container/context/transaction/impl/JTAEntityManagerHandler.java
Thu Jan 15 10:13:11 2015
@@ -97,17 +97,11 @@ public class JTAEntityManagerHandler imp
      */
     private EntityManager getPersistenceContext(boolean forceTransaction) {
         if (forceTransaction) {
-            EntityManager manager = activeManager.get();
-            if (manager != null) {
-                manager.clear();
-            }
+            clearDetachedManager();
             return reg.getCurrentPersistenceContext(emf, props, instanceCount, callback);
         } else {
             if (reg.isTransactionActive()) {
-                EntityManager manager = activeManager.get();
-                if (manager != null) {
-                    manager.clear();
-                }
+                clearDetachedManager();
                 return reg.getCurrentPersistenceContext(emf, props, instanceCount, callback);
             } else {
                 if (!!!reg.jtaIntegrationAvailable() && _logger.isDebugEnabled())
@@ -126,6 +120,13 @@ public class JTAEntityManagerHandler imp
         }
     }
 
+    private void clearDetachedManager() {
+        EntityManager manager = activeManager.get();
+        if (manager != null) {
+            manager.clear();
+        }
+    }
+
     /**
      * Called reflectively by blueprint
      */



Mime
View raw message