[jboss-cvs] JBossAS SVN: r75537 - in projects/jpa/trunk/deployers/src: test/java/org/jboss/jpa/deployers/test/deployment and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 9 06:08:19 EDT 2008


Author: wolfc
Date: 2008-07-09 06:08:19 -0400 (Wed, 09 Jul 2008)
New Revision: 75537

Modified:
   projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeployment.java
   projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/deployment/DeploymentTestCase.java
Log:
Make sure the persistence unit is registered

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 09:43:47 UTC (rev 75536)
+++ projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/deployment/PersistenceUnitDeployment.java	2008-07-09 10:08:19 UTC (rev 75537)
@@ -38,6 +38,7 @@
 import org.hibernate.ejb.HibernatePersistence;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.jpa.spi.PersistenceUnit;
+import org.jboss.jpa.spi.PersistenceUnitRegistry;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
 import org.jboss.metadata.jpa.spec.TransactionType;
@@ -79,6 +80,17 @@
       this.kernelName = kernelName;
    }
 
+   public void create()
+   {
+      // To allow for serializable objects to obtain a reference back
+      PersistenceUnitRegistry.register(this);
+   }
+   
+   public void destroy()
+   {
+      PersistenceUnitRegistry.unregister(this);
+   }
+   
    public static String getDefaultKernelName(String unitName)
    {
       int hashIndex = unitName.indexOf('#');

Modified: projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/deployment/DeploymentTestCase.java
===================================================================
--- projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/deployment/DeploymentTestCase.java	2008-07-09 09:43:47 UTC (rev 75536)
+++ projects/jpa/trunk/deployers/src/test/java/org/jboss/jpa/deployers/test/deployment/DeploymentTestCase.java	2008-07-09 10:08:19 UTC (rev 75537)
@@ -22,6 +22,7 @@
 package org.jboss.jpa.deployers.test.deployment;
 
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.net.URL;
 
@@ -29,6 +30,7 @@
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.jpa.deployers.test.common.MainDeployerTestDelegate;
 import org.jboss.jpa.spi.PersistenceUnit;
+import org.jboss.jpa.spi.PersistenceUnitRegistry;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 import org.junit.AfterClass;
@@ -74,6 +76,10 @@
       PersistenceUnit pu = delegate.getBean(name, PersistenceUnit.class);
       assertNotNull(pu);
       
+      assertNotNull("Persistence unit not found in PersistenceUnitRegistry", PersistenceUnitRegistry.getPersistenceUnit(name));
+      
       delegate.getMainDeployer().undeploy(deployment);
+      
+      assertNull("Persistence unit still found in PersistenceUnitRegistry", PersistenceUnitRegistry.getPersistenceUnit(name));
    }
 }




More information about the jboss-cvs-commits mailing list