aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [15/50] aries-jpa git commit: [ARIES-1575] Use bundle context of persistence bundle for tracker
Date Tue, 18 Apr 2017 12:55:07 GMT
[ARIES-1575] Use bundle context of persistence bundle for tracker

git-svn-id: https://svn.apache.org/repos/asf/aries/trunk/jpa@1766052 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/508754d9
Tree: http://git-wip-us.apache.org/repos/asf/aries-jpa/tree/508754d9
Diff: http://git-wip-us.apache.org/repos/asf/aries-jpa/diff/508754d9

Branch: refs/heads/master
Commit: 508754d9bd6fcbe8025cbd0e099a989f6c8dfb4e
Parents: 127990e
Author: cschneider <cschneider@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Fri Oct 21 15:48:30 2016 +0000
Committer: cschneider <cschneider@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Fri Oct 21 15:48:30 2016 +0000

----------------------------------------------------------------------
 .../java/org/apache/aries/jpa/container/impl/Activator.java   | 2 +-
 .../aries/jpa/container/impl/PersistenceBundleTracker.java    | 7 ++-----
 .../aries/jpa/container/impl/PersistenceProviderTracker.java  | 3 +--
 3 files changed, 4 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/508754d9/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java
----------------------------------------------------------------------
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java
b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java
index 67c7c56..6f51d85 100644
--- a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java
@@ -38,7 +38,7 @@ public class Activator implements BundleActivator {
     public void start(BundleContext context) throws Exception {
         registerWeavingHook(context, TransformerRegistrySingleton.get());
 
-        PersistenceBundleTracker customizer = new PersistenceBundleTracker(context);
+        PersistenceBundleTracker customizer = new PersistenceBundleTracker();
         persistenceBundleManager = new BundleTracker<Bundle>(context, Bundle.STARTING
| Bundle.ACTIVE, customizer);
         persistenceBundleManager.open();
     }

http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/508754d9/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 f468cfa..6981256 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
@@ -27,7 +27,6 @@ import java.util.Map;
 import org.apache.aries.jpa.container.parser.impl.PersistenceUnit;
 import org.apache.aries.jpa.container.parser.impl.PersistenceUnitParser;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.util.tracker.BundleTrackerCustomizer;
 import org.slf4j.Logger;
@@ -40,11 +39,9 @@ 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 containerContext;
     private Map<Integer, String> typeMap;
 
-    public PersistenceBundleTracker(BundleContext context) {
-        this.containerContext = context;
+    public PersistenceBundleTracker() {
         trackers = new HashMap<Bundle, Collection<PersistenceProviderTracker>>();
         this.typeMap = new HashMap<Integer, String>();
         this.typeMap.put(BundleEvent.INSTALLED, "INSTALLED");
@@ -102,7 +99,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(containerContext,
punit);
+        PersistenceProviderTracker tracker = new PersistenceProviderTracker(bundle.getBundleContext(),
punit);
         tracker.open();
         getTrackers(bundle).add(tracker);
     }

http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/508754d9/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 91e53ff..67d46e2 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
@@ -81,8 +81,7 @@ public class PersistenceProviderTracker extends ServiceTracker<PersistenceProvid
         StoredPerProvider stored = new StoredPerProvider();
         LOGGER.info("Found provider for " + punit.getPersistenceUnitName() + " " + punit.getPersistenceProviderClassName());
         
-        // This get must happen using the persistence bundle's context to avoid ARIES-1575
-        PersistenceProvider provider = punit.getBundle().getBundleContext().getService(reference);
+        PersistenceProvider provider = context.getService(reference);
 
         createAndCloseDummyEMF(provider);
 


Mime
View raw message