[jboss-cvs] JBossAS SVN: r62106 - trunk/ejb3/src/main/org/jboss/ejb3/enc.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 4 18:06:07 EDT 2007


Author: bdecoste
Date: 2007-04-04 18:06:07 -0400 (Wed, 04 Apr 2007)
New Revision: 62106

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java
Log:
resolve persistence.xml from ear if not in jar

Modified: trunk/ejb3/src/main/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java	2007-04-04 20:55:27 UTC (rev 62105)
+++ trunk/ejb3/src/main/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java	2007-04-04 22:06:07 UTC (rev 62106)
@@ -25,8 +25,10 @@
 import org.jboss.ejb3.PersistenceUnitRegistry;
 import org.jboss.ejb3.DeploymentScope;
 import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.logging.Logger;
 
 import javax.naming.NameNotFoundException;
+import java.util.Collection;
 import java.util.List;
 import java.util.LinkedHashMap;
 
@@ -38,6 +40,8 @@
  */
 public class DeploymentPersistenceUnitResolver
 {
+   private static final Logger log = Logger.getLogger(DeploymentPersistenceUnitResolver.class);
+   
    protected List<PersistenceUnitDeployment> persistenceUnitDeployments;
    protected DeploymentScope deploymentScope;
    protected LinkedHashMap ejbContainers;
@@ -65,7 +69,25 @@
          {
             throw new NameNotFoundException("EMPTY STRING unitName and there is more than one scoped persistence unit");
          }
-         throw new NameNotFoundException("There is no default persistence unit in this deployment.");
+         else //check for persistence.xml outside of jar, but in ear scope
+         {
+            if (deploymentScope != null)
+            {
+               Collection<Ejb3Deployment> deployments = deploymentScope.getEjbDeployments();
+               if (deployments != null)
+               {
+                  for (Ejb3Deployment deployment : deployments)
+                  {
+                     if (deployment.getPersistenceUnitDeployments().size() == 1)
+                     {
+                        return deployment.getPersistenceUnitDeployments().get(0);
+                     }
+                  }
+               }
+            }
+            throw new NameNotFoundException("There is no default persistence unit in this deployment.");
+         }
+         
       }
       int hashIndex = unitName.indexOf('#');
       if (hashIndex != -1)




More information about the jboss-cvs-commits mailing list