You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2007/05/07 23:38:21 UTC

svn commit: r536001 - /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java

Author: pcl
Date: Mon May  7 14:38:20 2007
New Revision: 536001

URL: http://svn.apache.org/viewvc?view=rev&rev=536001
Log:
Propagate the provided classloader further into the PCEnhancer call stack.

Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?view=diff&rev=536001&r1=536000&r2=536001
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Mon May  7 14:38:20 2007
@@ -181,9 +181,30 @@
      * because the configuration might be an
      * implementation-specific subclass whose metadata
      * required more than just base metadata files
+     * @deprecated use {@link #PCEnhancer(OpenJPAConfiguration, BCClass,
+        MetaDataRepository, ClassLoader)} instead. 
      */
     public PCEnhancer(OpenJPAConfiguration conf, BCClass type,
         MetaDataRepository repos) {
+        this(conf, type, repos, (ClassLoader) null);
+    }
+
+    /**
+     * Constructor. Supply configuration.
+     *
+     * @param type the bytecode representation fo the type to
+     * enhance; this can be created from any stream or file
+     * @param repos a metadata repository to use for metadata access,
+     * or null to create a new reporitory; the repository
+     * from the given configuration isn't used by default
+     * because the configuration might be an
+     * implementation-specific subclass whose metadata
+     * required more than just base metadata files
+     * @param loader the environment classloader to use for loading
+     * classes and resources.
+     */
+    public PCEnhancer(OpenJPAConfiguration conf, BCClass type,
+        MetaDataRepository repos, ClassLoader loader) {
         _pc = type;
         _log = conf.getLog(OpenJPAConfiguration.LOG_ENHANCE);
 
@@ -192,7 +213,7 @@
             _repos.setSourceMode(MetaDataRepository.MODE_META);
         } else
             _repos = repos;
-        _meta = _repos.getMetaData(type.getType(), null, false);
+        _meta = _repos.getMetaData(type.getType(), loader, false);
     }
 
     /**
@@ -3641,7 +3662,7 @@
                 bc = project.loadClass((String) o);
             else
                 bc = project.loadClass((Class) o);
-            enhancer = new PCEnhancer(conf, bc, repos);
+            enhancer = new PCEnhancer(conf, bc, repos, loader);
             if (writer != null)
                 enhancer.setBytecodeWriter(writer);
             enhancer.setDirectory(flags.directory);



Re: svn commit: r536001 - /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java

Posted by Patrick Linskey <pl...@gmail.com>.
I needed it to get my IntelliJ plugin working. I probably could have
set the thread's context classloader, but it seemed like this was a
better fix.

-Patrick

On 5/7/07, Marc Prud'hommeaux <mp...@apache.org> wrote:
>
> Out of curiosity, is there an existing problem that this fixes, or
> did you just notice through code inspection they we weren't passing
> the ClassLoader in places where it appeared we should?
>
>
> On May 7, 2007, at 2:38 PM, pcl@apache.org wrote:
>
> > Author: pcl
> > Date: Mon May  7 14:38:20 2007
> > New Revision: 536001
> >
> > URL: http://svn.apache.org/viewvc?view=rev&rev=536001
> > Log:
> > Propagate the provided classloader further into the PCEnhancer call
> > stack.
> >
> > Modified:
> >     incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/
> > openjpa/enhance/PCEnhancer.java
>
>
>


-- 
Patrick Linskey
202 669 5907

Re: svn commit: r536001 - /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java

Posted by Marc Prud'hommeaux <mp...@apache.org>.
Out of curiosity, is there an existing problem that this fixes, or  
did you just notice through code inspection they we weren't passing  
the ClassLoader in places where it appeared we should?


On May 7, 2007, at 2:38 PM, pcl@apache.org wrote:

> Author: pcl
> Date: Mon May  7 14:38:20 2007
> New Revision: 536001
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=536001
> Log:
> Propagate the provided classloader further into the PCEnhancer call  
> stack.
>
> Modified:
>     incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/ 
> openjpa/enhance/PCEnhancer.java