geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r1182804 - /geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceRefBuilder.java
Date Thu, 13 Oct 2011 12:32:05 GMT
Author: rwonly
Date: Thu Oct 13 12:32:05 2011
New Revision: 1182804

URL: http://svn.apache.org/viewvc?rev=1182804&view=rev
Log:
GERONIMO-6191 can not query the persistence unit gbean when ejb is in a war

Modified:
    geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceRefBuilder.java

Modified: geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceRefBuilder.java?rev=1182804&r1=1182803&r2=1182804&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceRefBuilder.java
(original)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceRefBuilder.java
Thu Oct 13 12:32:05 2011
@@ -202,23 +202,29 @@ public class PersistenceRefBuilder exten
             String persistenceUnitName = persistenceRef.getPersistenceUnitName().trim();
             persistenceUnitNameQuery = findPersistenceUnit(module, localConfiguration, persistenceUnitName);
         } else {
-            AbstractName childName = module.getEarContext().getNaming().createChildName(module.getModuleName(),
"", NameFactory.PERSISTENCE_UNIT);
-            Map<String, String> name = new HashMap<String, String>(childName.getName());
-            name.remove(NameFactory.J2EE_NAME);
-            persistenceUnitNameQuery = new AbstractNameQuery(null, name, PERSISTENCE_UNIT_INTERFACE_TYPES);
-            Set<AbstractNameQuery> patterns = Collections.singleton(persistenceUnitNameQuery);
-            LinkedHashSet<GBeanData> gbeans = localConfiguration.findGBeanDatas(localConfiguration,
patterns);
-            persistenceUnitNameQuery = checkForDefaultPersistenceUnit(gbeans);
+            LinkedHashSet<GBeanData> gbeans = new LinkedHashSet<GBeanData>();
+            do {
+                AbstractName childName = module.getEarContext().getNaming().createChildName(module.getModuleName(),
"", NameFactory.PERSISTENCE_UNIT);
+                Map<String, String> name = new HashMap<String, String>(childName.getName());
+                name.remove(NameFactory.J2EE_NAME);
+                
+                persistenceUnitNameQuery = new AbstractNameQuery(null, name, PERSISTENCE_UNIT_INTERFACE_TYPES);
+                Set<AbstractNameQuery> patterns = Collections.singleton(persistenceUnitNameQuery);
+                gbeans = localConfiguration.findGBeanDatas(module.getEarContext().getConfiguration(),
patterns);
+                
+                if (!gbeans.isEmpty()) {
+                    persistenceUnitNameQuery = checkForDefaultPersistenceUnit(gbeans);
+                    break;
+                }
+                                
+                module = module.getParentModule();
+            } while(module!=null);
+            
             if (gbeans.isEmpty()) {
-                gbeans = localConfiguration.findGBeanDatas(patterns);
-                persistenceUnitNameQuery = checkForDefaultPersistenceUnit(gbeans);
-
-                if (gbeans.isEmpty()) {
-                    if (defaultPersistenceUnitAbstractNameQuery == null) {
-                        throw new DeploymentException("No default PersistenceUnit specified,
and none located");
-                    }
-                    persistenceUnitNameQuery = defaultPersistenceUnitAbstractNameQuery;
+                if (defaultPersistenceUnitAbstractNameQuery == null) {
+                    throw new DeploymentException("No default PersistenceUnit specified,
and none located");
                 }
+                persistenceUnitNameQuery = defaultPersistenceUnitAbstractNameQuery;
             }
             checkForGBean(localConfiguration, persistenceUnitNameQuery, false, false, new
HashSet<AbstractName>());
         }



Mime
View raw message