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.6 KiB

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