You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2001/12/30 04:33:58 UTC

cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types Mapper.java Path.java

donaldp     01/12/29 19:33:58

  Modified:    proposal/myrmidon/src/java/org/apache/antlib/xml
                        XMLValidateTask.java XSLTProcess.java
               proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs
                        Available.java ExecuteJava.java Property.java
                        Rmic.java SQLExec.java
               proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers
                        DefaultCompilerAdapter.java
               proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/depend
                        Depend.java
               proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb
                        GenericDeploymentTool.java
                        WeblogicDeploymentTool.java
                        WebsphereDeploymentTool.java
               proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit
                        JUnitTask.java JUnitTestRunner.java
                        XMLResultAggregator.java
               proposal/myrmidon/src/main/org/apache/tools/ant/types
                        Mapper.java Path.java
  Removed:     proposal/myrmidon/src/main/org/apache/tools/ant
                        AntClassLoader.java
  Log:
  Removed AntClassLoader and replaced it with URLClassLoader. Now new ClassLoaders do not include the ant runtime by default
  
  Revision  Changes    Path
  1.7       +5 -8      jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java
  
  Index: XMLValidateTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLValidateTask.java	30 Dec 2001 00:26:06 -0000	1.6
  +++ XMLValidateTask.java	30 Dec 2001 03:33:57 -0000	1.7
  @@ -15,13 +15,12 @@
   import java.io.InputStream;
   import java.net.MalformedURLException;
   import java.net.URL;
  +import java.net.URLClassLoader;
   import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.Hashtable;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.DirectoryScanner;
  -import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.types.FileSet;
   import org.apache.tools.ant.types.Path;
  @@ -369,17 +368,15 @@
               // load the parser class
               // with JAXP, we would use a SAXParser factory
               Class readerClass = null;
  -            //Class readerImpl = null;
  -            //Class parserImpl = null;
               if( classpath != null )
               {
  -                AntClassLoader loader = new AntClassLoader( getProject(), classpath );
  -                //                loader.addSystemPackageRoot("org.xml"); // needed to avoid conflict
  -                readerClass = loader.loadClass( readerClassName );
  -                AntClassLoader.initializeClass( readerClass );
  +                final ClassLoader classLoader = new URLClassLoader( classpath.toURLs() );
  +                readerClass = classLoader.loadClass( readerClassName );
               }
               else
  +            {
                   readerClass = Class.forName( readerClassName );
  +            }
   
               // then check it implements XMLReader
               if( XMLReader.class.isAssignableFrom( readerClass ) )
  
  
  
  1.7       +3 -5      jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/xml/XSLTProcess.java
  
  Index: XSLTProcess.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/xml/XSLTProcess.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XSLTProcess.java	30 Dec 2001 00:25:40 -0000	1.6
  +++ XSLTProcess.java	30 Dec 2001 03:33:57 -0000	1.7
  @@ -8,10 +8,10 @@
   package org.apache.antlib.xml;
   
   import java.io.File;
  +import java.net.URLClassLoader;
   import java.util.ArrayList;
   import java.util.Iterator;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.taskdefs.MatchingTask;
   import org.apache.tools.ant.types.Path;
  @@ -378,10 +378,8 @@
           }
           else
           {
  -            AntClassLoader al = new AntClassLoader( getProject(), m_classpath );
  -            Class c = al.loadClass( classname );
  -            AntClassLoader.initializeClass( c );
  -            return c;
  +            final ClassLoader classLoader = new URLClassLoader( m_classpath.toURLs() );
  +            return classLoader.loadClass( classname );
           }
       }
   
  
  
  
  1.12      +71 -93    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java
  
  Index: Available.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Available.java	30 Dec 2001 00:21:51 -0000	1.11
  +++ Available.java	30 Dec 2001 03:33:58 -0000	1.12
  @@ -8,8 +8,9 @@
   package org.apache.tools.ant.taskdefs;
   
   import java.io.File;
  +import java.net.URL;
  +import java.net.URLClassLoader;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.taskdefs.condition.Condition;
   import org.apache.tools.ant.types.EnumeratedAttribute;
  @@ -29,22 +30,22 @@
       extends Task
       implements Condition
   {
  -    private String value = "true";
  -    private String classname;
  -    private Path classpath;
  -    private String file;
  -    private Path filepath;
  -    private AntClassLoader loader;
  -
  -    private String property;
  -    private String resource;
  -    private FileDir type;
  +    private String m_value = "true";
  +    private String m_classname;
  +    private Path m_classpath;
  +    private String m_file;
  +    private Path m_filepath;
  +    private ClassLoader m_classLoader;
  +
  +    private String m_property;
  +    private String m_resource;
  +    private FileDir m_type;
   
       public void setClassname( String classname )
       {
           if( !"".equals( classname ) )
           {
  -            this.classname = classname;
  +            m_classname = classname;
           }
       }
   
  @@ -62,7 +63,7 @@
   
       public void setFile( String file )
       {
  -        this.file = file;
  +        m_file = file;
       }
   
       public void setFilepath( Path filepath )
  @@ -73,102 +74,98 @@
   
       public void setProperty( String property )
       {
  -        this.property = property;
  +        m_property = property;
       }
   
       public void setResource( String resource )
       {
  -        this.resource = resource;
  +        m_resource = resource;
       }
   
       public void setType( FileDir type )
       {
  -        this.type = type;
  +        m_type = type;
       }
   
       public void setValue( String value )
       {
  -        this.value = value;
  +        m_value = value;
       }
   
       public Path createClasspath()
           throws TaskException
       {
  -        if( this.classpath == null )
  +        if( m_classpath == null )
           {
  -            this.classpath = new Path();
  +            m_classpath = new Path();
           }
  -        return this.classpath.createPath();
  +        return m_classpath.createPath();
       }
   
       public Path createFilepath()
           throws TaskException
       {
  -        if( this.filepath == null )
  +        if( m_filepath == null )
           {
  -            this.filepath = new Path();
  +            m_filepath = new Path();
           }
  -        return this.filepath.createPath();
  +        return m_filepath.createPath();
       }
   
       public boolean eval()
           throws TaskException
       {
  -        if( classname == null && file == null && resource == null )
  +        if( m_classname == null && m_file == null && m_resource == null )
           {
               throw new TaskException( "At least one of (classname|file|resource) is required" );
           }
   
  -        if( type != null )
  +        if( m_type != null )
           {
  -            if( file == null )
  +            if( m_file == null )
               {
                   throw new TaskException( "The type attribute is only valid when specifying the file attribute." );
               }
           }
   
  -        if( classpath != null )
  +        if( m_classpath != null )
           {
  -            this.loader = new AntClassLoader( getProject(), classpath );
  +            final URL[] urls = m_classpath.toURLs();
  +            m_classLoader = new URLClassLoader( urls );
           }
   
  -        if( ( classname != null ) && !checkClass( classname ) )
  +        if( ( m_classname != null ) && !checkClass( m_classname ) )
           {
  -            getLogger().debug( "Unable to load class " + classname + " to set property " + property );
  +            getLogger().debug( "Unable to load class " + m_classname + " to set property " + m_property );
               return false;
           }
   
  -        if( ( file != null ) && !checkFile() )
  +        if( ( m_file != null ) && !checkFile() )
           {
  -            if( type != null )
  +            if( m_type != null )
               {
  -                getLogger().debug( "Unable to find " + type + " " + file + " to set property " + property );
  +                getLogger().debug( "Unable to find " + m_type + " " + m_file + " to set property " + m_property );
               }
               else
               {
  -                getLogger().debug( "Unable to find " + file + " to set property " + property );
  +                getLogger().debug( "Unable to find " + m_file + " to set property " + m_property );
               }
               return false;
           }
   
  -        if( ( resource != null ) && !checkResource( resource ) )
  +        if( ( m_resource != null ) && !checkResource( m_resource ) )
           {
  -            getLogger().debug( "Unable to load resource " + resource + " to set property " + property );
  +            getLogger().debug( "Unable to load resource " + m_resource + " to set property " + m_property );
               return false;
           }
   
  -        if( loader != null )
  -        {
  -            loader.cleanup();
  -        }
  -
           return true;
       }
   
       public void execute()
           throws TaskException
       {
  -        if( property == null )
  +        if( m_property == null )
           {
               throw new TaskException( "property attribute is required" );
           }
  @@ -176,9 +173,9 @@
           if( eval() )
           {
               String lSep = System.getProperty( "line.separator" );
  -            if( null == getProject().getProperty( property ) )
  +            if( null == getProject().getProperty( m_property ) )
               {
  -                setProperty( property, value );
  +                setProperty( m_property, m_value );
               }
               //else ignore
           }
  @@ -188,24 +185,8 @@
       {
           try
           {
  -            if( loader != null )
  -            {
  -                loader.loadClass( classname );
  -            }
  -            else
  -            {
  -                ClassLoader l = this.getClass().getClassLoader();
  -                // Can return null to represent the bootstrap class loader.
  -                // see API docs of Class.getClassLoader.
  -                if( l != null )
  -                {
  -                    l.loadClass( classname );
  -                }
  -                else
  -                {
  -                    Class.forName( classname );
  -                }
  -            }
  +            final ClassLoader classLoader = getClassLoader();
  +            classLoader.loadClass( classname );
               return true;
           }
           catch( ClassNotFoundException e )
  @@ -221,13 +202,13 @@
       private boolean checkFile()
           throws TaskException
       {
  -        if( filepath == null )
  +        if( m_filepath == null )
           {
  -            return checkFile( resolveFile( file ), file );
  +            return checkFile( resolveFile( m_file ), m_file );
           }
           else
           {
  -            String[] paths = filepath.list();
  +            String[] paths = m_filepath.list();
               for( int i = 0; i < paths.length; ++i )
               {
                   getLogger().debug( "Searching " + paths[ i ] );
  @@ -248,20 +229,20 @@
   
                   // **   full-pathname specified == path in list
                   // **   simple name specified   == path in list
  -                if( path.exists() && file.equals( paths[ i ] ) )
  +                if( path.exists() && m_file.equals( paths[ i ] ) )
                   {
  -                    if( type == null )
  +                    if( m_type == null )
                       {
                           getLogger().debug( "Found: " + path );
                           return true;
                       }
  -                    else if( type.isDir()
  +                    else if( m_type.isDir()
                           && path.isDirectory() )
                       {
                           getLogger().debug( "Found directory: " + path );
                           return true;
                       }
  -                    else if( type.isFile()
  +                    else if( m_type.isFile()
                           && path.isFile() )
                       {
                           getLogger().debug( "Found file: " + path );
  @@ -274,14 +255,14 @@
                   File parent = path.getParentFile();
                   // **   full-pathname specified == parent dir of path in list
                   if( parent != null && parent.exists()
  -                    && file.equals( parent.getAbsolutePath() ) )
  +                    && m_file.equals( parent.getAbsolutePath() ) )
                   {
  -                    if( type == null )
  +                    if( m_type == null )
                       {
                           getLogger().debug( "Found: " + parent );
                           return true;
                       }
  -                    else if( type.isDir() )
  +                    else if( m_type.isDir() )
                       {
                           getLogger().debug( "Found directory: " + parent );
                           return true;
  @@ -293,8 +274,8 @@
                   // **   simple name specified   == path in list + name
                   if( path.exists() && path.isDirectory() )
                   {
  -                    if( checkFile( new File( path, file ),
  -                                   file + " in " + path ) )
  +                    if( checkFile( new File( path, m_file ),
  +                                   m_file + " in " + path ) )
                       {
                           return true;
                       }
  @@ -303,8 +284,8 @@
                   // **   simple name specified   == parent dir + name
                   if( parent != null && parent.exists() )
                   {
  -                    if( checkFile( new File( parent, file ),
  -                                   file + " in " + parent ) )
  +                    if( checkFile( new File( parent, m_file ),
  +                                   m_file + " in " + parent ) )
                       {
                           return true;
                       }
  @@ -316,8 +297,8 @@
                       File grandParent = parent.getParentFile();
                       if( grandParent != null && grandParent.exists() )
                       {
  -                        if( checkFile( new File( grandParent, file ),
  -                                       file + " in " + grandParent ) )
  +                        if( checkFile( new File( grandParent, m_file ),
  +                                       m_file + " in " + grandParent ) )
                           {
                               return true;
                           }
  @@ -330,9 +311,9 @@
   
       private boolean checkFile( File f, String text )
       {
  -        if( type != null )
  +        if( m_type != null )
           {
  -            if( type.isDir() )
  +            if( m_type.isDir() )
               {
                   if( f.isDirectory() )
                   {
  @@ -340,7 +321,7 @@
                   }
                   return f.isDirectory();
               }
  -            else if( type.isFile() )
  +            else if( m_type.isFile() )
               {
                   if( f.isFile() )
                   {
  @@ -358,22 +339,19 @@
   
       private boolean checkResource( String resource )
       {
  -        if( loader != null )
  +        final ClassLoader classLoader = getClassLoader();
  +        return ( null != classLoader.getResourceAsStream( resource ) );
  +    }
  +
  +    private ClassLoader getClassLoader()
  +    {
  +        if( null == m_classLoader )
           {
  -            return ( loader.getResourceAsStream( resource ) != null );
  +            return ClassLoader.getSystemClassLoader();
           }
           else
           {
  -            ClassLoader cL = this.getClass().getClassLoader();
  -            if( cL != null )
  -            {
  -                return ( cL.getResourceAsStream( resource ) != null );
  -            }
  -            else
  -            {
  -                return
  -                    ( ClassLoader.getSystemResourceAsStream( resource ) != null );
  -            }
  +            return m_classLoader;
           }
       }
   
  
  
  
  1.6       +21 -30    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  
  Index: ExecuteJava.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ExecuteJava.java	30 Dec 2001 01:26:55 -0000	1.5
  +++ ExecuteJava.java	30 Dec 2001 03:33:58 -0000	1.6
  @@ -9,8 +9,9 @@
   
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
  +import java.net.URL;
  +import java.net.URLClassLoader;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.types.Commandline;
   import org.apache.tools.ant.types.CommandlineJava;
  @@ -20,56 +21,51 @@
    * @author thomas.haas@softwired-inc.com
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    */
  -
   public class ExecuteJava
   {
  +    private Commandline m_javaCommand;
  +    private Path m_classpath;
  +    private CommandlineJava.SysProperties m_sysProperties;
   
  -    private Commandline javaCommand = null;
  -    private Path classpath = null;
  -    private CommandlineJava.SysProperties sysProperties = null;
  -
  -    public void setClasspath( Path p )
  +    public void setClasspath( final Path classpath )
       {
  -        classpath = p;
  +        m_classpath = classpath;
       }
   
  -    public void setJavaCommand( Commandline javaCommand )
  +    public void setJavaCommand( final Commandline javaCommand )
       {
  -        this.javaCommand = javaCommand;
  +        m_javaCommand = javaCommand;
       }
   
  -    public void setSystemProperties( CommandlineJava.SysProperties s )
  +    public void setSystemProperties( final CommandlineJava.SysProperties sysProperties )
       {
  -        sysProperties = s;
  +        m_sysProperties = sysProperties;
       }
   
       public void execute( Project project )
           throws TaskException
       {
  -        final String classname = javaCommand.getExecutable();
  -        final Object[] argument = {javaCommand.getArguments()};
  +        final String classname = m_javaCommand.getExecutable();
  +        final Object[] argument = {m_javaCommand.getArguments()};
   
  -        AntClassLoader loader = null;
           try
           {
  -            if( sysProperties != null )
  +            if( m_sysProperties != null )
               {
  -                sysProperties.setSystem();
  +                m_sysProperties.setSystem();
               }
   
               final Class[] param = {Class.forName( "[Ljava.lang.String;" )};
               Class target = null;
  -            if( classpath == null )
  +            if( m_classpath == null )
               {
                   target = Class.forName( classname );
               }
               else
               {
  -                loader = new AntClassLoader( Project.class.getClassLoader(), project, classpath, false );
  -                loader.setIsolated( true );
  -                loader.setThreadContextLoader();
  -                target = loader.forceLoadClass( classname );
  -                AntClassLoader.initializeClass( target );
  +                final URL[] urls = m_classpath.toURLs();
  +                final URLClassLoader classLoader = new URLClassLoader( urls );
  +                target = classLoader.loadClass( classname );
               }
               final Method main = target.getMethod( "main", param );
               main.invoke( null, argument );
  @@ -100,14 +96,9 @@
           }
           finally
           {
  -            if( loader != null )
  -            {
  -                loader.resetThreadContextLoader();
  -                loader.cleanup();
  -            }
  -            if( sysProperties != null )
  +            if( m_sysProperties != null )
               {
  -                sysProperties.restoreSystem();
  +                m_sysProperties.restoreSystem();
               }
           }
       }
  
  
  
  1.20      +7 -15     jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java
  
  Index: Property.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Property.java	30 Dec 2001 00:46:53 -0000	1.19
  +++ Property.java	30 Dec 2001 03:33:58 -0000	1.20
  @@ -11,13 +11,13 @@
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.InputStream;
  -import java.util.Enumeration;
  +import java.net.URL;
  +import java.net.URLClassLoader;
   import java.util.Iterator;
   import java.util.Properties;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.framework.exec.Environment;
   import org.apache.myrmidon.framework.exec.ExecException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.Reference;
  @@ -269,26 +269,18 @@
           getLogger().debug( "Resource Loading " + name );
           try
           {
  -            ClassLoader cL = null;
  -            InputStream is = null;
  +            ClassLoader classLoader = null;
   
               if( m_classpath != null )
               {
  -                cL = new AntClassLoader( getProject(), m_classpath );
  +                final URL[] urls = m_classpath.toURLs();
  +                classLoader = new URLClassLoader( urls );
               }
               else
               {
  -                cL = getClass().getClassLoader();
  -            }
  -
  -            if( cL == null )
  -            {
  -                is = ClassLoader.getSystemResourceAsStream( name );
  -            }
  -            else
  -            {
  -                is = cL.getResourceAsStream( name );
  +                classLoader = ClassLoader.getSystemClassLoader();
               }
  +            final InputStream is = classLoader.getResourceAsStream( name );
   
               if( is != null )
               {
  
  
  
  1.17      +2 -2      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java
  
  Index: Rmic.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Rmic.java	30 Dec 2001 00:12:54 -0000	1.16
  +++ Rmic.java	30 Dec 2001 03:33:58 -0000	1.17
  @@ -9,11 +9,11 @@
   
   import java.io.File;
   import java.io.IOException;
  +import java.net.URLClassLoader;
   import java.rmi.Remote;
   import java.util.ArrayList;
   import org.apache.avalon.excalibur.io.FileUtil;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.taskdefs.rmic.RmicAdapter;
   import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory;
  @@ -525,7 +525,7 @@
           adapter.setRmic( this );
   
           Path classpath = adapter.getClasspath();
  -        loader = new AntClassLoader( getProject(), classpath );
  +        loader = new URLClassLoader( classpath.toURLs() );
   
           // scan base dirs to build up compile lists only if a
           // specific classname is not given
  
  
  
  1.14      +18 -20    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  
  Index: SQLExec.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SQLExec.java	30 Dec 2001 00:38:44 -0000	1.13
  +++ SQLExec.java	30 Dec 2001 03:33:58 -0000	1.14
  @@ -18,6 +18,7 @@
   import java.io.PrintStream;
   import java.io.Reader;
   import java.io.StringReader;
  +import java.net.URLClassLoader;
   import java.sql.Connection;
   import java.sql.DatabaseMetaData;
   import java.sql.Driver;
  @@ -31,7 +32,6 @@
   import java.util.Properties;
   import java.util.StringTokenizer;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.types.EnumeratedAttribute;
  @@ -47,9 +47,9 @@
    * @author <A href="mailto:gholam@xtra.co.nz">Michael McCallum</A>
    * @author <A href="mailto:tim.stephenson@sybase.com">Tim Stephenson</A>
    */
  -public class SQLExec extends Task
  +public class SQLExec
  +    extends Task
   {
  -
       private int goodSql = 0, totalSql = 0;
   
       private ArrayList filesets = new ArrayList();
  @@ -57,42 +57,42 @@
       /**
        * Database connection
        */
  -    private Connection conn = null;
  +    private Connection conn;
   
       /**
        * Autocommit flag. Default value is false
        */
  -    private boolean autocommit = false;
  +    private boolean autocommit;
   
       /**
        * SQL statement
        */
  -    private Statement statement = null;
  +    private Statement statement;
   
       /**
        * DB driver.
        */
  -    private String driver = null;
  +    private String driver;
   
       /**
        * DB url.
        */
  -    private String url = null;
  +    private String url;
   
       /**
        * User name.
        */
  -    private String userId = null;
  +    private String userId;
   
       /**
        * Password
        */
  -    private String password = null;
  +    private String password;
   
       /**
        * SQL input file
        */
  -    private File srcFile = null;
  +    private File srcFile;
   
       /**
        * SQL input command
  @@ -118,7 +118,7 @@
       /**
        * Print SQL results.
        */
  -    private boolean print = false;
  +    private boolean print;
   
       /**
        * Print header columns.
  @@ -128,17 +128,17 @@
       /**
        * Results Output file.
        */
  -    private File output = null;
  +    private File output;
   
       /**
        * RDBMS Product needed for this SQL.
        */
  -    private String rdbms = null;
  +    private String rdbms;
   
       /**
        * RDBMS Version needed for this SQL.
        */
  -    private String version = null;
  +    private String version;
   
       /**
        * Action to perform if an error is found
  @@ -148,12 +148,10 @@
       /**
        * Encoding to use when reading SQL statements from a file
        */
  -    private String encoding = null;
  +    private String encoding;
   
       private Path classpath;
   
  -    private AntClassLoader loader;
  -
       /**
        * Set the autocommit flag for the DB connection.
        *
  @@ -457,8 +455,8 @@
               {
                   getLogger().debug( "Loading " + driver + " using AntClassLoader with classpath " + classpath );
   
  -                loader = new AntClassLoader( getProject(), classpath );
  -                dc = loader.loadClass( driver );
  +                final ClassLoader classLoader = new URLClassLoader( classpath.toURLs() );
  +                dc = classLoader.loadClass( driver );
               }
               else
               {
  
  
  
  1.17      +1 -2      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  
  Index: DefaultCompilerAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DefaultCompilerAdapter.java	30 Dec 2001 01:14:59 -0000	1.16
  +++ DefaultCompilerAdapter.java	30 Dec 2001 03:33:58 -0000	1.17
  @@ -401,8 +401,7 @@
               }
               catch( IOException e )
               {
  -                throw new TaskException( "Error running " + args[ 0 ]
  -                                         + " compiler", e );
  +                throw new TaskException( "Error running " + args[ 0 ] + " compiler", e );
               }
           }
           finally
  
  
  
  1.11      +4 -3      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  
  Index: Depend.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Depend.java	30 Dec 2001 00:21:51 -0000	1.10
  +++ Depend.java	30 Dec 2001 03:33:58 -0000	1.11
  @@ -15,12 +15,12 @@
   import java.io.IOException;
   import java.io.PrintWriter;
   import java.net.URL;
  +import java.net.URLClassLoader;
   import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.Hashtable;
   import java.util.Iterator;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.taskdefs.MatchingTask;
   import org.apache.tools.ant.types.Path;
  @@ -579,7 +579,7 @@
           {
               // now determine which jars each class depends upon
               classpathDependencies = new Hashtable();
  -            AntClassLoader loader = new AntClassLoader( getProject(), dependClasspath );
  +            final ClassLoader classLoader = new URLClassLoader( dependClasspath.toURLs() );
   
               Hashtable classpathFileCache = new Hashtable();
               Object nullFileMarker = new Object();
  @@ -599,7 +599,8 @@
   
                           if( !dependency.startsWith( "java." ) && !dependency.startsWith( "javax." ) )
                           {
  -                            URL classURL = loader.getResource( dependency.replace( '.', '/' ) + ".class" );
  +                            final String name = dependency.replace( '.', '/' ) + ".class";
  +                            URL classURL = classLoader.getResource( name );
                               if( classURL != null )
                               {
                                   if( classURL.getProtocol().equals( "jar" ) )
  
  
  
  1.11      +2 -2      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
  
  Index: GenericDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- GenericDeploymentTool.java	30 Dec 2001 00:21:52 -0000	1.10
  +++ GenericDeploymentTool.java	30 Dec 2001 03:33:58 -0000	1.11
  @@ -12,6 +12,7 @@
   import java.io.FileOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.net.URLClassLoader;
   import java.util.ArrayList;
   import java.util.HashSet;
   import java.util.Hashtable;
  @@ -27,7 +28,6 @@
   import org.apache.bcel.*;
   import org.apache.bcel.classfile.*;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
  @@ -329,7 +329,7 @@
           }
           else
           {
  -            classpathLoader = new AntClassLoader( getTask().getProject(), combinedClasspath );
  +            classpathLoader = new URLClassLoader( combinedClasspath.toURLs() );
           }
   
           return classpathLoader;
  
  
  
  1.12      +2 -2      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
  
  Index: WeblogicDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- WeblogicDeploymentTool.java	30 Dec 2001 00:21:52 -0000	1.11
  +++ WeblogicDeploymentTool.java	30 Dec 2001 03:33:58 -0000	1.12
  @@ -12,6 +12,7 @@
   import java.io.FileOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.net.URLClassLoader;
   import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.jar.JarEntry;
  @@ -21,7 +22,6 @@
   import javax.xml.parsers.SAXParserFactory;
   import org.apache.avalon.excalibur.io.FileUtil;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.taskdefs.Java;
   import org.apache.tools.ant.types.Path;
   import org.xml.sax.InputSource;
  @@ -332,7 +332,7 @@
               lookupPath.append( classpath );
           }
   
  -        return new AntClassLoader( getTask().getProject(), lookupPath );
  +        return new URLClassLoader( lookupPath.toURLs() );
       }
   
       protected DescriptorHandler getWeblogicDescriptorHandler( final File srcDir )
  
  
  
  1.12      +2 -2      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
  
  Index: WebsphereDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- WebsphereDeploymentTool.java	30 Dec 2001 00:21:52 -0000	1.11
  +++ WebsphereDeploymentTool.java	30 Dec 2001 03:33:58 -0000	1.12
  @@ -11,13 +11,13 @@
   import java.io.FileOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.net.URLClassLoader;
   import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.jar.JarEntry;
   import java.util.jar.JarFile;
   import java.util.jar.JarOutputStream;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.taskdefs.Java;
   import org.apache.tools.ant.types.Argument;
   import org.apache.tools.ant.types.EnumeratedAttribute;
  @@ -410,7 +410,7 @@
           {
               lookupPath.append( classpath );
           }
  -        return new AntClassLoader( getTask().getProject(), lookupPath );
  +        return new URLClassLoader( lookupPath.toURLs() );
       }
   
       protected DescriptorHandler getDescriptorHandler( File srcDir )
  
  
  
  1.20      +8 -9      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  
  Index: JUnitTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- JUnitTask.java	30 Dec 2001 01:14:59 -0000	1.19
  +++ JUnitTask.java	30 Dec 2001 03:33:58 -0000	1.20
  @@ -12,6 +12,7 @@
   import java.io.IOException;
   import java.io.OutputStream;
   import java.net.URL;
  +import java.net.URLClassLoader;
   import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.Hashtable;
  @@ -19,7 +20,6 @@
   import java.util.Properties;
   import java.util.Random;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.taskdefs.exec.Execute;
   import org.apache.tools.ant.taskdefs.exec.LogOutputStream;
  @@ -694,19 +694,18 @@
           try
           {
               getLogger().debug( "Using System properties " + System.getProperties() );
  -            AntClassLoader cl = null;
  +            ClassLoader classLoader = null;
               Path classpath = commandline.getClasspath();
               if( classpath != null )
               {
                   getLogger().debug( "Using CLASSPATH " + classpath );
  -
  -                cl = new AntClassLoader( null, getProject(), classpath, false );
  -                // make sure the test will be accepted as a TestCase
  -                cl.addSystemPackageRoot( "junit" );
  -                // will cause trouble in JDK 1.1 if omitted
  -                cl.addSystemPackageRoot( "org.apache.tools.ant" );
  +                classLoader = new URLClassLoader( classpath.toURLs() );
               }
  -            runner = new JUnitTestRunner( test, test.getHaltonerror(), test.getFiltertrace(), test.getHaltonfailure(), cl );
  +            runner = new JUnitTestRunner( test,
  +                                          test.getHaltonerror(),
  +                                          test.getFiltertrace(),
  +                                          test.getHaltonfailure(),
  +                                          classLoader );
               if( summary )
               {
                   getLogger().info( "Running " + test.getName() );
  
  
  
  1.8       +0 -4      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  
  Index: JUnitTestRunner.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JUnitTestRunner.java	30 Dec 2001 01:17:48 -0000	1.7
  +++ JUnitTestRunner.java	30 Dec 2001 03:33:58 -0000	1.8
  @@ -28,9 +28,6 @@
   import junit.framework.TestSuite;
   import org.apache.avalon.framework.ExceptionUtil;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
  -import org.apache.tools.ant.Project;
  -import org.apache.tools.ant.util.StringUtils;
   
   /**
    * Simple Testrunner for JUnit that runs all tests of a testsuite. <p>
  @@ -179,7 +176,6 @@
               else
               {
                   testClass = loader.loadClass( test.getName() );
  -                AntClassLoader.initializeClass( testClass );
               }
   
               Method suiteMethod = null;
  
  
  
  1.11      +3 -7      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
  
  Index: XMLResultAggregator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XMLResultAggregator.java	23 Dec 2001 14:22:46 -0000	1.10
  +++ XMLResultAggregator.java	30 Dec 2001 03:33:58 -0000	1.11
  @@ -24,7 +24,6 @@
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.types.FileSet;
   import org.apache.tools.ant.util.DOMElementWriter;
  -import org.apache.tools.ant.util.StringUtils;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   import org.xml.sax.SAXException;
  @@ -184,7 +183,7 @@
           }
           if( toDir == null )
           {
  -            toDir = FileUtil.resolveFile( getProject().getBaseDir(), DEFAULT_DIR );
  +            toDir = FileUtil.resolveFile( getBaseDirectory(), DEFAULT_DIR );
           }
           return new File( toDir, toFile );
       }
  @@ -210,16 +209,13 @@
                   if( pathname.endsWith( ".xml" ) )
                   {
                       File file = new File( ds.getBasedir(), pathname );
  -                    file = FileUtil.
  -                        resolveFile( getProject().getBaseDir(), file.getPath() );
  +                    file = FileUtil.resolveFile( getBaseDirectory(), file.getPath() );
                       v.add( file );
                   }
               }
           }
   
  -        File[] files = new File[ v.size() ];
  -        v.copyInto( files );
  -        return files;
  +        return (File[])v.toArray( new File[ v.size() ] );
       }
   
       /**
  
  
  
  1.7       +5 -6      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Mapper.java
  
  Index: Mapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Mapper.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Mapper.java	30 Dec 2001 00:17:35 -0000	1.6
  +++ Mapper.java	30 Dec 2001 03:33:58 -0000	1.7
  @@ -7,10 +7,10 @@
    */
   package org.apache.tools.ant.types;
   
  -import java.util.Properties;
  +import java.net.URL;
  +import java.net.URLClassLoader;
   import java.util.Stack;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.util.FileNameMapper;
   
   /**
  @@ -182,10 +182,9 @@
               }
               else
               {
  -                AntClassLoader al = new AntClassLoader( getProject(),
  -                                                        m_classpath );
  -                c = al.loadClass( m_classname );
  -                AntClassLoader.initializeClass( c );
  +                final URL[] urls = m_classpath.toURLs();
  +                final URLClassLoader classLoader = new URLClassLoader( urls );
  +                c = classLoader.loadClass( m_classname );
               }
   
               FileNameMapper m = (FileNameMapper)c.newInstance();
  
  
  
  1.11      +29 -1     jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java
  
  Index: Path.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Path.java	30 Dec 2001 01:14:59 -0000	1.10
  +++ Path.java	30 Dec 2001 03:33:58 -0000	1.11
  @@ -8,6 +8,8 @@
   package org.apache.tools.ant.types;
   
   import java.io.File;
  +import java.io.IOException;
  +import java.net.URL;
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.Locale;
  @@ -645,6 +647,33 @@
       }
   
       /**
  +     * Returns an array of URLs - useful for building a ClassLoader.
  +     */
  +    public URL[] toURLs()
  +        throws TaskException
  +    {
  +        try
  +        {
  +            final String[] list = list();
  +
  +            final URL[] result = new URL[ list.length ];
  +
  +            // path containing one or more elements
  +            for( int i = 0; i < list.length; i++ )
  +            {
  +                result[ i ] = new File( list[ i ] ).toURL();
  +            }
  +
  +            return result;
  +        }
  +        catch( final IOException ioe )
  +        {
  +            final String message = "Malformed path entry. Reason:" + ioe;
  +            throw new TaskException( message, ioe );
  +        }
  +    }
  +
  +    /**
        * Overrides the version of DataType to recurse on all DataType child
        * elements that may have been added.
        *
  @@ -655,7 +684,6 @@
       protected void dieOnCircularReference( Stack stk, Project p )
           throws TaskException
       {
  -
           if( checked )
           {
               return;
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>