[jboss-cvs] JBossAS SVN: r75540 - projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 9 07:09:40 EDT 2008
Author: wolfc
Date: 2008-07-09 07:09:40 -0400 (Wed, 09 Jul 2008)
New Revision: 75540
Modified:
projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeployment.java
Log:
Find the correct persistence unit root
Modified: projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeployment.java
===================================================================
--- projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeployment.java 2008-07-09 10:26:20 UTC (rev 75539)
+++ projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeployment.java 2008-07-09 11:09:40 UTC (rev 75540)
@@ -21,6 +21,7 @@
*/
package org.jboss.jpa.deployment;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -133,6 +134,26 @@
return getKernelName();
}
+ /**
+ * Find the persistence unit root, which can be the root of a jar
+ * or WEB-INF/classes of a war.
+ * @return the persistence unit root
+ */
+ protected VirtualFile getPersistenceUnitRoot()
+ {
+ // FIXME: What is the correct way to find the persistence unit root?
+ try
+ {
+ VirtualFile metaData = di.getMetaDataFile("persistence.xml");
+ assert metaData != null : "Can't find persistence.xml in " + di;
+ return metaData.getParent().getParent();
+ }
+ catch(IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
public EntityManagerFactory getContainerEntityManagerFactory()
{
return getManagedFactory().getEntityManagerFactory();
@@ -238,7 +259,7 @@
pi.setPersistenceUnitName(metaData.getName());
pi.setMappingFileNames(safeList(metaData.getMappingFiles()));
pi.setExcludeUnlistedClasses(metaData.isExcludeUnlistedClasses());
- VirtualFile root = di.getRoot();
+ VirtualFile root = getPersistenceUnitRoot();
log.debug("Persistence root: " + root);
// TODO - update this with VFSUtils helper method
// hack the JPA url
More information about the jboss-cvs-commits
mailing list