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 8.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 Ant2</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">Build file</a>
  43. </li>
  44. <li> <a href="./vfs.html">Virtual File System</a>
  45. </li>
  46. <li> <a href="./ant1compat.html">Ant1 Compatibility Layer</a>
  47. </li>
  48. <li> <a href="./differences.html">Differences to Ant1</a>
  49. </li>
  50. </ul>
  51. <p><strong>Extending Ant</strong></p>
  52. <ul>
  53. <li> <a href="./task.html">Task Writers HOWTO</a>
  54. </li>
  55. <li> <a href="./classloader.html">ClassLoader HOWTO</a>
  56. </li>
  57. <li> <a href="./librarys.html">Library HOWTO</a>
  58. </li>
  59. </ul>
  60. <p><strong>Container Design</strong></p>
  61. <ul>
  62. </ul>
  63. </td>
  64. <td align="left" valign="top">
  65. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  66. <tr><td bgcolor="#525D76">
  67. <font color="#ffffff" face="arial,helvetica,sanserif">
  68. <a name="ClassLoader Management"><strong>ClassLoader Management</strong></a>
  69. </font>
  70. </td></tr>
  71. <tr><td>
  72. <blockquote>
  73. <p>In many ways Ant2 needs to follow rules similar to a number of
  74. different application servers with respect to ClassLoader management.
  75. Ant2 will create a number of different ClassLoaders that have access
  76. to different sets of resources (and thus Classes). The main reason
  77. for this arrangment is to partition different sections of the
  78. application such as the Container, the Task API, task/type libraries
  79. and support libraries.</p>
  80. <p>The recomended structure for ClassLoader relationships is a hierarchy.
  81. When a ClassLoader is asked for a resource (or a class) it first delegates
  82. to it's parent to ask for the resource. If the resource is not present in
  83. its parent ClassLoader then the ClassLoader attempts to locate the resource
  84. in it's own store. In practice this means that all the classes (and static
  85. variables defined by said classes) in a parent ClassLoader are shared with
  86. the child ClassLoaders.</p>
  87. <p>Using kooky ascii art, the specific ClassLoader structure for Ant2 is as
  88. follows:</p>
  89. <div align="left">
  90. <table cellspacing="4" cellpadding="0" border="0">
  91. <tr>
  92. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  93. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  94. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  95. </tr>
  96. <tr>
  97. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  98. <td bgcolor="#ffffff"><pre>
  99. Bootstrap
  100. |
  101. System
  102. |
  103. Common
  104. / \
  105. Container Shared
  106. / \
  107. Antlib1 Antlib2 ...
  108. </pre></td>
  109. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  110. </tr>
  111. <tr>
  112. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  113. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  114. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  115. </tr>
  116. </table>
  117. </div>
  118. <ul>
  119. <li>
  120. The <strong>Bootstrap</strong> ClassLoader contains the classes and resources
  121. provided by the Java runtime.
  122. </li>
  123. <li>
  124. The <strong>System</strong> ClassLoader contains the classes that were made accessible
  125. via the CLASSPATH environment variable. If the standard ant script was used then this
  126. should only contain the classes that are used to bootstrap the ant runtime. ie
  127. <code>$ANT_HOME/bin/ant-launcher.jar</code>
  128. </li>
  129. <li>
  130. The <strong>Common</strong> ClassLoader contains the classes and resources
  131. that are made visible to both the Container and to all the ant type librarys. This
  132. contains all the classes that the Container uses to communicate with tasks and other
  133. supporting infrastructure. In particular it contains the following APIs;
  134. <ul>
  135. <li>
  136. <em>Task API</em> - Contains the classes that are part of the API used
  137. to define tasks.
  138. </li>
  139. <li>
  140. <em>ProjectListener API</em> - Contains the classes necessary to define new
  141. ProjectListeners.
  142. </li>
  143. <li>
  144. <em>Aspect API</em> - Contains the classes that are used to define Aspects
  145. of the container.
  146. </li>
  147. <li>
  148. <em>Container API</em> - Contains the interfaces that are required to communicate
  149. with the objects deep within the container. <strong>NOTE</strong>: These interfaces
  150. are not to be used by user tasks but are made available so that certain tasks (such
  151. as &lt;antcall/&gt;) can be implemented. However they are subject to change without
  152. notice between between different ant2 versions.
  153. </li>
  154. </ul>
  155. <p>
  156. These classes are loaded from all the jars present in the <code>$ANT_HOME/lib</code>
  157. directory.
  158. </p>
  159. </li>
  160. <li>
  161. The <strong>Container</strong> ClassLoader contains all the classes and resources
  162. that are part of the actual implementation of the Container. These classes are not
  163. directly accessible to any Ant library or task. Some of the classes are indirectly
  164. accessible to tasks and other elements defined in the ant librarys as they implement
  165. interfaces defined in the <strong>Common</strong> ClassLoader. The classes that are
  166. stored in jars in the <code>$ANT_HOME/bin/lib/</code> directory.
  167. </li>
  168. <li>
  169. The <strong>Shared</strong> ClassLoader contains all the classes and resources
  170. that are shared across all of the ant librarys (unless they are als needed by the
  171. container in which case they should be placed int the <strong>Container</strong>
  172. ClassLoader). This ClassLoader is populated by all the jars that are contained in
  173. the <code>$ANT_HOME/shared/</code> directory.
  174. </li>
  175. <li>
  176. The <strong>AntLib</strong> ClassLoaders each contain the classes and resources
  177. that required by that particular library. Note that in some cases a single Ant
  178. Library will manifest as a single ClassLoader containing a single jar. However
  179. in some cases it is possible for one Ant Library to have multiple jars in its
  180. ClassLoader or even have multiple ClassLoaders. See XXXX for further details.
  181. </li>
  182. </ul>
  183. </blockquote>
  184. </td></tr>
  185. </table>
  186. </td>
  187. </tr>
  188. <!-- FOOTER -->
  189. <tr><td colspan="2">
  190. <hr noshade="" size="1"/>
  191. </td></tr>
  192. <tr><td colspan="2">
  193. <div align="center"><font color="#525D76" size="-1"><em>
  194. Copyright &#169; 2000-2002, Apache Software Foundation
  195. </em></font></div>
  196. </td></tr>
  197. </table>
  198. </body>
  199. </html>
  200. <!-- end the processing -->