Revert "[ARIES-1689] Fix initialization" This was broken. Reverting to Guiseppes solution.
git-svn-id: https://svn.apache.org/repos/asf/aries/trunk/jpa@1785796 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/4960fdc2 Tree: http://git-wip-us.apache.org/repos/asf/aries-jpa/tree/4960fdc2 Diff: http://git-wip-us.apache.org/repos/asf/aries-jpa/diff/4960fdc2 Branch: refs/heads/master Commit: 4960fdc205ebd79ad740857f3d54d2232886bd4a Parents: 3e7d639 Author: cschneider <cschneider@13f79535-47bb-0310-9956-ffa450edef68> Authored: Tue Mar 7 05:29:55 2017 +0000 Committer: cschneider <cschneider@13f79535-47bb-0310-9956-ffa450edef68> Committed: Tue Mar 7 05:29:55 2017 +0000 ---------------------------------------------------------------------- .../org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/4960fdc2/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java ---------------------------------------------------------------------- diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java index 93a37b1..a6d5bf2 100644 --- a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java +++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java @@ -19,7 +19,6 @@ package org.apache.aries.jpa.blueprint.impl; import java.lang.reflect.Method; -import java.util.concurrent.atomic.AtomicBoolean; import javax.persistence.EntityManager; import javax.persistence.spi.PersistenceUnitTransactionType; @@ -40,13 +39,11 @@ public class JpaInterceptor implements Interceptor { private BlueprintContainer container; private String coordinatorId; private String emId; - private AtomicBoolean initialized; public JpaInterceptor(BlueprintContainer container, String coordinatorId, String emId) { this.container = container; this.coordinatorId = coordinatorId; this.emId = emId; - this.initialized = new AtomicBoolean(false); } @Override @@ -56,7 +53,7 @@ public class JpaInterceptor implements Interceptor { @Override public Object preCall(ComponentMetadata cm, Method m, Object... parameters) throws Throwable { - if (!initialized.get()) { + if (coordinator == null || em == null) { initServices(); } try { @@ -74,7 +71,7 @@ public class JpaInterceptor implements Interceptor { } private synchronized void initServices() { - if (initialized.compareAndSet(false, true)) { + if (coordinator == null || em == null) { coordinator = (Coordinator)container.getComponentInstance(coordinatorId); em = (EntityManager)container.getComponentInstance(emId); }