From cc0bf7e707542ff4c331cb0988c585459e9a2a6e Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Tue, 6 Nov 2001 08:10:00 +0000 Subject: [PATCH] Separated myrmidon out into several jars. myrmidon-container.jar (all the container classes) myrmidon-api.jar (the API used to write tasks and other types) myrmidon-framework.jar (the framework that makes writing tasks easier) myrmidon-launcher.jar (executable jar used to setup classloaders and run myrmidon) The ClassLoader hierarchy is now System CL <--- api/framework CL <--- container <--- type library 1 <--- type library 2 <--- type library 3 <--- type library 1 <--- type library 1 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269874 13f79535-47bb-0310-9956-ffa450edef68 --- proposal/myrmidon/build.xml | 46 +++++++++++-- .../org/apache/myrmidon/launcher/Main.java | 66 ++++++++++++++++++- proposal/myrmidon/src/make/sample.ant | 2 + .../src/manifest/builtin-ant-roles.xml | 2 +- .../myrmidon/src/manifest/myrmidon-api.mf | 9 +++ .../src/manifest/myrmidon-container.mf | 19 ++++++ .../src/manifest/myrmidon-framework.mf | 15 +++++ .../{ant-manifest.mf => myrmidon-launcher.mf} | 0 proposal/myrmidon/src/script/ant | 2 +- proposal/myrmidon/src/script/ant.bat | 2 +- 10 files changed, 150 insertions(+), 13 deletions(-) create mode 100644 proposal/myrmidon/src/manifest/myrmidon-api.mf create mode 100644 proposal/myrmidon/src/manifest/myrmidon-container.mf create mode 100644 proposal/myrmidon/src/manifest/myrmidon-framework.mf rename proposal/myrmidon/src/manifest/{ant-manifest.mf => myrmidon-launcher.mf} (100%) diff --git a/proposal/myrmidon/build.xml b/proposal/myrmidon/build.xml index 831194e08..c2d72d4d9 100644 --- a/proposal/myrmidon/build.xml +++ b/proposal/myrmidon/build.xml @@ -105,18 +105,24 @@ Legal: - + manifest="${manifest.dir}/myrmidon-launcher.mf"> - - - - + manifest="${manifest.dir}/myrmidon-api.mf"> + + + + + + + @@ -125,7 +131,29 @@ Legal: + + + + + + + @@ -167,10 +195,14 @@ Legal: + + + + diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/launcher/Main.java b/proposal/myrmidon/src/java/org/apache/myrmidon/launcher/Main.java index f7b58ab58..dc6711326 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/launcher/Main.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/launcher/Main.java @@ -13,6 +13,7 @@ import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; +import java.util.Arrays; import java.util.StringTokenizer; /** @@ -40,9 +41,13 @@ public final class Main //setup classloader appropriately for myrmidon jar final File libDir = new File( installDirectory, "lib" ); - final URL[] urls = buildURLList( libDir ); + final URL[] libUrls = buildURLList( libDir ); + final URLClassLoader libClassLoader = new URLClassLoader( libUrls ); - final URLClassLoader classLoader = new URLClassLoader( urls ); + final File containerLibDir = new File( installDirectory, "bin" + File.separator + "lib" ); + final URL[] containerLibUrls = buildURLList( containerLibDir ); + final URLClassLoader classLoader = + new URLClassLoader( containerLibUrls, libClassLoader ); //load class and retrieve appropriate main method. final Class clazz = classLoader.loadClass( "org.apache.myrmidon.frontends.CLIMain" ); @@ -116,7 +121,7 @@ public final class Main { final String element = tokenizer.nextToken(); - if( element.endsWith( "ant.jar" ) ) + if( element.endsWith( "myrmidon-launcher.jar" ) ) { File file = (new File( element )).getAbsoluteFile(); file = file.getParentFile(); @@ -133,3 +138,58 @@ public final class Main throw new Exception( "Unable to locate ant.jar in classpath" ); } } + +class MyClassLoader extends URLClassLoader +{ + MyClassLoader( final URL[] urls, final ClassLoader classLoader ) + { + super( urls, classLoader ); + } + + public Class loadClass( final String name ) + throws ClassNotFoundException + { + System.out.println( "Loading: " + name ); + try + { + return super.loadClass( name ); + } + catch( final ClassNotFoundException cnfe ) + { + System.out.println( "Failed to Load: " + name ); + throw cnfe; + } + } + + protected Class findClass( final String name ) + throws ClassNotFoundException + { + System.out.println( "findClass: " + name ); + try + { + return super.findClass( name ); + } + catch( final ClassNotFoundException cnfe ) + { + System.out.println( "Failed to Load: " + name ); + throw cnfe; + } + } + + public Class loadClass( final String name, final boolean resolve ) + throws ClassNotFoundException + { + System.out.println( "Loading: " + name ); + try + { + return super.loadClass( name, resolve ); + } + catch( final ClassNotFoundException cnfe ) + { + System.out.println( "Failed to Load: " + name ); + throw cnfe; + } + } +} + + diff --git a/proposal/myrmidon/src/make/sample.ant b/proposal/myrmidon/src/make/sample.ant index c4220feb8..691f62ecd 100644 --- a/proposal/myrmidon/src/make/sample.ant +++ b/proposal/myrmidon/src/make/sample.ant @@ -101,11 +101,13 @@ Legal: + diff --git a/proposal/myrmidon/src/manifest/builtin-ant-roles.xml b/proposal/myrmidon/src/manifest/builtin-ant-roles.xml index d16b54731..1703ddd32 100644 --- a/proposal/myrmidon/src/manifest/builtin-ant-roles.xml +++ b/proposal/myrmidon/src/manifest/builtin-ant-roles.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/proposal/myrmidon/src/manifest/myrmidon-api.mf b/proposal/myrmidon/src/manifest/myrmidon-api.mf new file mode 100644 index 000000000..0ab1df982 --- /dev/null +++ b/proposal/myrmidon/src/manifest/myrmidon-api.mf @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Created-By: Apache Ant Project +Extension-Name: myrmidon.api +Specification-Title: Myrmidon API +Specification-Version: 0.01 +Specification-Vendor: Jakarta Apache +Implementation-Vendor-Id: org.apache.jakarta +Implementation-Vendor: Jakarta Apache Project +Implementation-Version: 0.01 \ No newline at end of file diff --git a/proposal/myrmidon/src/manifest/myrmidon-container.mf b/proposal/myrmidon/src/manifest/myrmidon-container.mf new file mode 100644 index 000000000..f7941a8ae --- /dev/null +++ b/proposal/myrmidon/src/manifest/myrmidon-container.mf @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Created-By: Apache Ant Project +Main-Class: org.apache.myrmidon.frontends.CLIMain +Extension-Name: myrmidon.container +Specification-Title: Myrmidon Framework +Specification-Version: 0.01 +Specification-Vendor: Jakarta Apache +Implementation-Vendor-Id: org.apache.jakarta +Implementation-Vendor: Jakarta Apache Project +Implementation-Version: 0.01 +Extension-List: myrmidon_api, myrmidon_framework +myrmidon_api-Extension-Name: myrmidon.api +myrmidon_api-Specification-Version: 0.01 +myrmidon_api-Implementation-Version: 0.01 +myrmidon_api-Implementation-Vendor-Id: org.apache.jakarta +myrmidon_framework-Extension-Name: myrmidon.framework +myrmidon_framework-Specification-Version: 0.01 +myrmidon_framework-Implementation-Version: 0.01 +myrmidon_framework-Implementation-Vendor-Id: org.apache.jakarta \ No newline at end of file diff --git a/proposal/myrmidon/src/manifest/myrmidon-framework.mf b/proposal/myrmidon/src/manifest/myrmidon-framework.mf new file mode 100644 index 000000000..5cbf04aec --- /dev/null +++ b/proposal/myrmidon/src/manifest/myrmidon-framework.mf @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Created-By: Apache Ant Project +Extension-Name: myrmidon.framework +Specification-Title: Myrmidon Framework +Specification-Version: 0.01 +Specification-Vendor: Jakarta Apache +Implementation-Vendor-Id: org.apache.jakarta +Implementation-Vendor: Jakarta Apache Project +Implementation-Version: 0.01 +Extension-List: myrmidon.api +myrmidon.api-Extension-Name: myrmidon.api +myrmidon.api-Specification-Version: 0.01 +myrmidon.api-Implementation-Version: 0.01 +myrmidon.api-Implementation-Vendor-Id: org.apache.jakarta +_myrmidon.api-Implementation-URL: http://jakarta.apache.org/ant/myrmidon-api.jar \ No newline at end of file diff --git a/proposal/myrmidon/src/manifest/ant-manifest.mf b/proposal/myrmidon/src/manifest/myrmidon-launcher.mf similarity index 100% rename from proposal/myrmidon/src/manifest/ant-manifest.mf rename to proposal/myrmidon/src/manifest/myrmidon-launcher.mf diff --git a/proposal/myrmidon/src/script/ant b/proposal/myrmidon/src/script/ant index 18709728f..3e0fbb194 100644 --- a/proposal/myrmidon/src/script/ant +++ b/proposal/myrmidon/src/script/ant @@ -42,4 +42,4 @@ else fi fi -$JAVACMD $ANT_OPTS -jar $ANT_HOME/lib/ant.jar $@ +$JAVACMD $ANT_OPTS -jar $ANT_HOME/bin/myrmidon-launcher.jar $@ diff --git a/proposal/myrmidon/src/script/ant.bat b/proposal/myrmidon/src/script/ant.bat index b0269bd7a..a9d80be12 100644 --- a/proposal/myrmidon/src/script/ant.bat +++ b/proposal/myrmidon/src/script/ant.bat @@ -57,7 +57,7 @@ goto setupArgs :doneArgs rem Mmmmmm tasty - finished slurping args -%JAVACMD% %ANT_OPTS% -jar %ANT_HOME%\lib\ant.jar %ANT_CMD_LINE_ARGS% +%JAVACMD% %ANT_OPTS% -jar %ANT_HOME%\bin\myrmidon-launcher.jar %ANT_CMD_LINE_ARGS% :end if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat"