aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1709880 - /aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
Date Wed, 21 Oct 2015 16:31:03 GMT
Author: cschneider
Date: Wed Oct 21 16:31:02 2015
New Revision: 1709880

URL: http://svn.apache.org/viewvc?rev=1709880&view=rev
Log:
Avoid instanciating persistence units when stopping

Modified:
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java?rev=1709880&r1=1709879&r2=1709880&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
(original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
Wed Oct 21 16:31:02 2015
@@ -48,8 +48,13 @@ public class PersistenceBundleTracker im
     }
 
     public synchronized Bundle addingBundle(Bundle bundle, BundleEvent event) {
+        if (event != null && event.getType() == BundleEvent.STOPPED) {
+            // Avoid starting persistence units in state STOPPED.
+            // TODO No idea why we are called at all in this state
+            return bundle;
+        }
         if (getTrackers(bundle).size() == 0) {
-            findPersistenceUnits(bundle);
+            findPersistenceUnits(bundle, event);
         }
         return bundle;
     }
@@ -66,11 +71,18 @@ public class PersistenceBundleTracker im
         providerTrackers.clear();
     }
 
-    private void findPersistenceUnits(Bundle bundle) {
+    private void findPersistenceUnits(Bundle bundle, BundleEvent event) {
         for (PersistenceUnit punit : PersistenceUnitParser.getPersistenceUnits(bundle)) {
             punit.addAnnotated();
             trackProvider(bundle, punit);
         }
+        if (getTrackers(bundle).size() > 0) {
+            LOGGER.info("Persistence units added for bundle " + bundle.getSymbolicName()
+ " event " + getEventType(event));
+        }
+    }
+
+    private Integer getEventType(BundleEvent event) {
+        return (event != null) ? event.getType() : null;
     }
 
     private void trackProvider(Bundle bundle, PersistenceUnit punit) {



Mime
View raw message