Revision: 19215
          http://sourceforge.net/p/gate/code/19215
Author:   markagreenwood
Date:     2016-04-09 08:29:56 +0000 (Sat, 09 Apr 2016)
Log Message:
-----------
added an implementation of getResources which looks down into child classloaders

Modified Paths:
--------------
    gate/branches/sawdust2/src/main/gate/util/GateClassLoader.java

Modified: gate/branches/sawdust2/src/main/gate/util/GateClassLoader.java
===================================================================
--- gate/branches/sawdust2/src/main/gate/util/GateClassLoader.java      
2016-04-09 06:35:21 UTC (rev 19214)
+++ gate/branches/sawdust2/src/main/gate/util/GateClassLoader.java      
2016-04-09 08:29:56 UTC (rev 19215)
@@ -28,9 +28,13 @@
 import gate.creole.AbstractResource;
 
 import java.beans.Introspector;
+import java.io.IOException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
@@ -136,7 +140,7 @@
 
     return null;
   }
-
+  
   @Override
   public Class<?> loadClass(String name) throws ClassNotFoundException {
     return loadClass(name, false, false, new HashSet<GateClassLoader>());
@@ -386,7 +390,31 @@
       }
     }
   }
+  
+  @Override
+  public Enumeration<URL> getResources(String resource) throws IOException {
+    
+    if (childClassLoaders.isEmpty()) return super.getResources(resource);
+    
+    Set<URL> urls = new LinkedHashSet<URL>();
+    
+    urls.addAll(Collections.list(super.getResources(resource)));
+    
+    
+    Set<GateClassLoader> children;
+    synchronized(childClassLoaders) {
+      children = new 
LinkedHashSet<GateClassLoader>(childClassLoaders.values());
+    }
 
+    for(GateClassLoader cl : children) {
+      if(!cl.isIsolated()) {
+        urls.addAll(Collections.list(cl.getResources(resource)));
+      }
+    }
+    
+    return Collections.enumeration(urls);
+  }
+
   /**
    * Get the child classloaders in creation order. Note that you
    * shouldn't have any need to access the child classloaders. Holding

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial! http://pubads.g.doubleclick.net/
gampad/clk?id=1444514301&iu=/ca-pub-7940484522588532
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to