openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1194905 - in /openjpa/trunk: openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ openjpa-...
Date Sat, 29 Oct 2011 15:26:44 GMT
Author: ppoddar
Date: Sat Oct 29 15:26:44 2011
New Revision: 1194905

URL: http://svn.apache.org/viewvc?rev=1194905&view=rev
Log:
OPENJPA-2057: Change classloading scheme

Modified:
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
    openjpa/trunk/openjpa-persistence/src/main/resources/META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java?rev=1194905&r1=1194904&r2=1194905&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
Sat Oct 29 15:26:44 2011
@@ -1103,7 +1103,7 @@ public class ConfigurationImpl
         PluginValue<T> val = new PluginValue<T>(type, property, singleton);
         addValue(val);
         if (singleton) {
-        	val.setInstantiatingGetter("get" + property + "Instance");
+        	val.setInstantiatingGetter("get" + removePrefix(property) + "Instance");
         }
         return val;
     }
@@ -1143,4 +1143,8 @@ public class ConfigurationImpl
 		return _pluginLoader;
 	}
 
+	private String removePrefix(String s) {
+		int index = s.lastIndexOf('.');
+		return index == -1 ? s : s.substring(index+1);
+	}
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java?rev=1194905&r1=1194904&r2=1194905&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java
Sat Oct 29 15:26:44 2011
@@ -38,13 +38,11 @@ public class TestCacheModeInvalid extend
                 "openjpa.jdbc.JDBCListeners", new JDBCListener [] { getListener() });
             emf = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory("cache-mode-invalid",
                 "META-INF/caching-persistence-invalid.xml", propertiesMap );
+            fail("Expected SAX parse error for invalid entry");
         } catch (Throwable e) {
-            exceptionCaught = true;
-            assertException(e, org.apache.openjpa.util.GeneralException.class);
             String msg = e.getMessage();
             assertTrue(msg.contains("org.xml.sax.SAXException"));
         }
-        assertTrue(exceptionCaught);
     }
 
     @Override

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=1194905&r1=1194904&r2=1194905&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 15:26:44 2011
@@ -61,6 +61,7 @@ import org.apache.openjpa.lib.meta.XMLVe
 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.persistence.osgi.BundleUtils;
 import org.apache.openjpa.validation.Validator;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
@@ -151,15 +152,21 @@ public class PersistenceProductDerivatio
         _hints = Collections.unmodifiableSet(_hints);
     }
     
+    public PersistenceProductDerivation() {
+    	this(false);
+    }
+    
     /**
      * Constructs and configures a class loader to be used for loading
      * resources and classes by their names.
      */
-	public PersistenceProductDerivation() {
+	public PersistenceProductDerivation(boolean osgi) {
 		_loader = AccessController.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
-		_loader.addClassLoader(MultiClassLoader.SYSTEM_LOADER);
+		if (osgi) 
+			_loader.addClassLoader(BundleUtils.getBundleClassLoader());
 		_loader.addClassLoader(MultiClassLoader.THREAD_LOADER);
 		_loader.addClassLoader(this.getClass().getClassLoader());
+		_loader.addClassLoader(MultiClassLoader.SYSTEM_LOADER);
 	}
     
     public void putBrokerFactoryAliases(Map<String, String> m) {

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java?rev=1194905&r1=1194904&r2=1194905&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
Sat Oct 29 15:26:44 2011
@@ -90,8 +90,7 @@ public class PersistenceProviderImpl
      * @return EntityManagerFactory or null if anything goes wrong during loading resources.
      */
     public OpenJPAEntityManagerFactory createEntityManagerFactory(String name, String resource,
Map m) {
-        PersistenceProductDerivation pd = BundleUtils.runningUnderOSGi() 
-        	? new OSGiDerivation() : new PersistenceProductDerivation();
+        PersistenceProductDerivation pd = new PersistenceProductDerivation(BundleUtils.runningUnderOSGi());
         ProductDerivations.load(resource, name);
         try {
             Object poolValue = Configurations.removeProperty(EMF_POOL, m);
@@ -165,9 +164,7 @@ public class PersistenceProviderImpl
     }
 
     public OpenJPAEntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo
pui, Map m) {
-        PersistenceProductDerivation pd = BundleUtils.runningUnderOSGi() 
-        		? new OSGiDerivation() 
-        		: new PersistenceProductDerivation();
+        PersistenceProductDerivation pd = new PersistenceProductDerivation(BundleUtils.runningUnderOSGi());
         try {
             Object poolValue = Configurations.removeProperty(EMF_POOL, m);
             ConfigurationProvider cp = pd.load(pui, m);

Modified: openjpa/trunk/openjpa-persistence/src/main/resources/META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/resources/META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation?rev=1194905&r1=1194904&r2=1194905&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/resources/META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/resources/META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation
Sat Oct 29 15:26:44 2011
@@ -15,4 +15,3 @@
 # specific language governing permissions and limitations
 # under the License.
 org.apache.openjpa.persistence.PersistenceProductDerivation
-org.apache.openjpa.persistence.osgi.OSGiDerivation



Mime
View raw message