ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r453032 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/AntClassLoader.java src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java
Date Wed, 04 Oct 2006 21:19:00 GMT
Author: peterreilly
Date: Wed Oct  4 14:18:59 2006
New Revision: 453032

URL: http://svn.apache.org/viewvc?view=rev&rev=453032
Log:
another go at bugzilla 38747, isolate resources
get the baseloader for resources in isolate mode

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=453032&r1=453031&r2=453032
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Oct  4 14:18:59 2006
@@ -44,10 +44,6 @@
 * Added <tokens> resource collection for convenient creation of string
   resources from other resources' content. Inspired by Bugzilla 40504.
 
-* REVERTED for the moment: AntClassLoader did not isolate
-  resources when isolate was set. Bugzilla report 38747.
-
-
 Changes from Ant 1.7.0Beta1 to Ant 1.7.0Beta2
 =============================================
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java?view=diff&rev=453032&r1=453031&r2=453032
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java Wed Oct  4 14:18:59 2006
@@ -872,6 +872,18 @@
     }
 
     /**
+     * Used for isolated resource seaching.
+     * @return the root classloader of AntClassLoader.
+     */
+    private ClassLoader getRootLoader() {
+        ClassLoader ret = getClass().getClassLoader();
+        while (ret != null && ret.getParent() != null) {
+            ret = ret.getParent();
+        }
+        return ret;
+    }
+
+    /**
      * Finds the resource with the given name. A resource is
      * some data (images, audio, text, etc) that can be accessed by class
      * code in a way that is independent of the location of the code.
@@ -913,9 +925,13 @@
 
         if (url == null && !isParentFirst(name)) {
             // this loader was first but it didn't find it - try the parent
-
-            url = (parent == null) ? super.getResource(name)
-                : parent.getResource(name);
+            if (ignoreBase) {
+                url = (getRootLoader() == null) ? null
+                    : getRootLoader().getResource(name);
+            } else {
+                url = (parent == null) ? super.getResource(name)
+                    : parent.getResource(name);
+            }
             if (url != null) {
                 log("Resource " + name + " loaded from parent loader",
                     Project.MSG_DEBUG);
@@ -953,6 +969,11 @@
         if (isParentFirst(name)) {
             // Normal case.
             return CollectionUtils.append(base, mine);
+        } else if (ignoreBase) {
+            return getRootLoader() == null
+                ? mine
+                : CollectionUtils.append(
+                    mine, getRootLoader().getResources(name));
         } else {
             // Inverted.
             return CollectionUtils.append(mine, base);

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java?view=diff&rev=453032&r1=453031&r2=453032
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java
Wed Oct  4 14:18:59 2006
@@ -78,7 +78,7 @@
             enum2List(acl.getResources(TEST_RESOURCE)));
     }
 
-    public void NottestFindIsolateResources() throws Exception {
+    public void testFindIsolateResources() throws Exception {
         String buildTestcases = System.getProperty("build.tests");
         assertNotNull("defined ${build.tests}", buildTestcases);
         assertTrue("have a dir " + buildTestcases, new File(buildTestcases).isDirectory());



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message