Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r12 - trunk/pomstrap/src/main/java/com/prefetch/pomstrap

pomstrap
Discussion topic

Back to topic list

svn commit: r12 - trunk/pomstrap/src/main/java/com/prefetch/pomstrap

Reply

Author alag
Full name Alexis Agahi
Date 2006-05-05 10:15:34 PDT
Message Author: alag
Date: 2006-05-05 10:15:34-0700
New Revision: 12

Modified:
   trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Bootstrap​.java
   trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Dependenc​y.java
   trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Dependenc​yClassloader.java

Log:


Modified: trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Bootstrap​.java
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/trunk/poms​trap/src/main/java/c​om/prefetch/pomstrap​/Bootstrap.java?view​=diff&rev=12​&p1=trunk/pomstrap/s​rc/main/java/com/pre​fetch/pomstrap/Boots​trap.java&p2=tru​nk/pomstrap/src/main​/java/com/prefetch/p​omstrap/Bootstrap.ja​va&r1=11&r2=​12
====================​====================​====================​==================
--- trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Bootstrap​.java (original)
+++ trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Bootstrap​.java 2006-05-05 10:15:34-0700
@@ -192,7 +192,7 @@
         {
             classloader = new DependencyClassloader( new URL[]{dependency.getJarURL()}, dependency );
         }
- Thread.currentThread​().setContextClassLo​ader( classloader );
+ Thread.currentThread​().setContextClassLo​ader( classloader );
 
         
         Class classz = classloader.loadClass( className );

Modified: trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Dependenc​y.java
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/trunk/poms​trap/src/main/java/c​om/prefetch/pomstrap​/Dependency.java?vie​w=diff&rev=12​&p1=trunk/pomstrap/​src/main/java/com/pr​efetch/pomstrap/Depe​ndency.java&p2=t​runk/pomstrap/src/ma​in/java/com/prefetch​/pomstrap/Dependency​.java&r1=11&​r2=12
====================​====================​====================​==================
--- trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Dependenc​y.java (original)
+++ trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Dependenc​y.java 2006-05-05 10:15:34-0700
@@ -184,8 +184,8 @@
                 optional = e.getFirstChild().ge​tNodeValue().trim();​
             }
             
- //if( !( "test".equals( scope ) || "true".equals( optional ) ) )
- if( !( "test".equals( scope ) ) )
+ if( !( "test".equals( scope ) || "true".equals( optional ) ) )
+ //if( !( "test".equals( scope ) ) )
             {
                 e = (Element)(findElements( element, "groupId" ).iterator().next());
                 String groupId = e.getFirstChild().ge​tNodeValue().trim();​

Modified: trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Dependenc​yClassloader.java
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/trunk/poms​trap/src/main/java/c​om/prefetch/pomstrap​/DependencyClassload​er.java?view=diff​&rev=12&p1=trun​k/pomstrap/src/main/​java/com/prefetch/po​mstrap/DependencyCla​ssloader.java&p2​=trunk/pomstrap/src/​main/java/com/prefet​ch/pomstrap/Dependen​cyClassloader.java​&r1=11&r2=12
====================​====================​====================​==================
--- trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Dependenc​yClassloader.java (original)
+++ trunk/pomstrap/src/m​ain/java/com/prefetc​h/pomstrap/Dependenc​yClassloader.java 2006-05-05 10:15:34-0700
@@ -15,7 +15,7 @@
 import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Enumeration;
-import java.util.HashMap;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -35,26 +35,32 @@
 public class DependencyClassloader
     extends URLClassLoader
 {
- private static Map m_classLoaderMap = new HashMap();
+ private static Map m_classLoaderMap = new Hashtable();
     private List m_childClassLoaderList = new ArrayList();
- private Map m_classMap = new HashMap();
-
+ private Map m_classMap = new Hashtable();
+ private DependencyClassloader m_parentDependencyClassloader;
+ private Dependency m_dependency;
+
     /**
      * Look for the given classname inside this classloader
      */
- protected Class findClass(String name) throws ClassNotFoundException {
- //System.out.println( ">> findClass for class " + name + " " + m_classMap+" in " + this );
+
+ protected Class findClass(String name) throws ClassNotFoundException {
+ return findClass( name, new ArrayList() );
+ }
+
+ protected Class findClass(String name, List passedToList) throws ClassNotFoundException {
+ //System.out.println( ">> findClass " + name +" in " + this );
+
         Class clasz = (Class)m_classMap.get( name );
- if( clasz != null )
- {
- //System.out.println( "- found" );
+ if( clasz != null ){
             return clasz;
         }
         
         
         try{
             clasz = super.findClass(name);
- m_classMap.put( name, clasz );
+
         }
         catch (Exception e) {
             //System.out.println( "!!> Ex " + e.getMessage() );
@@ -63,14 +69,26 @@
                 DependencyClassloader dc = (DependencyClassload​er)m_childClassLoade​rList.get(i);
                 //System.out.println( ">> Looking for class " + name + " in " + dc );
                 
- clasz = dc.findClass( name );
+ if( !passedToList.contains( dc ) )
+ {
+ passedToList.add( dc );
+ clasz = dc.findClass( name, passedToList );
+ }
                 if( clasz != null )
                 {
                     break;
                 }
             }
+ if( clasz == null ){
+ if( m_parentDependencyClassloader != null ){
+ clasz = m_parentDependencyCl​assloader.findClass(​ name, passedToList );
+ }
+ }
+
         }
-
+ if( clasz != null )
+ m_classMap.put( name, clasz );
+ //System.out.println( ">> return " + clasz +" in " + this );
         return clasz;
     }
     
@@ -152,6 +170,7 @@
     private void postConstructor( Dependency dependency )
     throws Exception
     {
+ m_dependency = dependency;
         List dependenciesList = dependency.getChildD​ependencies();
         //System.out.println( "Dependency List for (" + dependency + "): "+ dependenciesList );
         
@@ -163,6 +182,7 @@
             if( dc == null )
             {
                 dc = new DependencyClassloader( new URL[]{d.getJarURL()}, d);
+ dc.setParentDependen​cyClassloader( this );
                 m_classLoaderMap.put( d, dc );
                 //System.out.println( "put " + d + " " + dc.hashCode() );
             }
@@ -170,7 +190,11 @@
         }
         
     }
-
+
+ protected void setParentDependencyClassloader( DependencyClassloader dc )
+ {
+ m_parentDependencyClassloader = dc;
+ }
 /*
     public URL[] getURLs() {
         URL[] urls = super.getURLs();
@@ -190,10 +214,11 @@
         }
         return list;
     }
-
+ */
     public String toString()
     {
- return "Classloader ("+hashCode()+"): " + m_dependency + "("+urlsAsReadableList() +")";
+ return "Classloader ("+hashCode()+"): " + m_dependency;
     }
- */
+
+
 }

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

Messages

Show all messages in topic

svn commit: r12 - trunk/pomstrap/src/main/java/com/prefetch/pomstrap alag Alexis Agahi 2006-05-05 10:15:34 PDT
Messages per page: