Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r177 - branches/2.X/org.tigris.pomstrap.core/src/main/java/org/tigris/pomstrap/core/DependencyClassloader.java

pomstrap
Discussion topic

Back to topic list

svn commit: r177 - branches/2.X/org.tigris.pomstrap.core/src/main/java/org/tigris/pomstrap/core/DependencyClassloader.java

Reply

Author evangelista
Full name Alessandro Evangelista
Date 2009-02-26 05:42:40 PST
Message Author: evangelista
Date: 2009-02-26 05:42:40-0800
New Revision: 177

Modified:
   branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endencyClassloader.j​ava

Log:
Fixed multiple resources lookup across multiple class-loaders.

Modified: branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endencyClassloader.j​ava
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/branches/2​.X/org.tigris.pomstr​ap.core/src/main/jav​a/org/tigris/pomstra​p/core/DependencyCla​ssloader.java?view=d​iff&pathrev=177​&r1=176&r2=17​7
====================​====================​====================​==================
--- branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endencyClassloader.j​ava (original)
+++ branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endencyClassloader.j​ava 2009-02-26 05:42:40-0800
@@ -25,6 +25,7 @@
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
+import java.util.Vector;
 
 import org.tigris.pomstrap.​core.Dependency;
 
@@ -66,9 +67,7 @@
     {
         Class clasz = (Class) classMap.get( name );
         if ( clasz != null )
- {
             return clasz;
- }
 
         clasz = doLoadClass( name );
 
@@ -282,37 +281,32 @@
     public Enumeration<URL> getResources( String name )
         throws IOException
     {
- return getResources( name, new ArrayList<Depende​ncyClassloader>()​ );
+ Vector<URL> resources = new Vector<URL>();
+ lookupResources( resources, name, new ArrayList<Depende​ncyClassloader>()​ );
+ return resources.elements();
     }
 
- public Enumeration<URL> getResources( String name, List<DependencyCl​assloader> passedToList )
+ protected void lookupResources( Vector<URL> resources, String name, List<DependencyCl​assloader> passedToList )
         throws IOException
     {
- Enumeration<URL> enumeration = super.getResources( name );
- if ( enumeration == null || !enumeration.hasMoreElements() )
+ Enumeration<URL> e = super.getResources( name );
+ while ( e.hasMoreElements() )
+ resources.add( e.nextElement() );
+
+ // TODO should we exclude different versions of already queried jars?
+ for ( DependencyClassloader dc : childClassLoaderList )
         {
- for ( int i = 0; i < childClassLoaderList.size(); i++ )
+ if ( !passedToList.contains( dc ) )
             {
- DependencyClassloader dc = (DependencyClassloader) childClassLoaderList.get( i );
- if ( !passedToList.contains( dc ) )
- {
- passedToList.add( dc );
- enumeration = dc.getResources( name, passedToList );
- }
- if ( enumeration != null && enumeration.hasMoreElements() )
- {
- break;
- }
- if ( enumeration == null )
- {
- if ( getParentDependencyC​lassloader() != null )
- {
- enumeration = getParentDependencyC​lassloader().getReso​urces( name, passedToList );
- }
- }
+ passedToList.add( dc );
+ dc.lookupResources( resources, name, passedToList );
             }
         }
- return enumeration;
+
+ if ( getParentDependencyC​lassloader() != null )
+ {
+ getParentDependencyC​lassloader().lookupR​esources( resources, name, passedToList );
+ }
     }
 
     static List<Dependency> toDependencyList( Dependency dependency )

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r177 - branches/2.X/org.tigris.pomstrap.core/src/main/java/org/tigris/pomstrap/core/DependencyClassloader.java evangelista Alessandro Evangelista 2009-02-26 05:42:40 PST
Messages per page: