openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1190716 [9/10] - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/...
Date Sat, 29 Oct 2011 00:44:18 GMT
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestPerClassSequenceFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestPerClassSequenceFactory.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestPerClassSequenceFactory.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestPerClassSequenceFactory.java Sat Oct 29 00:44:11 2011
@@ -30,10 +30,12 @@ package org.apache.openjpa.persistence.j
 import java.util.*;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.jdbc.meta.MappingRepository;
 import org.apache.openjpa.jdbc.schema.Sequence;
 import org.apache.openjpa.kernel.Seq;
 import org.apache.openjpa.kernel.StoreContext;
 import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.meta.MetaDataRepository;
 
 import org.apache.openjpa.persistence.jdbc.common.apps.*;
 
@@ -59,36 +61,18 @@ public class TestPerClassSequenceFactory
 
     public void testPerClassSequenceFactory()
         throws Exception {
-        Map props=new HashMap();
+        Map props = new HashMap();
         props.put("openjpa.Sequence", "table");
         
-        OpenJPAEntityManagerFactory factory =(OpenJPAEntityManagerFactory)
-                getEmf(props);
+        OpenJPAEntityManagerFactory factory =(OpenJPAEntityManagerFactory)getEmf(props);
 
-        JDBCConfiguration conf = (JDBCConfiguration)
-            factory.getConfiguration();
-        ClassMapping mapping1 = conf.getMappingRepositoryInstance().
-            getMapping(RuntimeTest1.class, null, true);
-        ClassMapping mapping2 = conf.getMappingRepositoryInstance().
-            getMapping(PerClassTestObject.class, null, true);
-        ClassMapping mapping3 = conf.getMappingRepositoryInstance().
-            getMapping(PerClassTestObject2.class, null, true);
+        JDBCConfiguration conf = (JDBCConfiguration) factory.getConfiguration();
+        MappingRepository repos = conf.getMappingRepositoryInstance();
+        ClassMapping mapping1 = repos.getMapping(RuntimeTest1.class, true);
+        ClassMapping mapping2 = repos.getMapping(PerClassTestObject.class, true);
+        ClassMapping mapping3 = repos.getMapping(PerClassTestObject2.class, true);
 
         OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
-        //FIXME jthomas
-        /*
-        Sequence s1 = pm.getIdentitySequence(mapping1.getDescribedType());
-        Sequence s2 = pm.getIdentitySequence(mapping2.getDescribedType());
-        Sequence s3 = pm.getFieldSequence(mapping3.getDescribedType(), "age");
-        assertTrue(((SequenceImpl) s1).getDelegate()
-            instanceof TableJDBCSeq);
-        assertTrue(((SequenceImpl) s2).getDelegate().toString(),
-            ((SequenceImpl) s2).getDelegate()
-                instanceof DummySequenceFactory);
-        assertTrue(((SequenceImpl) s2).getDelegate().toString(),
-            ((SequenceImpl) s3).getDelegate()
-                instanceof DummySequenceFactory);
-         */
     }
 
     public static class DummySequenceFactory

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSequenceGeneratorEnsureCapacityCall.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSequenceGeneratorEnsureCapacityCall.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSequenceGeneratorEnsureCapacityCall.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSequenceGeneratorEnsureCapacityCall.java Sat Oct 29 00:44:11 2011
@@ -84,9 +84,9 @@ public class TestSequenceGeneratorEnsure
     private Seq seqForClass(Class cls) {
         OpenJPAConfiguration conf = getConfiguration();
         ClassMetaData meta = conf.getMetaDataRepositoryInstance().getMetaData
-            (cls, null, true);
+            (cls, true);
         SequenceMetaData smeta = meta.getIdentitySequenceMetaData();
         return (smeta == null) ? conf.getSequenceInstance()
-            : smeta.getInstance(null);
+            : smeta.getInstance();
     }
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache.java Sat Oct 29 00:44:11 2011
@@ -1324,7 +1324,7 @@ public class TestPreparedQueryCache exte
             return name;
         return emf.getConfiguration()
                   .getMetaDataRepositoryInstance()
-                  .getQueryMetaData(null, name, null, true)
+                  .getQueryMetaData(null, name, true)
                   .getQueryString();
     }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPCClass.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPCClass.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPCClass.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPCClass.java Sat Oct 29 00:44:11 2011
@@ -60,7 +60,7 @@ public class TestPCClass extends BaseKer
 
         MetaDataRepository repos = getConfiguration()
             .getMetaDataRepositoryInstance();
-        ClassMetaData meta = repos.getMetaData(PCClassPC.class, null, true);
+        ClassMetaData meta = repos.getMetaData(PCClassPC.class, true);
 
         FieldMetaData fmd = meta.getField("specificPC");
         assertNotNull("fmd is nulll", fmd);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPersistenceManagerFactoryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPersistenceManagerFactoryImpl.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPersistenceManagerFactoryImpl.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPersistenceManagerFactoryImpl.java Sat Oct 29 00:44:11 2011
@@ -162,11 +162,11 @@ public class TestPersistenceManagerFacto
             assertTrue("no listeners defined added to Runtimetest4",
                 broker.getLifecycleEventManager().hasLoadListeners(
                     new RuntimeTest4("foo"),
-                    repos.getMetaData(RuntimeTest4.class, null, true)));
+                    repos.getMetaData(RuntimeTest4.class, true)));
             assertFalse("there should be listeners def for runtimetest1",
                 broker.getLifecycleEventManager().hasLoadListeners
                     (new RuntimeTest1(), repos.getMetaData
-                        (RuntimeTest1.class, null, true)));
+                        (RuntimeTest1.class, true)));
             broker.close();
         } finally {
             pmfSPI.removeLifecycleListener(listener);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestSimpleManagedInterface.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestSimpleManagedInterface.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestSimpleManagedInterface.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/managedinterface/TestSimpleManagedInterface.java Sat Oct 29 00:44:11 2011
@@ -42,7 +42,7 @@ public class TestSimpleManagedInterface
         MetaDataRepository repos = bf.getConfiguration()
             .getMetaDataRepositoryInstance();
         ClassMetaData meta = repos.getMetaData(SimpleManagedInterface.class,
-            null, false);
+            false);
         assertNotNull(meta);
         assertTrue(meta.isManagedInterface());
         assertEquals(SimpleManagedInterface.class, meta.getDescribedType());

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestClassMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestClassMetaData.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestClassMetaData.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestClassMetaData.java Sat Oct 29 00:44:11 2011
@@ -60,11 +60,11 @@ public class TestClassMetaData
     public void setUp()
         throws Exception {
         _repos = getRepository();
-        _metaTest5 = _repos.getMetaData(MetaTest5.class, null, true);
-        _metaTest3 = _repos.getMetaData(MetaTest3.class, null, true);
-        _metaTest2 = _repos.getMetaData(MetaTest2.class, null, true);
-        _metaTest1 = _repos.getMetaData(MetaTest1.class, null, true);
-        _metaTest6 = _repos.getMetaData(MetaTest6.class, null, true);
+        _metaTest5 = _repos.getMetaData(MetaTest5.class, true);
+        _metaTest3 = _repos.getMetaData(MetaTest3.class, true);
+        _metaTest2 = _repos.getMetaData(MetaTest2.class, true);
+        _metaTest1 = _repos.getMetaData(MetaTest1.class, true);
+        _metaTest6 = _repos.getMetaData(MetaTest6.class, true);
     }
 
     protected MetaDataRepository getRepository()
@@ -274,7 +274,7 @@ public class TestClassMetaData
      * Test that metadata on inner classes is available.
      */
     public void testStaticInnerClasses() {
-        assertNotNull(_repos.getMetaData(MetaTest1.Inner.class, null, true));
+        assertNotNull(_repos.getMetaData(MetaTest1.Inner.class, true));
     }
 
     /**

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestFactoryMethod.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestFactoryMethod.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestFactoryMethod.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestFactoryMethod.java Sat Oct 29 00:44:11 2011
@@ -48,7 +48,7 @@ public class TestFactoryMethod extends A
 
     public void setUp() throws Exception {
         _repos = getRepository();
-        _metaTest7 = _repos.getMetaData(MetaTest7.class, null, true);
+        _metaTest7 = _repos.getMetaData(MetaTest7.class, true);
     }
 
     protected MetaDataRepository getRepository() throws Exception {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestNonPersistentFields.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestNonPersistentFields.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestNonPersistentFields.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestNonPersistentFields.java Sat Oct 29 00:44:11 2011
@@ -43,7 +43,7 @@ public class TestNonPersistentFields
     public void setUp() {
         MetaDataRepository repos = new OpenJPAConfigurationImpl().
             newMetaDataRepositoryInstance();
-        _meta = repos.getMetaData(NonPersistentFieldsPC.class, null, true);
+        _meta = repos.getMetaData(NonPersistentFieldsPC.class, true);
     }
 
     public void testNonPersistentFields() {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestPersistentClasses.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestPersistentClasses.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestPersistentClasses.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestPersistentClasses.java Sat Oct 29 00:44:11 2011
@@ -45,8 +45,7 @@ public class TestPersistentClasses
     private void assertClass(String clsName, OpenJPAConfiguration conf,
         boolean shouldExist) {
 
-        Collection names = conf.getMetaDataRepositoryInstance().
-            getPersistentTypeNames(false, null);
+        Collection names = conf.getMetaDataRepositoryInstance().getPersistentTypeNames(false);
 
         if (shouldExist)
             assertTrue("expected element " + clsName + " was not found in "
@@ -65,7 +64,7 @@ public class TestPersistentClasses
         assertNull(((OpenJPAEntityManagerFactorySPI) pmf).getConfiguration()
             .getMetaDataRepositoryInstance().
 
-            getPersistentTypeNames(false, null));
+            getPersistentTypeNames(false));
 
         pmf.close();
     }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestQueryTypeAliasRegistration.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestQueryTypeAliasRegistration.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestQueryTypeAliasRegistration.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestQueryTypeAliasRegistration.java Sat Oct 29 00:44:11 2011
@@ -94,7 +94,7 @@ public class TestQueryTypeAliasRegistrat
         @Override
         public void run() {
             try {
-                repo.getMetaData("MdrTestEntity", Thread.currentThread().getContextClassLoader(), true);
+                repo.getMetaData("MdrTestEntity", true);
             } catch (Exception e) {
                 ex = e;
                 e.printStackTrace();

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestValueStrategies.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestValueStrategies.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestValueStrategies.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestValueStrategies.java Sat Oct 29 00:44:11 2011
@@ -231,7 +231,7 @@ public class TestValueStrategies
         pm.persist(pc);
         ClassMetaData meta = getConfiguration()
             .getMetaDataRepositoryInstance().
-            getMetaData(pc.getClass(), null, false);
+            getMetaData(pc.getClass(), false);
         assertNotNull(meta.getVersionField());
         assertEquals("version", meta.getVersionField().getName());
         assertEquals(0, pc.getVersion());

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestXMLPersistenceMetaDataSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestXMLPersistenceMetaDataSerializer.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestXMLPersistenceMetaDataSerializer.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestXMLPersistenceMetaDataSerializer.java Sat Oct 29 00:44:11 2011
@@ -53,11 +53,11 @@ public class TestXMLPersistenceMetaDataS
         throws Exception {
         OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
         MetaDataRepository repos = conf.newMetaDataRepositoryInstance();
-        repos.getMetaData(MetaTest5.class, null, true);
-        repos.getMetaData(MetaTest3.class, null, true);
-        repos.getMetaData(MetaTest2.class, null, true);
-        repos.getMetaData(MetaTest1.class, null, true);
-        repos.getMetaData(MetaTest6.class, null, true);
+        repos.getMetaData(MetaTest5.class, true);
+        repos.getMetaData(MetaTest3.class, true);
+        repos.getMetaData(MetaTest2.class, true);
+        repos.getMetaData(MetaTest1.class, true);
+        repos.getMetaData(MetaTest6.class, true);
 
         XMLPersistenceMetaDataSerializer ser =
             new XMLPersistenceMetaDataSerializer(conf);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestAccessPathsOfSubqueries.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestAccessPathsOfSubqueries.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestAccessPathsOfSubqueries.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestAccessPathsOfSubqueries.java Sat Oct 29 00:44:11 2011
@@ -38,6 +38,7 @@ import org.apache.openjpa.kernel.Broker;
 import org.apache.openjpa.kernel.Query;
 import org.apache.openjpa.kernel.jpql.JPQLParser;
 import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.meta.MetaDataRepository;
 
 public class TestAccessPathsOfSubqueries extends BaseQueryTest {
 
@@ -57,12 +58,9 @@ public class TestAccessPathsOfSubqueries
             + "WHERE rt5.name IS NOT NULL)");
         ClassMetaData[] metas = q.getAccessPathMetaDatas();
         Collection c = Arrays.asList(metas);
-        ClassMetaData rt1 = broker.getConfiguration().
-            getMetaDataRepositoryInstance().getMetaData(RuntimeTest1.class,
-            broker.getClassLoader(), true);
-        ClassMetaData rt5 = broker.getConfiguration().
-            getMetaDataRepositoryInstance().getMetaData(RuntimeTest5.class,
-            broker.getClassLoader(), true);
+        MetaDataRepository repos = broker.getConfiguration().getMetaDataRepositoryInstance();
+        ClassMetaData rt1 = repos.getMetaData(RuntimeTest1.class,true);
+        ClassMetaData rt5 = repos.getMetaData(RuntimeTest5.class,true);
         assertTrue(c.contains(rt1));
         assertTrue(c.contains(rt5));
         assertEquals(2, c.size());
@@ -77,15 +75,10 @@ public class TestAccessPathsOfSubqueries
 
         ClassMetaData[] metas = q.getAccessPathMetaDatas();
         Collection c = Arrays.asList(metas);
-        ClassMetaData rt1 = broker.getConfiguration().
-            getMetaDataRepositoryInstance().getMetaData(RuntimeTest1.class,
-            broker.getClassLoader(), true);
-        ClassMetaData rt4 = broker.getConfiguration().
-            getMetaDataRepositoryInstance().getMetaData(RuntimeTest4.class,
-            broker.getClassLoader(), true);
-        ClassMetaData rt5 = broker.getConfiguration().
-            getMetaDataRepositoryInstance().getMetaData(RuntimeTest5.class,
-            broker.getClassLoader(), true);
+        MetaDataRepository repos = broker.getConfiguration().getMetaDataRepositoryInstance();
+        ClassMetaData rt1 = repos.getMetaData(RuntimeTest1.class, true);
+        ClassMetaData rt4 = repos.getMetaData(RuntimeTest4.class, true);
+        ClassMetaData rt5 = repos.getMetaData(RuntimeTest5.class, true);
         assertTrue(c.contains(rt1));
         assertTrue(c.contains(rt4));
         assertTrue(c.contains(rt5));

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestNamedQueries.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestNamedQueries.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestNamedQueries.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestNamedQueries.java Sat Oct 29 00:44:11 2011
@@ -83,8 +83,7 @@ public class TestNamedQueries extends Ba
         assertEquals("num", query.getGrouping());
         */
         QueryMetaData meta = ((OpenJPAEntityManagerSPI) pm).getConfiguration().
-            getMetaDataRepositoryInstance().getQueryMetaData(null,
-            "named", pm.getClassLoader(), true);
+            getMetaDataRepositoryInstance().getQueryMetaData(null, "named", true);
         assertNotNull(meta);
         assertEquals("SELECT o FROM QueryTest1 o", meta.getQueryString());
         assertEquals(null, meta.getResultType());

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/ContainerEMFTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/ContainerEMFTest.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/ContainerEMFTest.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/ContainerEMFTest.java Sat Oct 29 00:44:11 2011
@@ -85,7 +85,7 @@ public abstract class ContainerEMFTest e
             clist = (List<Class<?>>)map.remove(PERSISTENT_CLASS_LIST);
         }
         PersistenceProductDerivation.ConfigurationParser cfgParser = 
-            new PersistenceProductDerivation.ConfigurationParser(config);
+            new PersistenceProductDerivation.ConfigurationParser(this.getClass().getClassLoader(), config);
         try {
             URL url = getResourceURL(persistenceFile);
             cfgParser.parse(url);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java Sat Oct 29 00:44:11 2011
@@ -25,6 +25,7 @@ import javax.persistence.EntityManager;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.lib.conf.ProductDerivations;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
@@ -103,8 +104,7 @@ public abstract class SingleEMFTestCase
      */
     protected ClassMapping getMapping(String name) {
         return (ClassMapping) emf.getConfiguration()
-                .getMetaDataRepositoryInstance().getMetaData(name,
-                        getClass().getClassLoader(), true);
+                .getMetaDataRepositoryInstance().getMetaData(name, true);
     }
     
     /**
@@ -117,8 +117,7 @@ public abstract class SingleEMFTestCase
      */
     protected ClassMapping getMapping(Class<?> entityClass) {
         return (ClassMapping) emf.getConfiguration()
-                .getMetaDataRepositoryInstance().getMetaData(entityClass,
-                        getClass().getClassLoader(), true);
+                .getMetaDataRepositoryInstance().getMetaData(entityClass, true);
     }
     
     /**
@@ -160,7 +159,7 @@ public abstract class SingleEMFTestCase
     
     public String getAlias(Class<?> t) {
         return emf.getConfiguration().getMetaDataRepositoryInstance()
-            .getMetaData(t, null, true).getTypeAlias();
+            .getMetaData(t, true).getTypeAlias();
     }
 
     protected ClassMapping [] getMappings() {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/util/TestJPAFacadeHelper.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/util/TestJPAFacadeHelper.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/util/TestJPAFacadeHelper.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/util/TestJPAFacadeHelper.java Sat Oct 29 00:44:11 2011
@@ -57,7 +57,7 @@ public class TestJPAFacadeHelper extends
     }
 
     public void testEmbeddedId() throws Exception {
-        ClassMetaData cmd = repo.getMetaData(EmbeddedIdEntity.class, null, true);
+        ClassMetaData cmd = repo.getMetaData(EmbeddedIdEntity.class, true);
         try {
             JPAFacadeHelper.toOpenJPAObjectId(cmd, new EmbeddedIdEntity());
             fail("Didn't fail!");
@@ -70,7 +70,7 @@ public class TestJPAFacadeHelper extends
     }
 
     public void testCompositeId() throws Exception {
-        ClassMetaData cmd = repo.getMetaData(EntityWithCompositeId.class, null, true);
+        ClassMetaData cmd = repo.getMetaData(EntityWithCompositeId.class, true);
         try {
             JPAFacadeHelper.toOpenJPAObjectId(cmd, new EntityWithCompositeId());
             fail("Didn't fail!");
@@ -83,7 +83,7 @@ public class TestJPAFacadeHelper extends
     }
 
     public void testBasic() throws Exception {
-        ClassMetaData cmd = repo.getMetaData(BasicEntity.class, null, true);
+        ClassMetaData cmd = repo.getMetaData(BasicEntity.class, true);
         try {
             JPAFacadeHelper.toOpenJPAObjectId(cmd, new BasicEntity());
             fail("Didn't fail!");
@@ -103,7 +103,7 @@ public class TestJPAFacadeHelper extends
     }
 
     public void testDerivedId() throws Exception {
-        ClassMetaData cmd = repo.getMetaData(EDSQLDateID.class, null, true);
+        ClassMetaData cmd = repo.getMetaData(EDSQLDateID.class, true);
         try {
             JPAFacadeHelper.toOpenJPAObjectId(cmd, new EDSQLDateID());
             fail("Didn't fail!");
@@ -116,7 +116,7 @@ public class TestJPAFacadeHelper extends
     }
 
     public void testNoId() throws Exception {
-        ClassMetaData cmd = repo.getMetaData(AllFieldTypes.class, null, true);
+        ClassMetaData cmd = repo.getMetaData(AllFieldTypes.class, true);
         try {
             // Don't parameterize this collection to force the JVM to use the 
             // ...(ClassMetaData meta, Collection<Object> oids) method sig.

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestXmlOverrideEntity.java Sat Oct 29 00:44:11 2011
@@ -60,13 +60,11 @@ public class TestXmlOverrideEntity exten
 
     public void testOverriddenEntityName() {
         emf.createEntityManager().close();
-        ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
-            XmlOverrideEntity.class);
+        ClassMetaData meta = JPAFacadeHelper.getMetaData(emf, XmlOverrideEntity.class);
         assertEquals("XmlOverride", meta.getTypeAlias());
         MetaDataRepository repo = emf.getConfiguration()
             .getMetaDataRepositoryInstance();
-        assertEquals(meta, repo.getMetaData("XmlOverride",
-            XmlOverrideEntity.class.getClassLoader(), true));
+        assertEquals(meta, repo.getMetaData("XmlOverride", true));
     }
 
     /**

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java Sat Oct 29 00:44:11 2011
@@ -181,11 +181,9 @@ import serp.util.Strings;
 public class AnnotationPersistenceMetaDataParser
     implements MetaDataModes {
 
-    private static final Localizer _loc = Localizer.forPackage
-        (AnnotationPersistenceMetaDataParser.class);
+    private static final Localizer _loc = Localizer.forPackage(AnnotationPersistenceMetaDataParser.class);
 
-    private static final Map<Class<?>, MetaDataTag> _tags =
-        new HashMap<Class<?>, MetaDataTag>();
+    private static final Map<Class<?>, MetaDataTag> _tags = new HashMap<Class<?>, MetaDataTag>();
 
     static {
         _tags.put(Access.class, ACCESS);
@@ -193,8 +191,7 @@ public class AnnotationPersistenceMetaDa
         _tags.put(EmbeddedId.class, EMBEDDED_ID);
         _tags.put(EntityListeners.class, ENTITY_LISTENERS);
         _tags.put(ExcludeDefaultListeners.class, EXCLUDE_DEFAULT_LISTENERS);
-        _tags.put(ExcludeSuperclassListeners.class,
-            EXCLUDE_SUPERCLASS_LISTENERS);
+        _tags.put(ExcludeSuperclassListeners.class, EXCLUDE_SUPERCLASS_LISTENERS);
         _tags.put(FlushModeType.class, FLUSH_MODE);
         _tags.put(GeneratedValue.class, GENERATED_VALUE);
         _tags.put(Id.class, ID);
@@ -240,7 +237,6 @@ public class AnnotationPersistenceMetaDa
     private final OpenJPAConfiguration _conf;
     private final Log _log;
     private MetaDataRepository _repos = null;
-    private ClassLoader _envLoader = null;
     private boolean _override = false;
     private int _mode = MODE_NONE;
 
@@ -298,21 +294,6 @@ public class AnnotationPersistenceMetaDa
         _repos = repos;
     }
 
-    /**
-     * Return the environmental class loader to pass on to parsed
-     * metadata instances.
-     */
-    public ClassLoader getEnvClassLoader() {
-        return _envLoader;
-    }
-
-    /**
-     * Set the environmental class loader to pass on to parsed
-     * metadata instances.
-     */
-    public void setEnvClassLoader(ClassLoader loader) {
-        _envLoader = loader;
-    }
 
     /**
      * Whether to allow later parses of mapping information to override
@@ -750,7 +731,6 @@ public class AnnotationPersistenceMetaDa
 
         if (meta == null) {
             meta = getRepository().addMetaData(_cls, getAccessCode(_cls));
-            meta.setEnvClassLoader(_envLoader);
             meta.setSourceMode(MODE_NONE);
             meta.setSource(getSourceFile(), SourceTracker.SRC_ANNOTATIONS, getSourceFile() == null ? ""
                 : getSourceFile().getPath());

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryValue.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryValue.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryValue.java Sat Oct 29 00:44:11 2011
@@ -18,6 +18,8 @@
  */
 package org.apache.openjpa.persistence;
 
+import javax.persistence.EntityManagerFactory;
+
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.kernel.BrokerFactory;
 import org.apache.openjpa.lib.conf.PluginValue;
@@ -29,7 +31,7 @@ import org.apache.openjpa.lib.conf.Plugi
  * @nojavadoc
  */
 public class EntityManagerFactoryValue
-    extends PluginValue {
+    extends PluginValue<OpenJPAEntityManagerFactory> {
 
     /**
      * Configuration property key.
@@ -45,17 +47,16 @@ public class EntityManagerFactoryValue
      */
     public static OpenJPAEntityManagerFactory newFactory(BrokerFactory bf) {
         OpenJPAConfiguration conf = bf.getConfiguration();
-        PluginValue val = (PluginValue) conf.getValue(KEY); 
+        PluginValue<OpenJPAEntityManagerFactory> val = (PluginValue<OpenJPAEntityManagerFactory>) conf.getValue(KEY); 
         if (val == null)
             return null;
-        EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) val.
-            instantiate(EntityManagerFactoryImpl.class, conf, true);
+        EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl)val.instantiate(conf, true);
         emf.setBrokerFactory(bf);
         return emf;
     }
 
     public EntityManagerFactoryValue() {
-        super(KEY, false);
+        super(OpenJPAEntityManagerFactory.class, KEY, false);
         setAliases(ALIASES);
         setDefault(ALIASES[0]);
         setClassName(ALIASES[1]);

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java Sat Oct 29 00:44:11 2011
@@ -219,10 +219,6 @@ public class EntityManagerImpl
         _broker.setSyncWithManagedTransactions(sync);
     }
 
-    public ClassLoader getClassLoader() {
-        return _broker.getClassLoader();
-    }
-
     public String getConnectionUserName() {
         return _broker.getConnectionUserName();
     }
@@ -923,9 +919,8 @@ public class EntityManagerImpl
         assertNotCloseInvoked();
         try {
             SequenceMetaData meta = _broker.getConfiguration().
-                getMetaDataRepositoryInstance().getSequenceMetaData(name,
-                _broker.getClassLoader(), true);
-            Seq seq = meta.getInstance(_broker.getClassLoader());
+                getMetaDataRepositoryInstance().getSequenceMetaData(name, true);
+            Seq seq = meta.getInstance();
             return new GeneratorImpl(seq, name, _broker, null);
         } catch (RuntimeException re) {
             throw PersistenceExceptions.toPersistenceException(re);
@@ -936,8 +931,7 @@ public class EntityManagerImpl
         assertNotCloseInvoked();
         try {
             ClassMetaData meta = _broker.getConfiguration().
-                getMetaDataRepositoryInstance().getMetaData(forClass,
-                _broker.getClassLoader(), true);
+                getMetaDataRepositoryInstance().getMetaData(forClass, true);
             Seq seq = _broker.getIdentitySequence(meta);
             return (seq == null) ? null : new GeneratorImpl(seq, null, _broker,
                 meta);
@@ -950,8 +944,7 @@ public class EntityManagerImpl
         assertNotCloseInvoked();
         try {
             ClassMetaData meta = _broker.getConfiguration().
-                getMetaDataRepositoryInstance().getMetaData(forClass,
-                _broker.getClassLoader(), true);
+                getMetaDataRepositoryInstance().getMetaData(forClass, true);
             FieldMetaData fmd = meta.getField(fieldName);
             if (fmd == null)
                 throw new ArgumentException(_loc.get("no-named-field",
@@ -1022,8 +1015,7 @@ public class EntityManagerImpl
         _broker.assertOpen();
         try {
             QueryMetaData meta = _broker.getConfiguration().
-                getMetaDataRepositoryInstance().getQueryMetaData(null, name,
-                _broker.getClassLoader(), true);
+                getMetaDataRepositoryInstance().getQueryMetaData(null, name, true);
             String qid = meta.getQueryString();
             
             PreparedQuery pq = JPQLParser.LANG_JPQL.equals(meta.getLanguage()) ? getPreparedQuery(qid) : null;

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/HintHandler.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/HintHandler.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/HintHandler.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/HintHandler.java Sat Oct 29 00:44:11 2011
@@ -145,7 +145,7 @@ public class HintHandler  {
             return;
         }
         
-        ClassLoader loader = owner.getDelegate().getBroker().getClassLoader();
+        ClassLoader loader = owner.getDelegate().getBroker().getConfiguration().getClassLoader();
         if (QueryHints.HINT_SUBCLASSES.equals(key)) {
             if (value instanceof String)
                 value = Boolean.valueOf((String) value);

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/JPAFacadeHelper.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/JPAFacadeHelper.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/JPAFacadeHelper.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/JPAFacadeHelper.java Sat Oct 29 00:44:11 2011
@@ -177,7 +177,7 @@ public class JPAFacadeHelper {
             OpenJPAPersistence.cast(em);
         try {
             return kem.getConfiguration().getMetaDataRepositoryInstance().
-                getMetaData(cls, kem.getClassLoader(), false);
+                getMetaData(cls, false);
         } catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);
         }
@@ -196,7 +196,7 @@ public class JPAFacadeHelper {
             (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast(emf);
         try {
             return emfSPI.getConfiguration().getMetaDataRepositoryInstance().
-                getMetaData(cls, null, false);
+                getMetaData(cls, false);
         } catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);
         }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAEntityManager.java Sat Oct 29 00:44:11 2011
@@ -110,12 +110,6 @@ public interface OpenJPAEntityManager
     public void setSyncWithManagedTransactions(boolean resync);
 
     /**
-     * Return the current thread's class loader at the time this entity
-     * manager was obtained from the factory.
-     */
-    public ClassLoader getClassLoader();
-
-    /**
      * Return the connection user name.
      */
     public String getConnectionUserName();

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java Sat Oct 29 00:44:11 2011
@@ -86,11 +86,9 @@ public class OpenJPAPersistence {
      * overrides.
      */
     public static OpenJPAEntityManagerFactory getEntityManagerFactory(Map map) {
-        ConfigurationProvider cp = new PersistenceProductDerivation.
-            ConfigurationProviderImpl(map);
+        ConfigurationProvider cp = new PersistenceProductDerivation.ConfigurationProviderImpl(map);
         try {
-            return JPAFacadeHelper.toEntityManagerFactory(
-                Bootstrap.getBrokerFactory(cp, null));
+            return JPAFacadeHelper.toEntityManagerFactory(Bootstrap.getBrokerFactory(cp));
         } catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);
         }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java Sat Oct 29 00:44:11 2011
@@ -309,7 +309,7 @@ public class PersistenceMetaDataDefaults
     	MetaDataRepository repos = meta.getRepository();
     	ClassMetaData supMeta = repos.getCachedMetaData(sup);
     	if (supMeta == null)
-    		supMeta = repos.getMetaData(sup, null, false);
+    		supMeta = repos.getMetaData(sup, false);
     	return supMeta;
     }
 

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java Sat Oct 29 00:44:11 2011
@@ -75,11 +75,9 @@ public class PersistenceMetaDataFactory
     extends AbstractCFMetaDataFactory
     implements Configurable, GenericConfigurable {
 
-    private static final Localizer _loc = Localizer.forPackage
-        (PersistenceMetaDataFactory.class);
+    private static final Localizer _loc = Localizer.forPackage(PersistenceMetaDataFactory.class);
 
-    private final PersistenceMetaDataDefaults _def = 
-        new PersistenceMetaDataDefaults();
+    private final PersistenceMetaDataDefaults _def = new PersistenceMetaDataDefaults();
     private AnnotationPersistenceMetaDataParser _annoParser = null;
     private AnnotationPersistenceXMLMetaDataParser _annoXMLParser = null;
     private XMLPersistenceMetaDataParser _xmlParser = null;
@@ -87,8 +85,7 @@ public class PersistenceMetaDataFactory
     private Set<URL> _unparsed = null; // xml rsrc
     private boolean _fieldOverride = true;
 
-    protected Stack<XMLPersistenceMetaDataParser> _stack = 
-        new Stack<XMLPersistenceMetaDataParser>();
+    protected Stack<XMLPersistenceMetaDataParser> _stack = new Stack<XMLPersistenceMetaDataParser>();
 
     /**
      * Whether to use field-level override or class-level override.
@@ -120,8 +117,7 @@ public class PersistenceMetaDataFactory
     /**
      * Set the metadata parser.
      */
-    public void setAnnotationParser(
-        AnnotationPersistenceMetaDataParser parser) {
+    public void setAnnotationParser(AnnotationPersistenceMetaDataParser parser) {
         if (_annoParser != null)
             _annoParser.setRepository(null);
         if (parser != null)
@@ -133,8 +129,7 @@ public class PersistenceMetaDataFactory
      * Create a new metadata parser.
      */
     protected AnnotationPersistenceMetaDataParser newAnnotationParser() {
-        return new AnnotationPersistenceMetaDataParser
-            (repos.getConfiguration());
+        return new AnnotationPersistenceMetaDataParser(repos.getConfiguration());
     }
 
     /**
@@ -205,7 +200,7 @@ public class PersistenceMetaDataFactory
         return new XMLPersistenceMetaDataSerializer(repos.getConfiguration());
     }
     
-    public void load(Class<?> cls, int mode, ClassLoader envLoader) {
+    public void load(Class<?> cls, int mode) {
         if (mode == MODE_NONE)
             return;
         if (!strict && (mode & MODE_META) != 0)
@@ -214,7 +209,7 @@ public class PersistenceMetaDataFactory
         // getting the list of persistent types runs callbacks to
         // mapPersistentTypeNames if it hasn't been called already, which
         // caches XML resources
-        getPersistentTypeNames(false, envLoader);
+        getPersistentTypeNames(false);
         URL xml = findXML(cls);
 
         // we have to parse metadata up-front to register persistence unit
@@ -225,7 +220,7 @@ public class PersistenceMetaDataFactory
             && (mode & MODE_META) != 0) {
             Set<URL> unparsed = new HashSet<URL>(_unparsed);
             for (URL url : unparsed) {
-                parseXML(url, cls, mode, envLoader);
+                parseXML(url, cls, mode);
             }
             parsedXML = unparsed.contains(xml);
              _unparsed.clear();
@@ -245,7 +240,7 @@ public class PersistenceMetaDataFactory
         // we may still need to parse XML if this is a redeploy of a class, or
         // if we're in strict query-only mode
         if (!parsedXML && xml != null) {
-            parseXML(xml, cls, mode, envLoader);
+            parseXML(xml, cls, mode);
             // XML process check
             meta = repos.getCachedMetaData(cls);
             if (meta != null && (meta.getSourceMode() & mode) == mode) {
@@ -255,7 +250,6 @@ public class PersistenceMetaDataFactory
         }
 
         AnnotationPersistenceMetaDataParser parser = getAnnotationParser();
-        parser.setEnvClassLoader(envLoader);
         parser.setMode(mode);
         parser.parse(cls);
 
@@ -267,27 +261,11 @@ public class PersistenceMetaDataFactory
     /**
      * Parse the given XML resource.
      */
-    private void parseXML(URL xml, Class<?> cls, int mode, 
-    	ClassLoader envLoader) {
+    private void parseXML(URL xml, Class<?> cls, int mode) {
         // spring needs to use the envLoader first for all class resolution,
         // but we must still fall back on application loader
-        ClassLoader loader = repos.getConfiguration().
-            getClassResolverInstance().getClassLoader(cls, null);
-        if (envLoader != null && envLoader != loader) {
-          MultiClassLoader mult = new MultiClassLoader();
-          mult.addClassLoader(envLoader);
-
-          // loader from resolver is usually a multi loader itself
-          if (loader instanceof MultiClassLoader)
-            mult.addClassLoaders((MultiClassLoader)loader);
-          else
-            mult.addClassLoader(loader);
-          loader = mult;
-        }
     
         XMLPersistenceMetaDataParser xmlParser = getXMLParser();
-        xmlParser.setClassLoader(loader);
-        xmlParser.setEnvClassLoader(envLoader);
         xmlParser.setMode(mode);
         try {
             xmlParser.parse(xml);
@@ -344,10 +322,10 @@ public class PersistenceMetaDataFactory
     }
 
     @Override
-    public Class<?> getQueryScope(String queryName, ClassLoader loader) {
+    public Class<?> getQueryScope(String queryName) {
         if (queryName == null)
             return null;
-        Collection<Class<?>> classes = repos.loadPersistentTypes(false, loader);
+        Collection<Class<?>> classes = repos.loadPersistentTypes(false);
         for (Class<?> cls :  classes) {
             if ((AccessController.doPrivileged(J2DoPrivHelper
                 .isAnnotationPresentAction(cls, NamedQuery.class)))
@@ -377,12 +355,11 @@ public class PersistenceMetaDataFactory
     }
 
     @Override
-    public Class<?> getResultSetMappingScope(String rsMappingName,
-        ClassLoader loader) {
+    public Class<?> getResultSetMappingScope(String rsMappingName) {
         if (rsMappingName == null)
             return null;
         
-        Collection<Class<?>> classes = repos.loadPersistentTypes(false, loader);
+        Collection<Class<?>> classes = repos.loadPersistentTypes(false);
         for (Class<?> cls : classes) {
 
             if ((AccessController.doPrivileged(J2DoPrivHelper
@@ -511,8 +488,7 @@ public class PersistenceMetaDataFactory
      * Look for META-INF/orm.xml, and if it doesn't exist, choose a default.
      */
     private File defaultXMLFile() {
-        ClassLoader loader = repos.getConfiguration().
-            getClassResolverInstance().getClassLoader(getClass(), null);
+        ClassLoader loader = repos.getConfiguration().getClassLoader();
         URL rsrc = AccessController.doPrivileged(
             J2DoPrivHelper.getResourceAction(loader, "META-INF/orm.xml"));
         if (rsrc != null) {

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=1190716&r1=1190715&r2=1190716&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 Sat Oct 29 00:44:11 2011
@@ -48,7 +48,6 @@ import org.apache.openjpa.conf.OpenJPACo
 import org.apache.openjpa.conf.OpenJPAProductDerivation;
 import org.apache.openjpa.conf.Specification;
 import org.apache.openjpa.datacache.DataCacheMode;
-import org.apache.openjpa.kernel.MixedLockLevels;
 import org.apache.openjpa.kernel.QueryHints;
 import org.apache.openjpa.lib.conf.AbstractProductDerivation;
 import org.apache.openjpa.lib.conf.Configuration;
@@ -61,9 +60,11 @@ import org.apache.openjpa.lib.meta.XMLMe
 import org.apache.openjpa.lib.meta.XMLVersionParser;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.lib.util.MultiClassLoader;
+import org.apache.openjpa.validation.Validator;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
-
+import static org.apache.openjpa.kernel.MixedLockLevels.*;
 
 /**
  * Sets JPA specification defaults and parses JPA specification XML files.
@@ -78,6 +79,7 @@ import org.xml.sax.SAXException;
  * a named one).
  *
  * @author Abe White
+ * @author Pinaki Poddar
  * @nojavadoc
  */
 public class PersistenceProductDerivation 
@@ -90,11 +92,8 @@ public class PersistenceProductDerivatio
     public static final String RSRC_DEFAULT = "META-INF/persistence.xml";
     public static final BigDecimal VERSION_1_0 = BigDecimal.valueOf(1.0);
 
-    private static final Localizer _loc = Localizer.forPackage
-        (PersistenceProductDerivation.class);
+    private static final Localizer _loc = Localizer.forPackage(PersistenceProductDerivation.class);
 
-    private HashMap<String, PUNameCollision> _puNameCollisions
-        = new HashMap<String,PUNameCollision>();
     
     public static final String PREFIX = "javax.persistence"; 
     
@@ -104,8 +103,11 @@ public class PersistenceProductDerivatio
     
     private static Set<String> _hints = new HashSet<String>();
     
-    // Provider name to filter out PUs that don't belong to this derivation.
-    protected String _providerImplName;
+    /**
+     * The loader used to load resources and classes by name and eventually set into
+     * the configuration.
+     */
+    private final MultiClassLoader _loader;
 
     static {
         _hints.add("javax.persistence.lock.timeout");
@@ -149,8 +151,15 @@ public class PersistenceProductDerivatio
         _hints = Collections.unmodifiableSet(_hints);
     }
     
+    /**
+     * Constructs and configures a class loader to be used for loading
+     * resources and classes by their names.
+     */
 	public PersistenceProductDerivation() {
-		_providerImplName = PersistenceProviderImpl.class.getName();
+		_loader = AccessController.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
+		_loader.addClassLoader(MultiClassLoader.SYSTEM_LOADER);
+		_loader.addClassLoader(MultiClassLoader.THREAD_LOADER);
+		_loader.addClassLoader(this.getClass().getClassLoader());
 	}
     
     public void putBrokerFactoryAliases(Map<String, String> m) {
@@ -171,8 +180,7 @@ public class PersistenceProductDerivatio
     }
 
     @Override
-    public void validate()
-        throws Exception {
+    public void validate() throws Exception {
         // make sure JPA is available
         AccessController.doPrivileged(J2DoPrivHelper.getClassLoaderAction(
             javax.persistence.EntityManagerFactory.class));
@@ -189,26 +197,17 @@ public class PersistenceProductDerivatio
         
         conf.addValue(new EntityManagerFactoryValue());
         
-        conf.readLockLevel.setAlias("optimistic", String.valueOf(MixedLockLevels.LOCK_OPTIMISTIC));
-        conf.readLockLevel.setAlias("optimistic-force-increment", String
-            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT));
-        conf.readLockLevel.setAlias("pessimistic-read", String
-            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_READ));
-        conf.readLockLevel.setAlias("pessimistic-write", String
-            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_WRITE));
-        conf.readLockLevel.setAlias("pessimistic-force-increment", String
-            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT));
-
-        conf.writeLockLevel.setAlias("optimistic", String
-            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC));
-        conf.writeLockLevel.setAlias("optimistic-force-increment", String
-            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT));
-        conf.writeLockLevel.setAlias("pessimistic-read", String
-            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_READ));
-        conf.writeLockLevel.setAlias("pessimistic-write", String
-            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_WRITE));
-        conf.writeLockLevel.setAlias("pessimistic-force-increment", String
-            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT));
+        conf.readLockLevel.setAlias("optimistic",                  String.valueOf(LOCK_OPTIMISTIC));
+        conf.readLockLevel.setAlias("optimistic-force-increment",  String.valueOf(LOCK_OPTIMISTIC_FORCE_INCREMENT));
+        conf.readLockLevel.setAlias("pessimistic-read",            String.valueOf(LOCK_PESSIMISTIC_READ));
+        conf.readLockLevel.setAlias("pessimistic-write",           String.valueOf(LOCK_PESSIMISTIC_WRITE));
+        conf.readLockLevel.setAlias("pessimistic-force-increment", String.valueOf(LOCK_PESSIMISTIC_FORCE_INCREMENT));
+
+        conf.writeLockLevel.setAlias("optimistic",                  String.valueOf(LOCK_OPTIMISTIC));
+        conf.writeLockLevel.setAlias("optimistic-force-increment",  String.valueOf(LOCK_OPTIMISTIC_FORCE_INCREMENT));
+        conf.writeLockLevel.setAlias("pessimistic-read",            String.valueOf(LOCK_PESSIMISTIC_READ));
+        conf.writeLockLevel.setAlias("pessimistic-write",           String.valueOf(LOCK_PESSIMISTIC_WRITE));
+        conf.writeLockLevel.setAlias("pessimistic-force-increment", String.valueOf(LOCK_PESSIMISTIC_FORCE_INCREMENT));
 
 
         configureBeanValidation(conf);
@@ -230,8 +229,8 @@ public class PersistenceProductDerivatio
      */
     private void configureBeanValidation(OpenJPAConfigurationImpl conf) {
         // Validation defines/adds the following plugins to OpenJPA Configuration
-        conf.validationFactory         = conf.addObject(JPAProperties.VALIDATE_FACTORY); 
-        conf.validator                 = conf.addObject("Validator");
+        conf.validationFactory         = conf.addObject(Object.class, JPAProperties.VALIDATE_FACTORY); 
+        conf.validator                 = conf.addObject(Validator.class, "Validator");
         conf.validationMode            = conf.addString(JPAProperties.VALIDATE_MODE);
         conf.validationGroupPrePersist = conf.addString(JPAProperties.VALIDATE_PRE_PERSIST);
         conf.validationGroupPreUpdate  = conf.addString(JPAProperties.VALIDATE_PRE_UPDATE);
@@ -302,12 +301,10 @@ public class PersistenceProductDerivatio
      * Load configuration from the given persistence unit with the specified
      * user properties.
      */
-    public ConfigurationProvider load(PersistenceUnitInfo pinfo, Map m)
-        throws IOException {
+    public ConfigurationProvider load(PersistenceUnitInfo pinfo, Map m) throws IOException {
         if (pinfo == null)
             return null;
-        if (!isOpenJPAPersistenceProvider(pinfo, null)) {
-            warnUnknownProvider(pinfo);
+        if (!isOpenJPAPersistenceProvider(pinfo)) {
             return null;
         }
 
@@ -333,7 +330,7 @@ public class PersistenceProductDerivatio
             rsrc = RSRC_DEFAULT;
         
         ConfigurationProviderImpl cp = new ConfigurationProviderImpl();
-        Boolean ret = load(cp, rsrc, name, m, null, explicit);
+        Boolean ret = load(cp, rsrc, name, m, explicit);
         if (ret != null)
             return (ret.booleanValue()) ? cp : null;
         if (explicit)
@@ -342,8 +339,7 @@ public class PersistenceProductDerivatio
         // persistence.xml does not exist; just load map
         PersistenceUnitInfoImpl pinfo = new PersistenceUnitInfoImpl();
         pinfo.fromUserProperties(m);
-        if (!isOpenJPAPersistenceProvider(pinfo, null)) {
-            warnUnknownProvider(pinfo);
+        if (!isOpenJPAPersistenceProvider(pinfo)) {
             return null;
         }
         cp.addProperties(pinfo.toOpenJPAProperties());
@@ -351,27 +347,25 @@ public class PersistenceProductDerivatio
     }
 
     @Override
-    public ConfigurationProvider load(String rsrc, String anchor, 
-        ClassLoader loader)
-        throws IOException {
+    public ConfigurationProvider load(String rsrc, String anchor)  throws IOException {
         if (rsrc != null && !rsrc.endsWith(".xml"))
             return null;
         ConfigurationProviderImpl cp = new ConfigurationProviderImpl();
-        if (load(cp, rsrc, anchor, null, loader, true) == Boolean.TRUE)
+        if (load(cp, rsrc, anchor, null, true) == Boolean.TRUE)
             return cp;
         return null;
     }
 
     @Override
-    public ConfigurationProvider load(File file, String anchor) 
-        throws IOException {
+    public ConfigurationProvider load(File file, String anchor) throws IOException {
         if (!file.getName().endsWith(".xml"))
             return null;
 
-        ConfigurationParser parser = new ConfigurationParser(null);
+        ConfigurationParser parser = new ConfigurationParser(_loader, null);
         parser.parse(file);
-        return load(findUnit((List<PersistenceUnitInfoImpl>) 
-            parser.getResults(), anchor, null), null);
+        List<PersistenceUnitInfoImpl> units = (List<PersistenceUnitInfoImpl>) parser.getResults();
+        PersistenceUnitInfoImpl unit = findUnit(units, anchor);
+        return load(unit, null);
     }
 
     @Override
@@ -380,8 +374,8 @@ public class PersistenceProductDerivatio
     }
 
     @Override
-    public List getAnchorsInFile(File file) throws IOException {
-        ConfigurationParser parser = new ConfigurationParser(null);
+    public List<String> getAnchorsInFile(File file) throws IOException {
+        ConfigurationParser parser = new ConfigurationParser(_loader, null);
         try {
             parser.parse(file);
             return getUnitNames(parser);
@@ -397,7 +391,7 @@ public class PersistenceProductDerivatio
         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)) {
+			if (provider == null || provider.indexOf("openjpa") != -1) {
 				names.add(unit.getPersistenceUnitName());
 			} else {
 				// Should trace something, but logging isn't configured yet.
@@ -408,13 +402,11 @@ public class PersistenceProductDerivatio
     }
 
     @Override
-    public List getAnchorsInResource(String resource) throws Exception {
-        ConfigurationParser parser = new ConfigurationParser(null);
+    public List<String> getAnchorsInResource(String resource) throws Exception {
+        ConfigurationParser parser = new ConfigurationParser(_loader, null);
         try {
-        	List results = new ArrayList();
-            ClassLoader loader = AccessController.doPrivileged(
-                J2DoPrivHelper.getContextClassLoaderAction());
-            List<URL> urls = getResourceURLs(resource, loader);
+        	List<String> results = new ArrayList<String>();
+            List<URL> urls = getResourceURLs(resource);
             if (urls != null) {
                 for (URL url : urls) {
                     parser.parse(url);
@@ -429,7 +421,7 @@ public class PersistenceProductDerivatio
     }
 
     @Override
-    public ConfigurationProvider loadGlobals(ClassLoader loader)
+    public ConfigurationProvider loadGlobals()
         throws IOException {
         String[] prefixes = ProductDerivations.getConfigurationPrefixes();
         String rsrc = null;
@@ -451,54 +443,52 @@ public class PersistenceProductDerivatio
             return null;
 
         ConfigurationProviderImpl cp = new ConfigurationProviderImpl();
-        if (load(cp, rsrc, anchor, null, loader, explicit) == Boolean.TRUE)
+        if (load(cp, rsrc, anchor, null, explicit) == Boolean.TRUE)
             return cp;
         return null;
     }
 
     @Override
-    public ConfigurationProvider loadDefaults(ClassLoader loader)
+    public ConfigurationProvider loadDefaults()
         throws IOException {
         ConfigurationProviderImpl cp = new ConfigurationProviderImpl();
-        if (load(cp, RSRC_DEFAULT, null, null, loader, false) == Boolean.TRUE)
+        if (load(cp, RSRC_DEFAULT, null, null, false) == Boolean.TRUE)
             return cp;
         return null;
     }
 
-      /**
-      * This method checks to see if the provided <code>puName</code> was
-      * detected in multiple resources. If a collision is detected, a warning
-      * will be logged and this method will return <code>true</code>.
-      * <p>
-      */
-     public boolean checkPuNameCollisions(Log logger,String puName){
-         PUNameCollision p = _puNameCollisions.get(puName);
-         if (p != null){
-             p.logCollision(logger);
-             return true;
-         }
-         return false;
+     private void checkPuNameCollisions(){
      }
 
-    private static List<URL> getResourceURLs(String rsrc, ClassLoader loader)
+    private List<URL> getResourceURLs(String rsrc)
         throws IOException {
         Enumeration<URL> urls = null;
         try {
-            urls = AccessController.doPrivileged(J2DoPrivHelper.getResourcesAction(loader, rsrc)); 
+            urls = AccessController.doPrivileged(J2DoPrivHelper.getResourcesAction(_loader, rsrc)); 
             if (!urls.hasMoreElements()) {
                 if (!rsrc.startsWith("META-INF"))
-                  urls = AccessController.doPrivileged(J2DoPrivHelper.getResourcesAction(loader, "META-INF/" + rsrc));
+                  urls = AccessController.doPrivileged(J2DoPrivHelper.getResourcesAction(_loader, "META-INF/" + rsrc));
                 if (!urls.hasMoreElements())
                     return null;
             }
         } catch (PrivilegedActionException pae) {
             throw (IOException) pae.getException();
         }
-
-        return Collections.list(urls);
+        List<URL> result = new ArrayList<URL>();
+        for (;urls.hasMoreElements();) {
+        	URL url = urls.nextElement();
+        	if (!result.contains(url)) {
+        		result.add(url);
+        	}
+        }
+        return result;
     }
 
     /**
+     * The core load method to load the configuration resource.
+     * The class loader that loads the configuration resource is remembered by the provider
+     * and later {@link ConfigurationProvider#setInto(Configuration) set into} {@link Configuration}.
+     * <br>
      * Looks through the resources at <code>rsrc</code> for a configuration
      * file that matches <code>name</code> (or an unnamed one if
      * <code>name</code> is <code>null</code>), and loads the XML in the
@@ -508,26 +498,21 @@ public class PersistenceProductDerivatio
      * @return {@link Boolean#TRUE} if the resource was loaded, null if it
      * does not exist, or {@link Boolean#FALSE} if it is not for OpenJPA
      */
-    private Boolean load(ConfigurationProviderImpl cp, String rsrc, 
-        String name, Map m, ClassLoader loader, boolean explicit)
+    private Boolean load(ConfigurationProviderImpl cp, String rsrc, String name, Map m, boolean explicit)
         throws IOException {
-        if (loader == null)
-            loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
-
-        List<URL> urls = getResourceURLs(rsrc, loader);
+        List<URL> urls = getResourceURLs(rsrc);
         if (urls == null || urls.size() == 0)
             return null;
 
-        ConfigurationParser parser = new ConfigurationParser(m);
-        PersistenceUnitInfoImpl pinfo = parseResources(parser, urls, name, loader);
+        ConfigurationParser parser = new ConfigurationParser(_loader, m);
+        PersistenceUnitInfoImpl pinfo = parseResources(parser, urls, name);
         if (pinfo == null) {
             if (!explicit)
                 return Boolean.FALSE;
             throw new MissingResourceException(_loc.get("missing-xml-config", 
                 rsrc, String.valueOf(name)).getMessage(), getClass().getName(), rsrc);
-        } else if (!isOpenJPAPersistenceProvider(pinfo, loader)) {
+        } else if (!isOpenJPAPersistenceProvider(pinfo)) {
             if (!explicit) {
-                warnUnknownProvider(pinfo);
                 return Boolean.FALSE;
             }
             throw new MissingResourceException(_loc.get("unknown-provider", 
@@ -540,6 +525,7 @@ public class PersistenceProductDerivatio
 
         cp.addProperties(pinfo.toOpenJPAProperties());
         cp.setSource(pinfo.getPersistenceXmlFileUrl().toString());
+        
         return Boolean.TRUE;
     }
 
@@ -549,100 +535,70 @@ public class PersistenceProductDerivatio
      * no name given (preferring an unnamed OpenJPA unit to a named one).
      */
     private PersistenceUnitInfoImpl parseResources(ConfigurationParser parser,
-        List<URL> urls, String name, ClassLoader loader)
+        List<URL> urls, String name)
         throws IOException {
         List<PersistenceUnitInfoImpl> pinfos = new ArrayList<PersistenceUnitInfoImpl>();
         for (URL url : urls) {
             parser.parse(url);
             pinfos.addAll((List<PersistenceUnitInfoImpl>) parser.getResults());
-        }
-        return findUnit(pinfos, name, loader);
+            PersistenceUnitInfoImpl pu = null;
+         }
+        return findUnit(pinfos, name);
     }
 
     /**
-     * Find the unit with the given name, or an OpenJPA unit if no name is
-     * given (preferring an unnamed OpenJPA unit to a named one).
+     * Finds the unit with the given name in the given list of persistence unit infos.
+     * Ignores any persistence unit info that does not use OpenJPA as persistence provider.
+     * If the same unit name is found in multiple units, returns the first unit but
+     * records the rest as duplicates.
      */
-    private PersistenceUnitInfoImpl findUnit(List<PersistenceUnitInfoImpl> 
-        pinfos, String name, ClassLoader loader) {
-        PersistenceUnitInfoImpl ojpa = null;
+    private PersistenceUnitInfoImpl findUnit(List<PersistenceUnitInfoImpl> pinfos, String name) {
+        PUNameCollision _puNameCollisions = null;
         PersistenceUnitInfoImpl result = null;
         for (PersistenceUnitInfoImpl pinfo : pinfos) {
-            // found named unit?
-            if (name != null) {
-                if (name.equals(pinfo.getPersistenceUnitName())){
-                    if (result != null){
-                        this.addPuNameCollision(name, result.getPersistenceXmlFileUrl().toString(),
-                                pinfo.getPersistenceXmlFileUrl().toString());
-
-                    } else {
-                        // Grab a ref to the pinfo that matches the name we're
-                        // looking for. Keep going to look for duplicate pu names.
-                        result = pinfo;
-                    }
-                }
-                continue;
-            }
-
-            if (isOpenJPAPersistenceProvider(pinfo, loader)) {
-                // if no name given and found unnamed unit, return it.  
-                // otherwise record as default unit unless we find a better match later
-                if (StringUtils.isEmpty(pinfo.getPersistenceUnitName()))
-                    return pinfo;
-                if (ojpa == null)
-                    ojpa = pinfo;
-            }
-        }
-        if(result!=null){
-            return result;
-        }
-        return ojpa;
+        	if (!isOpenJPAPersistenceProvider(pinfo)) {
+        		continue;
+        	}
+        	if (name == null || name.equals(pinfo.getPersistenceUnitName())) {
+        		if (result == null) {
+        			result = pinfo;
+        		} else {
+        			if (_puNameCollisions == null) {
+        				_puNameCollisions = new PUNameCollision(name, result, pinfo);
+        			} else {
+        				_puNameCollisions.addDuplicate(pinfo);
+        			}
+        		}
+        	} 
+        }
+        if (_puNameCollisions != null) {
+        	_puNameCollisions.logCollision();
+        }
+        return result;
     }
 
     /**
-     * Return whether the given persistence unit uses an OpenJPA provider.
-     */
-    private static boolean isOpenJPAPersistenceProvider(PersistenceUnitInfo pinfo, ClassLoader loader) {
-        String provider = pinfo.getPersistenceProviderClassName();
-        if (StringUtils.isEmpty(provider) || PersistenceProviderImpl.class.getName().equals(provider))
+     * Affirms if the given provider is recognized as an OpenJPA provider.
+     * An empty string or a name containing <tt>"openjpa"</tt> returns true.
+     */
+    private boolean isOpenJPAPersistenceProvider(PersistenceUnitInfo pinfo) {
+    	String provider = pinfo.getPersistenceProviderClassName();
+        if (StringUtils.isEmpty(provider) || "void".equals(provider) || provider.indexOf("openjpa") != -1)
             return true;
 
-        if (loader == null)
-            loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
-        try {
-            if (PersistenceProviderImpl.class.isAssignableFrom(Class.forName(provider, false, loader)))
-                return true;
-        } catch (Throwable t) {
-            log(_loc.get("unloadable-provider", provider, t).getMessage());
-            return false;
-        }
+        log(_loc.get("unrecognized-provider", provider).getMessage());
         return false;
     }
 
-    /**
-     * Warn the user that we could only find an unrecognized persistence 
-     * provider.
-     */
-    private static void warnUnknownProvider(PersistenceUnitInfo pinfo) {
-        log(_loc.get("unrecognized-provider", pinfo.getPersistenceProviderClassName()).getMessage());
-    }
     
     /**
-     * Log a message.   
+     * Log a message on the console because no logging mechanism has been configured yet.   
      */
     private static void log(String msg) {
         // at this point logging isn't configured yet
-        System.err.println(msg);
+        System.err.println("WARN: " + msg);
     }
 
-    private void addPuNameCollision(String puName, String file1, String file2){
-        PUNameCollision pun = _puNameCollisions.get(puName);
-        if (pun != null){
-            pun.addCollision(file1, file2);
-        } else {
-            _puNameCollisions.put(puName, new PUNameCollision(puName, file1, file2));
-        }
-    }
     
     /**
      * Custom configuration provider.   
@@ -653,6 +609,7 @@ public class PersistenceProductDerivatio
         private String _source;
 
         public ConfigurationProviderImpl() {
+        	super();
         }
 
         public ConfigurationProviderImpl(Map props) {
@@ -666,6 +623,9 @@ public class PersistenceProductDerivatio
             _source = source;
         }
 
+        /**
+         * Sets the configuration.
+         */
         @Override
         public void setInto(Configuration conf) {
             if (conf instanceof OpenJPAConfiguration) {
@@ -694,17 +654,17 @@ public class PersistenceProductDerivatio
             }
             super.setInto(conf, null);
             
-            // At this point user properties have been loaded into the configuration. Apply any modifications based off
-            // those.
+            // At this point user properties have been loaded into the configuration. 
+            // Apply any modifications based off those.
             if (conf instanceof OpenJPAConfiguration) {
                 OpenJPAConfiguration oconf = (OpenJPAConfiguration) conf;
-                // If the datacache is enabled, make sure we have a RemoteCommitProvider
+                // If the data cache is enabled, make sure we have a RemoteCommitProvider
                 String dc = oconf.getDataCache();
                 String rcp = oconf.getRemoteCommitProvider();
-                // If the datacache is set and is something other than false
-                if (dc != null && dc.equals("false") == false) {
+                // If the data cache is set and is something other than false
+                if (!"false".equals(dc)) {
                     // If RCP is null or empty, set it to sjvm.
-                    if (rcp == null || (rcp != null && rcp.equals("") == false)) {
+                    if (StringUtils.isEmpty(rcp)) {
                         oconf.setRemoteCommitProvider("sjvm");
                     }
                 }
@@ -737,8 +697,6 @@ public class PersistenceProductDerivatio
         private static final String PERSISTENCE_XSD_1_0 = "persistence_1_0.xsd";
         private static final String PERSISTENCE_XSD_2_0 = "persistence_2_0.xsd";
 
-        private static final Localizer _loc = Localizer.forPackage
-            (ConfigurationParser.class);
 
         private final Map _map;
         private PersistenceUnitInfoImpl _info = null;
@@ -747,7 +705,15 @@ public class PersistenceProductDerivatio
         private String _schemaLocation;
         private boolean _excludeUnlistedSet = false;
 
-        public ConfigurationParser(Map map) {
+        /**
+         * Parse configuration information.
+         * 
+         * @param loader Class Loader to load resources. Must not be null.
+         * @param 
+         * @param map
+         */
+        public ConfigurationParser(ClassLoader loader, Map map) {
+        	super(loader);
             _map = map;
             setCaching(false);
             setValidating(true);
@@ -766,8 +732,7 @@ public class PersistenceProductDerivatio
                 _persistenceVersion = vp.getVersion();
                 _schemaLocation = vp.getSchemaLocation();
             } catch (Throwable t) {
-                    log(_loc.get("version-check-error", 
-                        _source.toString()).toString());
+                    log(_loc.get("version-check-error", _source.toString()).toString());
             }            
             super.parse(url);
         }
@@ -776,8 +741,7 @@ public class PersistenceProductDerivatio
         public void parse(File file)
             throws IOException {
             try {
-                _source = AccessController.doPrivileged(J2DoPrivHelper
-                    .toURLAction(file));
+                _source = AccessController.doPrivileged(J2DoPrivHelper.toURLAction(file));
             } catch (PrivilegedActionException pae) {
                 throw (MalformedURLException) pae.getException();
             }
@@ -788,11 +752,22 @@ public class PersistenceProductDerivatio
                 _persistenceVersion = vp.getVersion();
                 _schemaLocation = vp.getSchemaLocation();                
             } catch (Throwable t) {
-                    log(_loc.get("version-check-error", 
-                        _source.toString()).toString());
+                    log(_loc.get("version-check-error", _source.toString()).toString());
             }            
             super.parse(file);
         }
+        
+        boolean peek(String name, URL fileOrURL) {
+            XMLVersionParser vp = new XMLVersionParser("persistence");
+            try {
+                vp.parse(fileOrURL);
+                _persistenceVersion = vp.getVersion();
+                _schemaLocation = vp.getSchemaLocation();                
+            } catch (Throwable t) {
+                    log(_loc.get("version-check-error", _source.toString()).toString());
+            }            
+            return vp.unitNames().contains(name);
+        }
 
         @Override
         protected Object getSchemaSource() {
@@ -930,9 +905,8 @@ public class PersistenceProductDerivatio
                     return new BigDecimal(_info.getPersistenceXMLSchemaVersion());
                 }
                 catch (Throwable t) {
-                    log(_loc.get("invalid-version-attribute", 
-                        _info.getPersistenceXMLSchemaVersion(),
-                        VERSION_1_0.toString()).toString());
+                    log(_loc.get("invalid-version-attribute", _info.getPersistenceXMLSchemaVersion(),
+                        VERSION_1_0).toString());
                 }
             }
             // OpenJPA supports persistence files without a version attribute.
@@ -945,32 +919,40 @@ public class PersistenceProductDerivatio
     
     
     /**
-     * This private class is used to hold onto information regarding
-     * PersistentUnit name collisions.
+     * Holds the URLs of persistence configuration that contain the same unit name.
      */
-    private static class PUNameCollision{
-        private String _puName;
-        private Set<String> _resources;
-
-        PUNameCollision(String puName, String file1, String file2) {
-            _resources = new LinkedHashSet<String>();
-            _resources.add(file1);
-            _resources.add(file2);
+    private static class PUNameCollision {
+    	private final String _puName;
+        private final PersistenceUnitInfoImpl _original;
+        private final Set<PersistenceUnitInfoImpl> _duplicates;
+
+        PUNameCollision(String pu, PersistenceUnitInfoImpl original, PersistenceUnitInfoImpl duplicate) {
+        	_puName = pu;
+        	_original = original;
+        	_duplicates = new LinkedHashSet<PersistenceUnitInfoImpl>();
+        	_duplicates.add(duplicate);
 
-            _puName=puName;
         }
         
-        void logCollision(Log logger){
-            if(logger.isWarnEnabled()){
-                logger.warn(_loc.getFatal("dup-pu", new Object[]{_puName,_resources.toString(),	
-                    _resources.iterator().next()}));
-            }
+        void logCollision(){
+        	String duplicates = listDuplicates();
+        	if (_puName == null) {
+        		log(_loc.get("dup-pu-unnamed", _original, duplicates).toString());
+        	} else {
+        		log(_loc.get("dup-pu", _puName, _original, duplicates).toString());
+        	}
         }
         
-        void addCollision(String file1, String file2){
-            _resources.add(file1);
-            _resources.add(file2);
+        void addDuplicate(PersistenceUnitInfoImpl dup){
+        	_duplicates.add(dup);
+        }
+        
+        String listDuplicates() {
+        	StringBuilder buf = new StringBuilder("\r\n");
+        	for (PersistenceUnitInfoImpl pu : _duplicates) {
+        		buf.append(pu).append("\r\n");
+        	}
+        	return buf.toString();
         }
-
     }
 }



Mime
View raw message