tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject [2/2] tomee git commit: synchronization for persistence unit from @PersistenceContext
Date Tue, 07 Apr 2015 22:12:36 GMT
synchronization for persistence unit from @PersistenceContext


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3bf595f3
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3bf595f3
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3bf595f3

Branch: refs/heads/master
Commit: 3bf595f3c045a5d1644d99b5cff07933c3b24fc0
Parents: dc66eb5
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Wed Apr 8 00:12:27 2015 +0200
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Wed Apr 8 00:12:27 2015 +0200

----------------------------------------------------------------------
 .../org/apache/openejb/config/AnnotationDeployer.java |  7 +++++++
 .../apache/openejb/config/PersistenceContextAnn.java  |  2 ++
 .../openejb/config/PersistenceContextAnnFactory.java  | 14 ++++++++++++++
 3 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/3bf595f3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
index f4713bf..c47e3b1 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
@@ -84,6 +84,7 @@ import org.apache.openejb.jee.NamedMethod;
 import org.apache.openejb.jee.OutboundResourceAdapter;
 import org.apache.openejb.jee.ParamValue;
 import org.apache.openejb.jee.PersistenceContextRef;
+import org.apache.openejb.jee.PersistenceContextSynchronization;
 import org.apache.openejb.jee.PersistenceContextType;
 import org.apache.openejb.jee.PersistenceUnitRef;
 import org.apache.openejb.jee.PortComponent;
@@ -4555,6 +4556,9 @@ public class AnnotationDeployer implements DynamicDeployer {
             PersistenceContextRef persistenceContextRef = consumer.getPersistenceContextRefMap().get(refName);
             if (persistenceContextRef == null) {
                 persistenceContextRef = new PersistenceContextRef();
+                if (persistenceContext.synchronization() != null) { // should be the case
in "normal" deployments
+                    persistenceContextRef.setPersistenceContextSynchronization(PersistenceContextSynchronization.valueOf(persistenceContext.synchronization().toUpperCase(Locale.ENGLISH)));
+                }
                 persistenceContextRef.setPersistenceUnitName(persistenceContext.unitName());
                 persistenceContextRef.setPersistenceContextRefName(refName);
                 if ("EXTENDED".equalsIgnoreCase(persistenceContext.type())) {
@@ -4574,6 +4578,9 @@ public class AnnotationDeployer implements DynamicDeployer {
                         persistenceContextRef.setPersistenceContextType(PersistenceContextType.TRANSACTION);
                     }
                 }
+                if (persistenceContextRef.getPersistenceContextSynchronization() == null
&& persistenceContext.synchronization() != null) {
+                    persistenceContextRef.setPersistenceContextSynchronization(PersistenceContextSynchronization.valueOf(persistenceContext.synchronization().toUpperCase(Locale.ENGLISH)));
+                }
             }
 
             List<Property> persistenceProperties = persistenceContextRef.getPersistenceProperty();

http://git-wip-us.apache.org/repos/asf/tomee/blob/3bf595f3/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceContextAnn.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceContextAnn.java
b/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceContextAnn.java
index de59f66..aaf70b8 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceContextAnn.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceContextAnn.java
@@ -22,6 +22,8 @@ import java.util.Map;
 public interface PersistenceContextAnn {
     String name();
 
+    String synchronization();
+
     String unitName();
 
     String type();

http://git-wip-us.apache.org/repos/asf/tomee/blob/3bf595f3/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceContextAnnFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceContextAnnFactory.java
b/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceContextAnnFactory.java
index cc4bd61..ee9671c 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceContextAnnFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/PersistenceContextAnnFactory.java
@@ -28,6 +28,7 @@ import org.apache.xbean.asm5.shade.commons.EmptyVisitor;
 
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceProperty;
+import javax.persistence.SynchronizationType;
 import java.io.IOException;
 import java.net.URL;
 import java.util.HashMap;
@@ -112,6 +113,11 @@ public class PersistenceContextAnnFactory {
             return persistenceContext.name();
         }
 
+        @Override
+        public String synchronization() {
+            return persistenceContext.synchronization().name();
+        }
+
         public String unitName() {
             return persistenceContext.unitName();
         }
@@ -140,12 +146,18 @@ public class PersistenceContextAnnFactory {
         public String name;
         public String unitName;
         public String type;
+        public String synchronization = SynchronizationType.SYNCHRONIZED.name(); // default
         public final Map<String, String> properties = new LinkedHashMap<String,
String>();
 
         public String name() {
             return name;
         }
 
+        @Override
+        public String synchronization() {
+            return synchronization;
+        }
+
         public String unitName() {
             return unitName;
         }
@@ -261,6 +273,8 @@ public class PersistenceContextAnnFactory {
                 persistenceContext.unitName = value;
             } else if ("type".equals(name)) {
                 persistenceContext.type = value;
+            } else if ("synchronization".equals(name)) {
+                persistenceContext.synchronization = value;
             }
         }
 


Mime
View raw message