User: rinkrank
  Date: 02/06/13 22:59:05

  Modified:    core/src/xdoclet/loader ModuleFinder.java
  Log:
  Fixed Bug #566782
  
  Revision  Changes    Path
  1.5       +35 -4     xdoclet/core/src/xdoclet/loader/ModuleFinder.java
  
  Index: ModuleFinder.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/loader/ModuleFinder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- ModuleFinder.java 28 May 2002 21:59:00 -0000      1.4
  +++ ModuleFinder.java 14 Jun 2002 05:59:05 -0000      1.5
  @@ -15,6 +15,8 @@
   
   import javax.xml.parsers.DocumentBuilderFactory;
   import org.apache.commons.logging.Log;
  +
  +import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.Project;
   
   import xdoclet.util.LogUtil;
  @@ -24,7 +26,9 @@
    *
    * @author    <a href="mailto:[EMAIL PROTECTED]";>Aslak Helles�y</a>
    * @created   7. april 2002
  - * @version   $Revision: 1.4 $
  + * @todo      Use reflection to call AntClassLoader.getClasspath to remove 
dependency to Ant. This package should be Ant
  + *      independent
  + * @version   $Revision: 1.5 $
    */
   public class ModuleFinder
   {
  @@ -37,8 +41,14 @@
                   return file.getName().endsWith(".jar");
               }
           };
  +    private static String classpath;
       private static List modules = null;
   
  +    public static String getClasspath()
  +    {
  +        return classpath;
  +    }
  +
       /**
        * Get the newest Jar file on the classpath. This method is used to see if a 
generation is needed because one of the
        * xdoclet jars might have changed since the last generation.
  @@ -65,6 +75,29 @@
       }
   
       /**
  +     * Initialises the classpath. If a system property named 
<code>xdoclet.class.path</code>, then that value will be
  +     * used. If not, we'll try to cast the clazz' class loader to an AntClassLoader 
and get classpath from there. If
  +     * that fails (happens if the clazz was loaded by the system class loader), 
we'll use java.class.path.
  +     *
  +     * @param clazz  the class used to find classpath.
  +     */
  +    public static void initClasspath(Class clazz)
  +    {
  +        if (System.getProperty("xdoclet.class.path") == null) {
  +            try {
  +                classpath = ((AntClassLoader) 
clazz.getClassLoader()).getClasspath();
  +            }
  +            catch (ClassCastException e) {
  +                classpath = System.getProperty("java.class.path");
  +            }
  +        }
  +        else {
  +            classpath = System.getProperty("xdoclet.class.path");
  +        }
  +        LogUtil.getLog(ModuleFinder.class, "initClasspath").debug("classpath=" + 
classpath);
  +    }
  +
  +    /**
        * Returns a List of XDocletModule objects
        *
        * @return
  @@ -128,10 +161,8 @@
   
       private static List findModuleFiles()
       {
  -        String classpath = System.getProperty("xdoclet.class.path");
  -
           if (classpath == null) {
  -            throw new IllegalStateException("The xdoclet.class.path System property 
must be defined!");
  +            throw new IllegalStateException("initClasspath must be called first!");
           }
   
           ArrayList result = new ArrayList();
  
  
  

_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - 
http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to