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

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