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.

librarys.html 16 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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 Librarys 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="Library Management"><strong>Library Management</strong></a>
  65. </font>
  66. </td></tr>
  67. <tr><td>
  68. <blockquote>
  69. <p>Long ago there was identified the need for librarys that contain
  70. tasks and other elements present in the build file. This document
  71. attempts to describe the mechanism via which these libraries will be
  72. defined and used in Ant2. The librarys (also referred to as
  73. deployments) will be termed antlibs.</p>
  74. <p>Ant librarys can be packaged and signed into a ANt Type Library
  75. format (.atl) using the standard Java Archive tools. (For details on
  76. the .jar file format see the
  77. <a href="http://java.sun.com/j2se/1.3/docs/guide/jar/index.html">
  78. Jar Specification</a>.</p>
  79. <p>When packaged into such a form the META-INF/ directory contains
  80. ant specific descriptors in addition to the standard Jar manifest
  81. and other descriptor files. The archive will also contain the
  82. <code>.class</code> files for all the tasks and other types the
  83. library defines. It may also contain additional resources that can
  84. be referenced in the build file (an example being DTDs).</p>
  85. <p>The library may also need access to other librarys or resources
  86. to perform its job. For instance, if the task loaded an XML document
  87. and then processed said document using the <em>Trax API</em> then
  88. the Ant library needs to have access to the <em>Trax API</em> and an
  89. implementation of the API. The Antlib mechanism thus uses the standard
  90. "Optional Package" Specification to declare dependencies on other
  91. libraries.</p>
  92. <p>The libraries will usually be installed in standard locations that
  93. make it possible for the Ant container to automatically locate and scan
  94. the libraries. It will also be possible for the users to specify
  95. additional search locations or even the specific location of ant
  96. libraries.</p>
  97. <p>The following sections will describe each of these different facets
  98. in greater detail.</p>
  99. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  100. <tr><td bgcolor="#828DA6">
  101. <font color="#ffffff" face="arial,helvetica,sanserif">
  102. <a name="Descriptors"><strong>Descriptors</strong></a>
  103. </font>
  104. </td></tr>
  105. <tr><td>
  106. <blockquote>
  107. <p>FIXME: Import this part from other doco</p>
  108. </blockquote>
  109. </td></tr>
  110. </table>
  111. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  112. <tr><td bgcolor="#828DA6">
  113. <font color="#ffffff" face="arial,helvetica,sanserif">
  114. <a name="Class and Resource Files"><strong>Class and Resource Files</strong></a>
  115. </font>
  116. </td></tr>
  117. <tr><td>
  118. <blockquote>
  119. <p>The class and resources files should be stored as in standard jars. The
  120. root directory being the base via which code and resources are loaded. So
  121. the <code>.class</code> file for the Java class <code>com.biz.tasks.Mytask</code>
  122. would be stored in <code>/com/biz/tasks/Mytask.class</code></p>
  123. </blockquote>
  124. </td></tr>
  125. </table>
  126. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  127. <tr><td bgcolor="#828DA6">
  128. <font color="#ffffff" face="arial,helvetica,sanserif">
  129. <a name="Dependencies"><strong>Dependencies</strong></a>
  130. </font>
  131. </td></tr>
  132. <tr><td>
  133. <blockquote>
  134. <p>It is often the case that a library will need external resources. The
  135. example given above described dependence on an external XML library. The
  136. ant library thus needs a mechanism via which to declare dependencies on
  137. external libraries.</p>
  138. <p>Ant2 uses the "Optional Package" mechanism. Prior to JDK1.3, an "Optional
  139. Package" was known as an <em>Extension</em>. The specification for this
  140. mechanism is available in the JDK1.3 documentation in the directory
  141. <code>$JDK_HOME/docs/guide/extensions/versioning.html</code>. Alternatively
  142. it is available online at
  143. <a href="http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html">
  144. http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html</a>.</p>
  145. <p>This mechanism was adopted as it is an established standard. The standard
  146. is also begining to be adopted by other specifications such as the <em>Servlet
  147. 2.3 API</em>. Thus we are likely to see an increase of jars using this mechanism
  148. to specify dependencies.</p>
  149. <p>The "Optional Package" mechanism allows jars to specify dependencies on other
  150. jars that implement a particular specification at particular version levels. For
  151. example you could specify a dependency on the Trax 1.1 API by adding the following
  152. to the manifest of your jar.</p>
  153. <div align="left">
  154. <table cellspacing="4" cellpadding="0" border="0">
  155. <tr>
  156. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  157. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  158. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  159. </tr>
  160. <tr>
  161. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  162. <td bgcolor="#ffffff"><pre>
  163. Extension-List: trax
  164. trax-Extension-Name: Java API for XML Parsing
  165. trax-Specification-Version: 1.1
  166. </pre></td>
  167. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  168. </tr>
  169. <tr>
  170. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  171. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  172. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  173. </tr>
  174. </table>
  175. </div>
  176. <p>In some cases you may also wish to specify a dependency on a specific vendors
  177. implementation. For instance you may need to use xalan due to it implementing a
  178. particular extension you need. In that case you manifest may contain;</p>
  179. <div align="left">
  180. <table cellspacing="4" cellpadding="0" border="0">
  181. <tr>
  182. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  183. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  184. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  185. </tr>
  186. <tr>
  187. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  188. <td bgcolor="#ffffff"><pre>
  189. Extension-List: trax
  190. trax-Extension-Name: Java API for XML Parsing
  191. trax-Specification-Version: 1.1
  192. trax-Implementation-Title: org.apache.xalan.xslt
  193. trax-Implementation-Version: 2.1.0
  194. trax-Implementation-Vendor: Apache Software Foundation
  195. </pre></td>
  196. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  197. </tr>
  198. <tr>
  199. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  200. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  201. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  202. </tr>
  203. </table>
  204. </div>
  205. <p>In many cases there will be no distinction between the specification and
  206. the implementation of a library. For instance the Velocity project only has
  207. one implementation and one specification. In which case it is sufficient to
  208. just declare a dependency on the Velocity "Specification". A library that uses
  209. both the Trax API and the Velocity project may look like;</p>
  210. <div align="left">
  211. <table cellspacing="4" cellpadding="0" border="0">
  212. <tr>
  213. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  214. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  215. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  216. </tr>
  217. <tr>
  218. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  219. <td bgcolor="#ffffff"><pre>
  220. Extension-List: trax velocity
  221. velocity-Extension-Name: org.apache.velocity
  222. velocity-Specification-Version: 1.0
  223. trax-Extension-Name: Java API for XML Parsing
  224. trax-Specification-Version: 1.1
  225. trax-Implementation-Title: org.apache.xalan.xslt
  226. trax-Implementation-Version: 2.1.0
  227. trax-Implementation-Vendor: Apache Software Foundation
  228. </pre></td>
  229. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  230. </tr>
  231. <tr>
  232. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  233. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  234. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  235. </tr>
  236. </table>
  237. </div>
  238. <p>To make other jars available to Ant librarys as "Optional Packages"
  239. or Extensions then you need to add a few lines to the manifest of the
  240. other jar. The minimal manifest is the following;</p>
  241. <div align="left">
  242. <table cellspacing="4" cellpadding="0" border="0">
  243. <tr>
  244. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  245. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  246. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  247. </tr>
  248. <tr>
  249. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  250. <td bgcolor="#ffffff"><pre>
  251. Extension-Name: org.realityforge.dve
  252. Specification-Vendor: Peter Donald
  253. Specification-Version: 1.0
  254. </pre></td>
  255. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  256. </tr>
  257. <tr>
  258. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  259. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  260. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  261. </tr>
  262. </table>
  263. </div>
  264. <p>It is important to note that looking for dependencies is recursive. For example,
  265. if the ant library depends upon jar A and and A depends on B then both A and B will
  266. need to be loaded by the container.</p>
  267. </blockquote>
  268. </td></tr>
  269. </table>
  270. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  271. <tr><td bgcolor="#828DA6">
  272. <font color="#ffffff" face="arial,helvetica,sanserif">
  273. <a name="Implementation Notes"><strong>Implementation Notes</strong></a>
  274. </font>
  275. </td></tr>
  276. <tr><td>
  277. <blockquote>
  278. <p>So far there has been no mention of implementation strategies for
  279. managing ClassLoaders and other details about where the "Optional Packages"
  280. are stored. This section will outline such details but they could change
  281. in the future. The above specification will still be accurate but the approach
  282. to implementing specification will be different.</p>
  283. <p>In the current architecture all of the "Optional Packages" are assumed to
  284. be stored in the <code>$ANT_HOME/ext</code> directory. The runtime will scan
  285. this directory for jars and add all the "optional Packages" found into a
  286. registry. This registry will be used by the library loading mechanism to locate
  287. all the "Optional Packages". The user is able to specify an alternative directory
  288. or add a new directory to search on the commandline.</p>
  289. <p>When the container attempts to load an ant library it will also try to load
  290. any needed dependencies. First it will check the parent ClassLoaders to see if any
  291. of them contain the required dependencies. If not then it will search the
  292. "Optional Packages" registry. If the dependency is not found then a error will be
  293. signaled. If the dependency is found in the "Optional Packages" registry then it is
  294. loaded by the same ClassLoader that is used to load the Ant library.</p>
  295. </blockquote>
  296. </td></tr>
  297. </table>
  298. </blockquote>
  299. </td></tr>
  300. </table>
  301. </td>
  302. </tr>
  303. <!-- FOOTER -->
  304. <tr><td colspan="2">
  305. <hr noshade="" size="1"/>
  306. </td></tr>
  307. <tr><td colspan="2">
  308. <div align="center"><font color="#525D76" size="-1"><em>
  309. Copyright &#169; 2000-2002, Apache Software Foundation
  310. </em></font></div>
  311. </td></tr>
  312. </table>
  313. </body>
  314. </html>
  315. <!-- end the processing -->