You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2017/04/18 12:55:02 UTC

[10/50] aries-jpa git commit: [ARIES-1575] Use the Persistence Bundle's context to get the Persistence Provider

[ARIES-1575] Use the Persistence Bundle's context to get the Persistence Provider

git-svn-id: https://svn.apache.org/repos/asf/aries/trunk/jpa@1748744 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/aries-jpa/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jpa/commit/ac32967f
Tree: http://git-wip-us.apache.org/repos/asf/aries-jpa/tree/ac32967f
Diff: http://git-wip-us.apache.org/repos/asf/aries-jpa/diff/ac32967f

Branch: refs/heads/master
Commit: ac32967f1c7c33f661b55f858f3e7d53f4b3378b
Parents: ad5990d
Author: timothyjward <ti...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu Jun 16 15:20:52 2016 +0000
Committer: timothyjward <ti...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu Jun 16 15:20:52 2016 +0000

----------------------------------------------------------------------
 .../aries/jpa/container/impl/PersistenceBundleTracker.java   | 6 +++---
 .../aries/jpa/container/impl/PersistenceProviderTracker.java | 8 +++++---
 2 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/ac32967f/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
----------------------------------------------------------------------
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
index b777741..f468cfa 100644
--- a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
@@ -40,11 +40,11 @@ import org.slf4j.LoggerFactory;
 public class PersistenceBundleTracker implements BundleTrackerCustomizer<Bundle> {
     private static final Logger LOGGER = LoggerFactory.getLogger(PersistenceBundleTracker.class);
     private final Map<Bundle, Collection<PersistenceProviderTracker>> trackers;
-    private final BundleContext context;
+    private final BundleContext containerContext;
     private Map<Integer, String> typeMap;
 
     public PersistenceBundleTracker(BundleContext context) {
-        this.context = context;
+        this.containerContext = context;
         trackers = new HashMap<Bundle, Collection<PersistenceProviderTracker>>();
         this.typeMap = new HashMap<Integer, String>();
         this.typeMap.put(BundleEvent.INSTALLED, "INSTALLED");
@@ -102,7 +102,7 @@ public class PersistenceBundleTracker implements BundleTrackerCustomizer<Bundle>
         LOGGER.info(String.format("Found persistence unit %s in bundle %s with provider %s.",
                                   punit.getPersistenceUnitName(), bundle.getSymbolicName(),
                                   punit.getPersistenceProviderClassName()));
-        PersistenceProviderTracker tracker = new PersistenceProviderTracker(context, punit);
+        PersistenceProviderTracker tracker = new PersistenceProviderTracker(containerContext, punit);
         tracker.open();
         getTrackers(bundle).add(tracker);
     }

http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/ac32967f/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java
----------------------------------------------------------------------
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java
index 787b2fd..91e53ff 100644
--- a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java
@@ -48,8 +48,8 @@ public class PersistenceProviderTracker extends ServiceTracker<PersistenceProvid
 
     private PersistenceUnit punit;
 
-    public PersistenceProviderTracker(BundleContext context, PersistenceUnit punit) {
-        super(context, createFilter(context, punit), null);
+    public PersistenceProviderTracker(BundleContext containerContext, PersistenceUnit punit) {
+        super(containerContext, createFilter(containerContext, punit), null);
         this.punit = punit;
     }
 
@@ -80,7 +80,9 @@ public class PersistenceProviderTracker extends ServiceTracker<PersistenceProvid
         }
         StoredPerProvider stored = new StoredPerProvider();
         LOGGER.info("Found provider for " + punit.getPersistenceUnitName() + " " + punit.getPersistenceProviderClassName());
-        PersistenceProvider provider = context.getService(reference);
+        
+        // This get must happen using the persistence bundle's context to avoid ARIES-1575
+        PersistenceProvider provider = punit.getBundle().getBundleContext().getService(reference);
 
         createAndCloseDummyEMF(provider);