You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by st...@apache.org on 2015/05/16 23:28:08 UTC

[2/7] tomee git commit: TOMEE-1580 persistence.xml root url when p.xml is in a jar + some datasource property adjustment to openejb namespace

TOMEE-1580 persistence.xml root url when p.xml is in a jar + some datasource property adjustment to openejb namespace


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

Branch: refs/heads/fb_tomee2_owb16
Commit: f286297cb4fc5eabd606ade2de40876df6d6ecaf
Parents: 7ddafaf
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Fri May 15 15:23:27 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Fri May 15 15:23:27 2015 +0200

----------------------------------------------------------------------
 .../org/apache/openejb/config/AppInfoBuilder.java   | 16 ++++++++++++++++
 .../org/apache/openejb/config/ReadDescriptors.java  |  7 +++++--
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/f286297c/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
index cc61204..755f017 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
@@ -98,6 +98,8 @@ import java.util.Properties;
 import java.util.Set;
 import javax.xml.bind.JAXBException;
 
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
 import static org.apache.openejb.util.URLs.toFile;
 
 /**
@@ -870,6 +872,13 @@ class AppInfoBuilder {
                         info.properties.setProperty(ECLIPSELINK_SESSION_CUSTOMIZER, PREFIX_SESSION_CUSTOMIZER);
                     }
                 }
+
+                for (final String key : singletonList("eclipselink.jdbc.sequence-connection-pool.non-jta-data-source")) {
+                    final String ds = info.properties.getProperty(key);
+                    if (ds != null && !ds.contains(":") /* java:, openejb:, other: namespace */ ) {
+                        info.properties.setProperty(key, "java:openejb/Resource/" + ds);
+                    }
+                }
             } else if (info.provider == null || "org.apache.openjpa.persistence.PersistenceProviderImpl".equals(info.provider)) {
 
                 // Apply the overrides that apply to all persistence units of this provider
@@ -920,6 +929,13 @@ class AppInfoBuilder {
 
             // Apply the overrides that apply to just this persistence unit
             override(appModule.getProperties(), info);
+
+            for (final String key : asList("javax.persistence.jtaDataSource", "javax.persistence.nonJtaDataSource")) {
+                final String ds = info.properties.getProperty(key);
+                if (ds != null && !ds.contains(":") /* java:, openejb:, other: namespace */ ) {
+                    info.properties.setProperty(key, "java:openejb/Resource/" + ds);
+                }
+            }
         }
 
         private static void overrideFromSystemProp(final PersistenceUnitInfo info) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/f286297c/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
index 5f951a1..1d3a978 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
@@ -147,9 +147,12 @@ public class ReadDescriptors implements DynamicDeployer {
                     path = file.getAbsolutePath();
 
                     if (file.getName().endsWith("persistence.xml")) {
-                        final String parent = file.getParentFile().getName();
+                        final File parentFile = file.getParentFile();
+                        final String parent = parentFile.getName();
                         if (parent.equalsIgnoreCase("WEB-INF") || parent.equalsIgnoreCase("META-INF")) {
-                            file = file.getParentFile().getParentFile();
+                            file = parentFile.getParentFile();
+                        } else if (parent.equalsIgnoreCase("lib") && "WEB-INF".equals(parentFile.getParentFile().getName())) {
+                            file = parentFile.getParentFile().getParentFile();
                         } else { // we don't really know so simply go back (users will often put persistence.xml in root resource folder with arquillian)
                             file = file.getParentFile();
                         }