tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgallim...@apache.org
Subject svn commit: r1076875 - /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Date Thu, 03 Mar 2011 23:10:43 GMT
Author: jgallimore
Date: Thu Mar  3 23:10:42 2011
New Revision: 1076875

URL: http://svn.apache.org/viewvc?rev=1076875&view=rev
Log:
Find persistence.xml in war files

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1076875&r1=1076874&r2=1076875&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Thu Mar  3 23:10:42 2011
@@ -228,7 +228,23 @@ public class DeploymentLoader implements
                 
                 AppModule appModule = new AppModule(OpenEJB.class.getClassLoader(), file.getAbsolutePath(),
new Application(), true);
                 addWebModule(appModule, baseUrl, OpenEJB.class.getClassLoader(), getContextRoot(),
getModuleName());
-                return appModule;
+                
+				File persistenceXml = new File(file, "WEB-INF/classes/META-INF/persistence.xml");
+				if (persistenceXml.exists() && persistenceXml.isFile()) {
+					List<URL> persistenceUrls = (List<URL>) appModule.getAltDDs().get("persistence.xml");
+			        if (persistenceUrls == null) {
+			            persistenceUrls = new ArrayList<URL>();
+			            appModule.getAltDDs().put("persistence.xml", persistenceUrls);
+			        }
+
+			        try {
+						persistenceUrls.add(persistenceXml.toURI().toURL());
+					} catch (Exception e) {
+					}
+				}
+				
+				addPersistenceUnits(appModule, baseUrl);
+				return appModule;
             } else if (PersistenceModule.class.equals(moduleClass) && loadingRequiredModuleTypes.contains(PersistenceModule.class))
{
                 String jarLocation = URLs.toFilePath(baseUrl);
                 ClassLoader classLoader = ClassLoaderUtil.createTempClassLoader(jarPath,
new URL[]{baseUrl}, OpenEJB.class.getClassLoader());



Mime
View raw message