openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r502326 - in /incubator/openjpa/trunk/openjpa-kernel/src/main: java/org/apache/openjpa/meta/InterfaceImplGenerator.java resources/org/apache/openjpa/meta/localizer.properties
Date Thu, 01 Feb 2007 19:36:22 GMT
Author: ppoddar
Date: Thu Feb  1 11:36:21 2007
New Revision: 502326

URL: http://svn.apache.org/viewvc?view=rev&rev=502326
Log:
Classloader used to generate dynamic implementaion of managed interface uses interfaces' classloader
as parent

Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java?view=diff&rev=502326&r1=502325&r2=502326
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java
Thu Feb  1 11:36:21 2007
@@ -48,11 +48,9 @@
     private final MetaDataRepository _repos;
     private final Map _impls = new WeakHashMap();
     private final Project _project = new Project();
-    private final BCClassLoader _loader = new BCClassLoader(_project);
-
+ 
     // distinct project / loader for enhanced version of class
     private final Project _enhProject = new Project();
-    private final BCClassLoader _enhLoader = new BCClassLoader(_enhProject);
 
     /**
      * Constructor.  Supply repository.
@@ -73,6 +71,8 @@
         if (impl != null)
             return impl;
 
+        ClassLoader parentLoader = iface.getClassLoader();
+        BCClassLoader loader = new BCClassLoader(_project, parentLoader);
         BCClass bc = _project.loadClass(getClassName(meta));
         bc.declareInterface(iface);
         ClassMetaData sup = meta.getPCSuperclassMetaData();
@@ -88,14 +88,14 @@
         // first load the base class as the enhancer requires the class
         // to be available
         try {
-            meta.setInterfaceImpl(Class.forName(bc.getName(), true, _loader));
+            meta.setInterfaceImpl(Class.forName(bc.getName(), true, loader));
         } catch (Throwable t) {
-            throw new InternalException(_loc.get("interface-load"), t).
-                setFatal(true);
+            throw new InternalException(_loc.get("interface-load", iface, 
+                loader), t).setFatal(true);
         }
         // copy the BCClass into the enhancer project.
         bc = _enhProject.loadClass(new ByteArrayInputStream(bc.toByteArray()), 
-            _loader);
+            loader);
         PCEnhancer enhancer = new PCEnhancer(_repos.getConfiguration(), bc, 
             meta);
 
@@ -103,12 +103,13 @@
         if (result != PCEnhancer.ENHANCE_PC)
             throw new InternalException(_loc.get("interface-badenhance", 
                 iface)).setFatal(true);
+        BCClassLoader enhLoader = new BCClassLoader(_enhProject, parentLoader);
         try{
             // load the class for real.
-            impl = Class.forName(bc.getName(), true, _enhLoader);
+            impl = Class.forName(bc.getName(), true, enhLoader);
         } catch (Throwable t) {
-            throw new InternalException(_loc.get("interface-load2"), t).
-                setFatal(true);
+            throw new InternalException(_loc.get("interface-load2", iface, 
+                enhLoader), t).setFatal(true);
         }
         // cache the generated impl.
         _impls.put(iface, impl);

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties?view=diff&rev=502326&r1=502325&r2=502326
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
Thu Feb  1 11:36:21 2007
@@ -294,3 +294,8 @@
 scanning-resource: Scanning resource "{0}" for persistent types.
 scan-found-names: Scan of "{1}" found persistent types {0}.
 parse-found-names: parsePersistentTypeNames() found {0}.
+interface-load: Dynamic implementation of managed "{0}" can not be defined \
+	using classloader "{1}". See nested exception for details.
+interface-load2: Enhanced dynamic implementaion of managed "{0}" can not be \
+	defined using classloader "{1}". See nested exception for details.
+interface-badenhance: Dynamic implementaion of "{0}" can not be enhanced.
\ No newline at end of file



Mime
View raw message