|
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
- <!-- Content Stylesheet for Site -->
-
-
- <!-- start the processing -->
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
-
- <meta name="author" value="Peter Donald">
- <meta name="email" value="peter@apache.org">
-
- <title>Apache Myrmidon - On ClassLoaders in Ant 2</title>
- </head>
-
- <body bgcolor="#ffffff" text="#000000" link="#525D76">
- <table border="0" width="100%" cellspacing="0">
- <!-- TOP IMAGE -->
- <tr>
- <td> <td colspan="2">
- <a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
- </td>
- </td>
- <td valign="bottom"><div align="right"><b><font size="+3" color="#525D76">Apache Myrmidon</font></b></div></td>
- </tr>
- </table>
- <table border="0" width="100%" cellspacing="4">
- <tr><td colspan="2">
- <hr noshade="" size="1"/>
- </td></tr>
-
- <tr>
- <!-- LEFT SIDE NAVIGATION -->
- <td valign="top" nowrap="true">
- <p><strong>Myrmidon</strong></p>
- <ul>
- <li> <a href="./index.html">Introduction</a>
- </li>
- <li> <a href="./getinvolved.html">Get Involved</a>
- </li>
- <li> <a href="./user.html">Building Myrmidon</a>
- </li>
- <li> <a href="./todo.html">Todo List</a>
- </li>
- </ul>
- <p><strong>User Guide</strong></p>
- <ul>
- <li> <a href="./buildfile.html">Project File</a>
- </li>
- <li> <a href="./vfs.html">Virtual File System</a>
- </li>
- <li> <a href="./ant1compat.html">Ant 1 Compatibility Layer</a>
- </li>
- <li> <a href="./differences.html">Differences to Ant 1</a>
- </li>
- <li> <a href="./task.html">My First Task</a>
- </li>
- </ul>
- <p><strong>Extending Ant</strong></p>
- <ul>
- <li> <a href="./configuring.html">Configuration HOWTO</a>
- </li>
- <li> <a href="./converter.html">Converter HOWTO</a>
- </li>
- <li> <a href="./type.html">Type HOWTO</a>
- </li>
- <li> <a href="./classloader.html">ClassLoader HOWTO</a>
- </li>
- <li> <a href="./librarys.html">Library HOWTO</a>
- </li>
- </ul>
- <p><strong>Container Design</strong></p>
- <ul>
- </ul>
- </td>
- <td align="left" valign="top">
- <table border="0" cellspacing="0" cellpadding="2" width="100%">
- <tr><td bgcolor="#525D76">
- <font color="#ffffff" face="arial,helvetica,sanserif">
- <a name="ClassLoader Management"><strong>ClassLoader Management</strong></a>
- </font>
- </td></tr>
- <tr><td>
- <blockquote>
- <p>In many ways Ant 2 needs to follow rules similar to a number of
- different application servers with respect to ClassLoader management.
- Ant 2 will create a number of different ClassLoaders that have access
- to different sets of resources (and thus Classes). The main reason
- for this arrangment is to partition different sections of the
- application such as the Container, the Task API, task/type libraries
- and support libraries.</p>
- <p>The recomended structure for ClassLoader relationships is a hierarchy.
- When a ClassLoader is asked for a resource (or a class) it first delegates
- to it's parent to ask for the resource. If the resource is not present in
- its parent ClassLoader then the ClassLoader attempts to locate the resource
- in it's own store. In practice this means that all the classes (and static
- variables defined by said classes) in a parent ClassLoader are shared with
- the child ClassLoaders.</p>
- <p>Using kooky ascii art, the specific ClassLoader structure for Ant 2 is as
- follows:</p>
- <div align="left">
- <table cellspacing="4" cellpadding="0" border="0">
- <tr>
- <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
- <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
- <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
- </tr>
- <tr>
- <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
- <td bgcolor="#ffffff"><pre>
- Bootstrap
- |
- System
- |
- Common
- / \
- Container Shared
- / \
- Antlib1 Antlib2 ...
- </pre></td>
- <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
- </tr>
- <tr>
- <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
- <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
- <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
- </tr>
- </table>
- </div>
- <ul>
- <li>
- The
- <strong>Bootstrap</strong> ClassLoader contains the classes and resources
- provided by the Java runtime.
-
- </li>
- <li>
- The
- <strong>System</strong> ClassLoader contains the classes that were made accessible
- via the CLASSPATH environment variable. If the standard ant script was used then this
- should only contain the classes that are used to bootstrap the ant runtime. ie
-
- <code>$ANT_HOME/bin/ant-launcher.jar</code>
- </li>
- <li>
- The
- <strong>Common</strong> ClassLoader contains the classes and resources
- that are made visible to both the Container and to all the ant type libraries. This
- contains all the classes that the Container uses to communicate with tasks and other
- supporting infrastructure. In particular it contains the following APIs;
-
- <ul>
- <li>
- <em>Task API</em> - Contains the classes that are part of the API used
- to define tasks.
-
- </li>
- <li>
- <em>ProjectListener API</em> - Contains the classes necessary to define new
- ProjectListeners.
-
- </li>
- <li>
- <em>Aspect API</em> - Contains the classes that are used to define Aspects
- of the container.
-
- </li>
- <li>
- <em>Container API</em> - Contains the interfaces that are required to communicate
- with the objects deep within the container.
- <strong>NOTE</strong>: These interfaces
- are not to be used by user tasks but are made available so that certain tasks (such
- as <antcall/>) can be implemented. However they are subject to change without
- notice between between different Ant 2 versions.
-
- </li>
- </ul>
- <p>
- These classes are loaded from all the jars present in the
- <code>$ANT_HOME/lib</code>
- directory.
-
- </p>
- </li>
- <li>
- The
- <strong>Container</strong> ClassLoader contains all the classes and resources
- that are part of the actual implementation of the Container. These classes are not
- directly accessible to any Ant library or task. Some of the classes are indirectly
- accessible to tasks and other elements defined in the ant libraries as they implement
- interfaces defined in the
- <strong>Common</strong> ClassLoader. The classes that are
- stored in jars in the
- <code>$ANT_HOME/bin/lib/</code> directory.
-
- </li>
- <li>
- The
- <strong>Shared</strong> ClassLoader contains all the classes and resources
- that are shared across all of the ant libraries (unless they are als needed by the
- container in which case they should be placed int the
- <strong>Container</strong>
- ClassLoader). This ClassLoader is populated by all the jars that are contained in
- the
- <code>$ANT_HOME/shared/</code> directory.
-
- </li>
- <li>
- The
- <strong>AntLib</strong> ClassLoaders each contain the classes and resources
- that required by that particular library. Note that in some cases a single Ant
- Library will manifest as a single ClassLoader containing a single jar. However
- in some cases it is possible for one Ant Library to have multiple jars in its
- ClassLoader or even have multiple ClassLoaders. See XXXX for further details.
-
- </li>
- </ul>
- </blockquote>
- </td></tr>
- </table>
- </td>
- </tr>
-
- <!-- FOOTER -->
- <tr><td colspan="2">
- <hr noshade="" size="1"/>
- </td></tr>
- <tr><td colspan="2">
- <div align="center"><font color="#525D76" size="-1"><em>
- Copyright © 2000-2002, Apache Software Foundation
- </em></font></div>
- </td></tr>
- </table>
- </body>
- </html>
- <!-- end the processing -->
-
-
-
|