geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hogst...@apache.org
Subject svn commit: r530628 - in /geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder: PersistenceContextRefBuilder.java PersistenceUnitBuilder.java PersistenceUnitRefBuilder.java
Date Fri, 20 Apr 2007 04:03:04 GMT
Author: hogstrom
Date: Thu Apr 19 21:03:03 2007
New Revision: 530628

URL: http://svn.apache.org/viewvc?view=rev&rev=530628
Log:
GERONIMO-3107 Added ability to track previously processed Persistence Units

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

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java?view=diff&rev=530628&r1=530627&r2=530628
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java
Thu Apr 19 21:03:03 2007
@@ -164,8 +164,9 @@
             localConfiguration.findGBeanData(persistenceUnitNameQuery);
             return true;
         } catch (GBeanNotFoundException e) {
-            if (complainIfMissing) {
-                throw new DeploymentException("Could not resolve reference at deploy time
for query " + persistenceUnitNameQuery, e);
+            if (complainIfMissing  || e.hasMatches()) { 
+                String reason = e.hasMatches() ? "More than one GBean reference found." :
"No GBeans found.";
+                throw new DeploymentException("Could not resolve reference at deploy time
for query " + persistenceUnitNameQuery + ". " + reason, e);
             }
             return false;
         }

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=530628&r1=530627&r2=530628
==============================================================================
--- 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
Thu Apr 19 21:03:03 2007
@@ -23,6 +23,7 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 
 import javax.xml.namespace.QName;
@@ -80,7 +81,14 @@
             //TODO the code that figures out the persistence unit name is incomplete
             URI baseURI = moduleContext.getBaseDir().toURI();
             String base = baseURI.toString();
+            Map generalData = ((EARContext) applicationContext).getGeneralData();
+            List<URL> knownPersistenceUrls = (List<URL>) generalData.get(PersistenceUnitBuilder.class.getName());
+            if (knownPersistenceUrls == null) {
+                knownPersistenceUrls = new ArrayList<URL>();
+                generalData.put(PersistenceUnitBuilder.class.getName(), knownPersistenceUrls);
+            }
             List<URL> persistenceUrls = finder.findAll("META-INF/persistence.xml");
+            persistenceUrls.removeAll(knownPersistenceUrls);
             for (URL persistenceUrl: persistenceUrls) {
                 String persistenceLocation;
                 try {
@@ -111,6 +119,7 @@
                     }
                     PersistenceDocument.Persistence persistence = persistenceDocument.getPersistence();
                     buildPersistenceUnits(persistence, moduleContext, NameFactory.PERSISTENCE_UNIT_MODULE,
relative);
+                    knownPersistenceUrls.add(persistenceUrl);
                 } else {
                     throw new DeploymentException("Could not find persistence.xml file: "
+ persistenceUrl);
                 }

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java?view=diff&rev=530628&r1=530627&r2=530628
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java
Thu Apr 19 21:03:03 2007
@@ -147,8 +147,9 @@
             localConfiguration.findGBeanData(persistenceUnitNameQuery);
             return true;
         } catch (GBeanNotFoundException e) {
-            if (complainIfMissing) {
-                throw new DeploymentException("Could not resolve reference at deploy time
for query " + persistenceUnitNameQuery, e);
+            if (complainIfMissing  || e.hasMatches()) { 
+                String reason = e.hasMatches() ? "More than one GBean reference found." :
"No GBean references found.";
+                throw new DeploymentException("Could not resolve reference at deploy time
for query " + persistenceUnitNameQuery + ". " + reason, e);
             }
             return false;
         }



Mime
View raw message