openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r892877 - in /openjpa/trunk/openjpa-persistence/src: main/java/org/apache/openjpa/persistence/ test/java/org/apache/openjpa/persistence/ test/resources/META-INF/
Date Mon, 21 Dec 2009 16:44:28 GMT
Author: curtisr7
Date: Mon Dec 21 16:44:27 2009
New Revision: 892877

URL: http://svn.apache.org/viewvc?rev=892877&view=rev
Log:
OPENJPA-993: PersistenceProductDerivation.getAnchorsInxxx(..) should only return PUs that
belong to OpenJPA.

Modified:
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
    openjpa/trunk/openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestPersistenceProductDerivation.java
    openjpa/trunk/openjpa-persistence/src/test/resources/META-INF/persistence.xml

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java?rev=892877&r1=892876&r2=892877&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
Mon Dec 21 16:44:27 2009
@@ -93,6 +93,14 @@
 
     private HashMap<String, PUNameCollision> _puNameCollisions
         = new HashMap<String,PUNameCollision>();
+    
+    // Provider name to filter out PUs that don't belong to this derivation.
+    protected String _providerImplName;
+
+	public PersistenceProductDerivation() {
+		_providerImplName = PersistenceProviderImpl.class.getName();
+	}
+    
     public void putBrokerFactoryAliases(Map m) {
     }
 
@@ -331,8 +339,16 @@
     private List<String> getUnitNames(ConfigurationParser parser) {
         List<PersistenceUnitInfoImpl> units = parser.getResults();
         List<String> names = new ArrayList<String>();
-        for (PersistenceUnitInfoImpl unit : units)
-            names.add(unit.getPersistenceUnitName());
+        for (PersistenceUnitInfoImpl unit : units){
+        	String provider = unit.getPersistenceProviderClassName();
+			// Only add the PU name if the provider it is ours or not specified.
+			if (provider == null || provider.equals(_providerImplName)) {
+				names.add(unit.getPersistenceUnitName());
+			} else {
+				// Should trace something, but logging isn't configured yet.
+				// Swallow.
+			}
+        }
         return names;
     }
 

Modified: openjpa/trunk/openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestPersistenceProductDerivation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestPersistenceProductDerivation.java?rev=892877&r1=892876&r2=892877&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestPersistenceProductDerivation.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestPersistenceProductDerivation.java
Mon Dec 21 16:44:27 2009
@@ -111,6 +111,9 @@
         List<String> actual = ppd.getAnchorsInResource("META-INF/persistence.xml");
         
         assertTrue(actual.containsAll(expectedPUs));
+        
+        // Added for OPENJPA-993
+        assertFalse(actual.contains("bad_provider"));
     }
     public void testEncryptionPluginConfiguration() throws Exception {
 		PersistenceProductDerivation ppd = new PersistenceProductDerivation();

Modified: openjpa/trunk/openjpa-persistence/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/test/resources/META-INF/persistence.xml?rev=892877&r1=892876&r2=892877&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/test/resources/META-INF/persistence.xml (original)
+++ openjpa/trunk/openjpa-persistence/src/test/resources/META-INF/persistence.xml Mon Dec
21 16:44:27 2009
@@ -43,4 +43,8 @@
     <persistence-unit name="exclude_true">
         <exclude-unlisted-classes>true</exclude-unlisted-classes>
     </persistence-unit>
+    <!-- Added for OPENJPA-993 -->
+    <persistence-unit name="bad_provider">
+        <provider>void</provider>
+    </persistence-unit>    
 </persistence>



Mime
View raw message