openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r946332 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetaDataRepository.java
Date Wed, 19 May 2010 18:39:57 GMT
Author: curtisr7
Date: Wed May 19 18:39:56 2010
New Revision: 946332

URL: http://svn.apache.org/viewvc?rev=946332&view=rev
Log:
OPENJPA-1670: PCRegistry should not save duplicate listeners.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetaDataRepository.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java?rev=946332&r1=946331&r2=946332&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java
Wed May 19 18:39:56 2010
@@ -20,6 +20,7 @@ package org.apache.openjpa.enhance;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.Map;
 
@@ -44,7 +45,7 @@ public class PCRegistry {
             ReferenceMap.HARD);
 
     // register class listeners
-    private static final Collection<RegisterClassListener> _listeners = new LinkedList<RegisterClassListener>();
+    private static final Collection<RegisterClassListener> _listeners = new LinkedHashSet<RegisterClassListener>();
 
     /**
      * Register a {@link RegisterClassListener}.
@@ -67,9 +68,9 @@ public class PCRegistry {
     /**
      * Removes a {@link RegisterClassListener}.
      */
-    public static void removeRegisterClassListener(RegisterClassListener rcl) {
+    public static boolean removeRegisterClassListener(RegisterClassListener rcl) {
         synchronized (_listeners) {
-            _listeners.remove(rcl);
+            return _listeners.remove(rcl);
         }
     }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetaDataRepository.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetaDataRepository.java?rev=946332&r1=946331&r2=946332&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetaDataRepository.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetaDataRepository.java
Wed May 19 18:39:56 2010
@@ -20,11 +20,11 @@ package org.apache.openjpa.persistence.m
 
 import java.util.Collection;
 
+import org.apache.openjpa.enhance.PCRegistry;
+import org.apache.openjpa.enhance.PCRegistry.RegisterClassListener;
 import org.apache.openjpa.meta.ClassMetaData;
-import org.apache.openjpa.meta.FieldMetaData;
 import org.apache.openjpa.meta.MetaDataRepository;
 import org.apache.openjpa.meta.QueryMetaData;
-import org.apache.openjpa.meta.XMLMetaData;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
 import org.apache.openjpa.persistence.test.AbstractPersistenceTestCase;
 import org.apache.openjpa.persistence.xmlmapping.entities.Customer;
@@ -74,6 +74,16 @@ public class TestMetaDataRepository exte
 			}
 		}
 	}
+	
+	public void testPreloadCleanUp() {
+        OpenJPAEntityManagerFactorySPI emf = null;
+        emf = createNamedEMF(PU_NAME, "openjpa.MetaDataRepository", "Preload=true");
+        MetaDataRepository repo = emf.getConfiguration().getMetaDataRepositoryInstance();
+        emf.createEntityManager();
+        emf.close();
+        assertFalse("The PCRegistry should no longer reference the MetaDataRepository.",
PCRegistry
+            .removeRegisterClassListener(repo));
+    }
 
 	public void testXmlMappingPreload() {
         OpenJPAEntityManagerFactorySPI emf = null;



Mime
View raw message