Login | Register
My pages Projects Community openCollabNet

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

pomstrap
Discussion topic

Back to topic list

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

Reply

Author alag
Full name Alexis Agahi
Date 2006-07-19 02:10:07 PDT
Message Author: alag
Date: 2006-07-19 02:10:07-0700
New Revision: 46

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=46​&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=45&r2=​46
====================​====================​====================​==================
--- 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-07-19 02:10:07-0700
@@ -253,7 +253,7 @@
         Thread.currentThread​().setContextClassLo​ader( classloader );
         
         System.out.println( "Dependency/Classloader tree");
- classloader.printDep​encencyTree();
+ classloader.printDep​encencyTree( System.out );
         
         Class classz = classloader.loadClass( className );
         Constructor ctor = classz.getConstructor( (Class[])null );

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=46​&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=45&​r2=46
====================​====================​====================​==================
--- 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-07-19 02:10:07-0700
@@ -93,27 +93,15 @@
         this.optional = false;
     }
     
+
     
- /*
- * Provides all dependencies JAR URL (if any) of this dependency
+ /**
+ * Get dependency according to groupId:artifactId
      *
- * @return an array of URLs to jar files
+ * @param groupId Maven2 dependency groupId
+ * @param artifactId Maven2 dependency artifactId
      * @throws Exception
- private URL[] getDependencyURLs()
- throws Exception
- {
- List dependencyList = getChildDependencies();
- List urlList = new ArrayList( dependencyList.size() );
- Iterator iter = dependencyList.iterator();
- while( iter.hasNext() )
- {
- Dependency dependency = (Dependency)iter.next();
- urlList.add( dependency.getJarURL() );
- }
- return (URL[])urlList.toArray( new URL[0] );
- }
      */
-
     private Dependency getDependency( String groupId, String artifactId )
     throws Exception
     {
@@ -133,7 +121,9 @@
 
     
     /**
- * Provides all dependencies (if any) of this dependency
+ * Provides all dependencies (if any) of this dependency.
+ * The child list is computed once according to pom file (at first call).
+ * Next call will return the same list instance. This list can then be changed to customize the dependency list.
      * @return a list of dependencies
      * @throws Exception
      */
@@ -347,7 +337,10 @@
     
  
     
-
+ /*
+ * Getter/Setter list
+ */
+
     public String getArtifactId()
     {
         return artifactId;

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=46&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=45&r2=46
====================​====================​====================​==================
--- 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-07-19 02:10:07-0700
@@ -11,6 +11,7 @@
 package com.prefetch.pomstrap;
 
 import java.io.IOException;
+import java.io.PrintStream;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
@@ -39,25 +40,39 @@
 public class DependencyClassloader
     extends URLClassLoader
 {
-
+ // Classloader static cache map
     private static Map classLoaderMap;
     
+ // Child list of classloader linked to this classloader
     private List childClassLoaderList = new ArrayList();
- private Map classMap = new Hashtable();
- private DependencyClassloader parentDependencyClassloader;
+ // Parent classloader
+ private DependencyClassloader parentDependencyClassloader;
+
+ // Map of class associated to this classloader
+ private Map classMap = new Hashtable();
+
+ // POM dependency list assigned to this classloader (most of time if not grouped this list contains only one Dependency)
     private List dependencyList;
     
+
+ // List of String defining dependencies to group toghether when building child classloader written such as: groupId:artifactId
     private List customGroupList;
+ // Auto group dependency in same child classloader if they are from the same groupid.
     private boolean autoGroup;
     
+ /**
+ * Allocate the classloader static cache Map.
+ * This init should be done once in application lifetime, but it can be called to reinitialize application or
+ * unit test.
+ */
     public void init()
     {
         classLoaderMap = new Hashtable();
     }
+
     /**
      * Look for the given classname inside this classloader
      */
-
     protected Class findClass(String name) throws ClassNotFoundException {
         return findClass( name, new ArrayList() );
     }
@@ -156,7 +171,6 @@
      * Constructor
      * @param urls JAR URLs (generally the current dependency dependent jars)
      * @param parent inherited classloader
- * @param dependency the current maven2 dependency
      * @throws Exception
      */
     public DependencyClassloader( URL[] urls, ClassLoader parent )
@@ -178,7 +192,7 @@
     }
   
     /**
- * Build classloader dependency tree
+ * Assign a dependency to the classloader and build corresponding classloader dependency tree
      * @param dependency
      * @throws Exception
      */
@@ -189,6 +203,13 @@
         list.add( dependency );
         assignDependency( list );
     }
+
+ /**
+ * Assign a dependency list to the classloader and build corresponding classloader dependency tree.
+ * This method should be called once per instance.
+ * @param dependencyList list of dependency associated to the classloader
+ * @throws Exception
+ */
     public void assignDependency( List dependencyList )
     throws Exception
     {
@@ -329,56 +350,47 @@
         parentDependencyClassloader = dc;
     }
     
+ /**
+ * Get the child list of dependency
+ * @return list of dependency childs
+ */
     public List getChilds()
     {
         return childClassLoaderList;
     }
-
-/*
- public URL[] getURLs() {
- URL[] urls = super.getURLs();
- return urls;
- }
-*/
 
- /*
- private List urlsAsReadableList()
- {
- URL[] urls = getURLs();
- List list = new ArrayList( urls.length );
- for( int i=0; i<urls.length; i++ )
- {
- //list.add( new File( urls[i].getFile() ).getName() );
- list.add( urls[i].getPath() );
- }
- return list;
- }
- */
+
     
- public void printDepencencyTree()
+ /**
+ * Print the classloader dependency tree
+ * @param outputStream where it will be printed
+ */
+ public void printDepencencyTree( PrintStream outputStream )
     {
- printDepencency( this, 0 );
+ printDepencency( outputStream, this, 0 );
     }
- private void printDepencency( DependencyClassloader dc, int indent )
+ private void printDepencency( PrintStream outputStream, DependencyClassloader dc, int indent )
     {
         if( indent > 0 )
         {
             for( int i=0; i<indent-1; i++ )
             {
- System.out.print( " | " );
+ outputStream.print( " | " );
             }
- System.out.print( " +- " );
+ outputStream.print( " +- " );
         }
- System.out.println( dc );
+ outputStream.println( dc );
             
         for( Iterator iter = dc.getChilds().iterator(); iter.hasNext(); )
         {
- printDepencency( (DependencyClassload​er)iter.next(), indent+1 );
+ printDepencency( outputStream, (DependencyClassload​er)iter.next(), indent+1 );
         }
     }
     
     
-
+ /*
+ * Getter/Setter section
+ */
     
     public void setCustomGroupList(List customGroupList) {
         this.customGroupList = customGroupList;

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

Messages

Show all messages in topic

svn commit: r46 - trunk/pomstrap/src/main/java/com/prefetch/pomstrap alag Alexis Agahi 2006-07-19 02:10:07 PDT
Messages per page: