ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/launcher Main.java
Date Mon, 18 Feb 2002 09:08:08 GMT
donaldp     02/02/18 01:08:08

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/launcher
                        Main.java
  Log:
  Start simplifying so that metrics task does not complain as much
  
  Revision  Changes    Path
  1.14      +38 -17    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/launcher/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/launcher/Main.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Main.java	7 Feb 2002 13:01:31 -0000	1.13
  +++ Main.java	18 Feb 2002 09:08:08 -0000	1.14
  @@ -19,7 +19,7 @@
    * Basic Loader that is responsible for all the hackery to get classloader to work.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.13 $ $Date: 2002/02/07 13:01:31 $
  + * @version $Revision: 1.14 $ $Date: 2002/02/18 09:08:08 $
    */
   public final class Main
   {
  @@ -39,24 +39,11 @@
               final File installDirectory = findInstallDir();
               System.setProperty( "myrmidon.home", installDirectory.toString() );
   
  -            //setup classloader appropriately for myrmidon jar
  -            final File libDir = new File( installDirectory, "lib" );
  -            final URL[] libUrls = buildURLList( libDir );
  -            final URLClassLoader libClassLoader = new URLClassLoader( libUrls );
  -
  -            final File containerLibDir = new File( installDirectory, "bin" + File.separator
+ "lib" );
  -            final URL[] containerLibUrls = buildURLList( containerLibDir );
  +            final URLClassLoader sharedClassLoader = createSharedClassLoader( installDirectory
);
               final URLClassLoader classLoader =
  -                new URLClassLoader( containerLibUrls, libClassLoader );
  -
  -            //load class and retrieve appropriate main method.
  -            final Class clazz = classLoader.loadClass( "org.apache.myrmidon.frontends.CLIMain"
);
  -            final Method method = clazz.getMethod( "main", new Class[]{args.getClass()}
);
  +                createContainerClassLoader( installDirectory, sharedClassLoader );
   
  -            Thread.currentThread().setContextClassLoader( classLoader );
  -
  -            //kick the tires and light the fires....
  -            method.invoke( null, new Object[]{args} );
  +            execMainClass( classLoader, args );
           }
           catch( final InvocationTargetException ite )
           {
  @@ -68,6 +55,40 @@
               System.err.println( "Error: " + throwable.getMessage() );
               throwable.printStackTrace();
           }
  +    }
  +
  +    private static void execMainClass( final URLClassLoader classLoader, final String[]
args )
  +        throws Exception
  +    {
  +        //load class and retrieve appropriate main method.
  +        final Class clazz = classLoader.loadClass( "org.apache.myrmidon.frontends.CLIMain"
);
  +        final Method method = clazz.getMethod( "main", new Class[]{args.getClass()} );
  +
  +        Thread.currentThread().setContextClassLoader( classLoader );
  +
  +        //kick the tires and light the fires....
  +        method.invoke( null, new Object[]{args} );
  +    }
  +
  +    private static URLClassLoader createContainerClassLoader( final File installDirectory,
  +                                                              final URLClassLoader sharedClassLoader
)
  +        throws Exception
  +    {
  +        final File containerLibDir = new File( installDirectory, "bin" + File.separator
+ "lib" );
  +        final URL[] containerLibUrls = buildURLList( containerLibDir );
  +        final URLClassLoader classLoader =
  +            new URLClassLoader( containerLibUrls, sharedClassLoader );
  +        return classLoader;
  +    }
  +
  +    private static URLClassLoader createSharedClassLoader( final File installDirectory
)
  +        throws Exception
  +    {
  +        //setup classloader appropriately for myrmidon jar
  +        final File libDir = new File( installDirectory, "lib" );
  +        final URL[] libUrls = buildURLList( libDir );
  +        final URLClassLoader libClassLoader = new URLClassLoader( libUrls );
  +        return libClassLoader;
       }
   
       private static final URL[] buildURLList( final File dir )
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message