geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r529346 - /geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java
Date Mon, 16 Apr 2007 18:13:47 GMT
Author: kevan
Date: Mon Apr 16 11:13:47 2007
New Revision: 529346

URL: http://svn.apache.org/viewvc?view=rev&rev=529346
Log:
GERONIMO-3017 Apply patch from Jay McHugh. Allows persistence.xml file to be specified in
a war file. Thanks Jay.

Modified:
    geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java?view=diff&rev=529346&r1=529345&r2=529346
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java
Mon Apr 16 11:13:47 2007
@@ -95,16 +95,25 @@
                     continue;
                 }
                 int endPos = persistenceLocation.lastIndexOf("!/");
-                String relative = persistenceLocation.substring(pos + base.length(), endPos);
-                PersistenceDocument persistenceDocument;
-                try {
-                    XmlObject xmlObject = XmlBeansUtil.parse(persistenceUrl, moduleContext.getClassLoader());
-                    persistenceDocument = (PersistenceDocument)xmlObject.changeType(PersistenceDocument.type);
-                } catch (XmlException e) {
-                    throw new DeploymentException("Could not parse persistence.xml file:
" + persistenceUrl, e);
+                if (endPos < 0) {
+                    // if unable to find the '!/' marker, try to see if this is
+                    // a war file with the persistence.xml directly embeded - no ejb-jar
+                    endPos = persistenceLocation.lastIndexOf("WEB-INF");
+                }
+                if (endPos >= 0) {
+                    String relative = persistenceLocation.substring(pos + base.length(),
endPos);
+                    PersistenceDocument persistenceDocument;
+                    try {
+                        XmlObject xmlObject = XmlBeansUtil.parse(persistenceUrl, moduleContext.getClassLoader());
+                        persistenceDocument = (PersistenceDocument)xmlObject.changeType(PersistenceDocument.type);
+                    } catch (XmlException e) {
+                        throw new DeploymentException("Could not parse persistence.xml file:
" + persistenceUrl, e);
+                    }
+                    PersistenceDocument.Persistence persistence = persistenceDocument.getPersistence();
+                    buildPersistenceUnits(persistence, moduleContext, NameFactory.PERSISTENCE_UNIT_MODULE,
relative);
+                } else {
+                    throw new DeploymentException("Could not find persistence.xml file: "
+ persistenceUrl);
                 }
-                PersistenceDocument.Persistence persistence = persistenceDocument.getPersistence();
-                buildPersistenceUnits(persistence, moduleContext, NameFactory.PERSISTENCE_UNIT_MODULE,
relative);
             }
         } catch (IOException e) {
             throw new DeploymentException("Could not look for META-INF/persistence.xml files",
e);



Mime
View raw message