You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

classloader.html 10 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <!-- Content Stylesheet for Site -->
  3. <!-- start the processing -->
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  7. <meta name="author" value="Peter Donald">
  8. <meta name="email" value="peter@apache.org">
  9. <title>Apache Myrmidon - On ClassLoaders in Ant 2</title>
  10. </head>
  11. <body bgcolor="#ffffff" text="#000000" link="#525D76">
  12. <table border="0" width="100%" cellspacing="0">
  13. <!-- TOP IMAGE -->
  14. <tr>
  15. <td> <td colspan="2">
  16. <a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
  17. </td>
  18. </td>
  19. <td valign="bottom"><div align="right"><b><font size="+3" color="#525D76">Apache Myrmidon</font></b></div></td>
  20. </tr>
  21. </table>
  22. <table border="0" width="100%" cellspacing="4">
  23. <tr><td colspan="2">
  24. <hr noshade="" size="1"/>
  25. </td></tr>
  26. <tr>
  27. <!-- LEFT SIDE NAVIGATION -->
  28. <td valign="top" nowrap="true">
  29. <p><strong>Myrmidon</strong></p>
  30. <ul>
  31. <li> <a href="./index.html">Introduction</a>
  32. </li>
  33. <li> <a href="./getinvolved.html">Get Involved</a>
  34. </li>
  35. <li> <a href="./user.html">Building Myrmidon</a>
  36. </li>
  37. <li> <a href="./todo.html">Todo List</a>
  38. </li>
  39. </ul>
  40. <p><strong>User Guide</strong></p>
  41. <ul>
  42. <li> <a href="./buildfile.html">Project File</a>
  43. </li>
  44. <li> <a href="./vfs.html">Virtual File System</a>
  45. </li>
  46. <li> <a href="./ant1compat.html">Ant 1 Compatibility Layer</a>
  47. </li>
  48. <li> <a href="./differences.html">Differences to Ant 1</a>
  49. </li>
  50. <li> <a href="./task.html">My First Task</a>
  51. </li>
  52. </ul>
  53. <p><strong>Extending Ant</strong></p>
  54. <ul>
  55. <li> <a href="./configuring.html">Configuration HOWTO</a>
  56. </li>
  57. <li> <a href="./converter.html">Converter HOWTO</a>
  58. </li>
  59. <li> <a href="./type.html">Type HOWTO</a>
  60. </li>
  61. <li> <a href="./classloader.html">ClassLoader HOWTO</a>
  62. </li>
  63. <li> <a href="./librarys.html">Library HOWTO</a>
  64. </li>
  65. </ul>
  66. <p><strong>Container Design</strong></p>
  67. <ul>
  68. </ul>
  69. </td>
  70. <td align="left" valign="top">
  71. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  72. <tr><td bgcolor="#525D76">
  73. <font color="#ffffff" face="arial,helvetica,sanserif">
  74. <a name="ClassLoader Management"><strong>ClassLoader Management</strong></a>
  75. </font>
  76. </td></tr>
  77. <tr><td>
  78. <blockquote>
  79. <p>In many ways Ant 2 needs to follow rules similar to a number of
  80. different application servers with respect to ClassLoader management.
  81. Ant 2 will create a number of different ClassLoaders that have access
  82. to different sets of resources (and thus Classes). The main reason
  83. for this arrangment is to partition different sections of the
  84. application such as the Container, the Task API, task/type libraries
  85. and support libraries.</p>
  86. <p>The recomended structure for ClassLoader relationships is a hierarchy.
  87. When a ClassLoader is asked for a resource (or a class) it first delegates
  88. to it's parent to ask for the resource. If the resource is not present in
  89. its parent ClassLoader then the ClassLoader attempts to locate the resource
  90. in it's own store. In practice this means that all the classes (and static
  91. variables defined by said classes) in a parent ClassLoader are shared with
  92. the child ClassLoaders.</p>
  93. <p>Using kooky ascii art, the specific ClassLoader structure for Ant 2 is as
  94. follows:</p>
  95. <div align="left">
  96. <table cellspacing="4" cellpadding="0" border="0">
  97. <tr>
  98. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  99. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  100. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  101. </tr>
  102. <tr>
  103. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  104. <td bgcolor="#ffffff"><pre>
  105. Bootstrap
  106. |
  107. System
  108. |
  109. Common
  110. / \
  111. Container Shared
  112. / \
  113. Antlib1 Antlib2 ...
  114. </pre></td>
  115. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  116. </tr>
  117. <tr>
  118. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  119. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  120. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  121. </tr>
  122. </table>
  123. </div>
  124. <ul>
  125. <li>
  126. The
  127. <strong>Bootstrap</strong> ClassLoader contains the classes and resources
  128. provided by the Java runtime.
  129. </li>
  130. <li>
  131. The
  132. <strong>System</strong> ClassLoader contains the classes that were made accessible
  133. via the CLASSPATH environment variable. If the standard ant script was used then this
  134. should only contain the classes that are used to bootstrap the ant runtime. ie
  135. <code>$ANT_HOME/bin/ant-launcher.jar</code>
  136. </li>
  137. <li>
  138. The
  139. <strong>Common</strong> ClassLoader contains the classes and resources
  140. that are made visible to both the Container and to all the ant type libraries. This
  141. contains all the classes that the Container uses to communicate with tasks and other
  142. supporting infrastructure. In particular it contains the following APIs;
  143. <ul>
  144. <li>
  145. <em>Task API</em> - Contains the classes that are part of the API used
  146. to define tasks.
  147. </li>
  148. <li>
  149. <em>ProjectListener API</em> - Contains the classes necessary to define new
  150. ProjectListeners.
  151. </li>
  152. <li>
  153. <em>Aspect API</em> - Contains the classes that are used to define Aspects
  154. of the container.
  155. </li>
  156. <li>
  157. <em>Container API</em> - Contains the interfaces that are required to communicate
  158. with the objects deep within the container.
  159. <strong>NOTE</strong>: These interfaces
  160. are not to be used by user tasks but are made available so that certain tasks (such
  161. as &lt;antcall/&gt;) can be implemented. However they are subject to change without
  162. notice between between different Ant 2 versions.
  163. </li>
  164. </ul>
  165. <p>
  166. These classes are loaded from all the jars present in the
  167. <code>$ANT_HOME/lib</code>
  168. directory.
  169. </p>
  170. </li>
  171. <li>
  172. The
  173. <strong>Container</strong> ClassLoader contains all the classes and resources
  174. that are part of the actual implementation of the Container. These classes are not
  175. directly accessible to any Ant library or task. Some of the classes are indirectly
  176. accessible to tasks and other elements defined in the ant libraries as they implement
  177. interfaces defined in the
  178. <strong>Common</strong> ClassLoader. The classes that are
  179. stored in jars in the
  180. <code>$ANT_HOME/bin/lib/</code> directory.
  181. </li>
  182. <li>
  183. The
  184. <strong>Shared</strong> ClassLoader contains all the classes and resources
  185. that are shared across all of the ant libraries (unless they are als needed by the
  186. container in which case they should be placed int the
  187. <strong>Container</strong>
  188. ClassLoader). This ClassLoader is populated by all the jars that are contained in
  189. the
  190. <code>$ANT_HOME/shared/</code> directory.
  191. </li>
  192. <li>
  193. The
  194. <strong>AntLib</strong> ClassLoaders each contain the classes and resources
  195. that required by that particular library. Note that in some cases a single Ant
  196. Library will manifest as a single ClassLoader containing a single jar. However
  197. in some cases it is possible for one Ant Library to have multiple jars in its
  198. ClassLoader or even have multiple ClassLoaders. See XXXX for further details.
  199. </li>
  200. </ul>
  201. </blockquote>
  202. </td></tr>
  203. </table>
  204. </td>
  205. </tr>
  206. <!-- FOOTER -->
  207. <tr><td colspan="2">
  208. <hr noshade="" size="1"/>
  209. </td></tr>
  210. <tr><td colspan="2">
  211. <div align="center"><font color="#525D76" size="-1"><em>
  212. Copyright &#169; 2000-2002, Apache Software Foundation
  213. </em></font></div>
  214. </td></tr>
  215. </table>
  216. </body>
  217. </html>
  218. <!-- end the processing -->