bodewig     2004/04/16 00:48:49

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs XSLTProcess.java
  Log:
  Set context classloader in <xslt>, PR: 24802
  
  Revision  Changes    Path
  1.586     +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.585
  retrieving revision 1.586
  diff -u -r1.585 -r1.586
  --- WHATSNEW  14 Apr 2004 16:13:26 -0000      1.585
  +++ WHATSNEW  16 Apr 2004 07:48:49 -0000      1.586
  @@ -113,6 +113,9 @@
   * <import optional="false"> and <import optional="true">
     behaved identically.
   
  +* <xslt> now sets the context classloader if you've specified a nested
  +  <classpath>.  Bugzilla report 24802.
  +
   Other changes:
   --------------
   
  
  
  
  1.83      +21 -3     
ant/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  
  Index: XSLTProcess.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- XSLTProcess.java  9 Mar 2004 16:48:07 -0000       1.82
  +++ XSLTProcess.java  16 Apr 2004 07:48:49 -0000      1.83
  @@ -121,6 +121,18 @@
       private boolean reuseLoadedStylesheet = true;
   
       /**
  +     * AntClassLoader for the nested &lt;classpath&gt; - if set.
  +     *
  +     * <p>We keep this here in order to reset the context classloader
  +     * in execute.  We can't use liaison.getClass().getClassLoader()
  +     * since the actual liaison class may have been loaded by a loader
  +     * higher up (system classloader, for example).</p>
  +     *
  +     * @since Ant 1.6.2
  +     */
  +    private AntClassLoader loader = null;
  +
  +    /**
        * Creates a new XSLTProcess Task.
        */
       public XSLTProcess() {
  @@ -170,6 +182,7 @@
           if (inFile != null && !inFile.exists()) {
               throw new BuildException("input file " + inFile.toString() + " 
does not exist", getLocation());
           }
  +
           try {
               if (baseDir == null) {
                   baseDir = getProject().resolveFile(".");
  @@ -233,6 +246,10 @@
                   }
               }
           } finally {
  +            if (loader != null) {
  +                loader.resetThreadContextLoader();
  +                loader = null;
  +            }
               liaison = null;
               stylesheetLoaded = false;
               baseDir = savedBaseDir;
  @@ -379,8 +396,9 @@
           if (classpath == null) {
               return Class.forName(classname);
           } else {
  -            AntClassLoader al = getProject().createClassLoader(classpath);
  -            Class c = Class.forName(classname, true, al);
  +            loader = getProject().createClassLoader(classpath);
  +            loader.setThreadContextLoader();
  +            Class c = Class.forName(classname, true, loader);
               return c;
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to