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.

design.html 24 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html lang="en">
  3. <!-- GENERATED FILE, DO NOT EDIT, EDIT THE XML FILE IN xdocs INSTEAD! -->
  4. <head>
  5. <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  6. <title>Apache Ant - Design Overview</title>
  7. <link type="text/css" href="../../page.css" rel="stylesheet">
  8. <meta name="author" content="Simeon H. K. Fitch">
  9. <meta name="email" content="simeon@fitch.net">
  10. <meta name="author" content="Christoph Wilhelms">
  11. <meta name="email" content="christoph.wilhelms@t-online.de">
  12. </head>
  13. <body>
  14. <p class="navpath">
  15. <script src="../../breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
  16. </p>
  17. <table summary="header with logos" width="100%" border="0" cellpadding="0" cellspacing="0">
  18. <tr>
  19. <td bgcolor="#294563"><a href="http://ant.apache.org/"><img border="0" alt="Apache Ant site" src="../../images/group-logo.gif"></a></td><td width="100%" align="center" bgcolor="#294563"><a href="http://ant.apache.org/"><img alt="Apache Ant logo" border="0" src="../../images/project-logo.gif"></a></td><td valign="top" rowspan="2" bgcolor="#294563">
  20. <form target="_blank" onsubmit="q.value = query.value + ' site:ant.apache.org'" action="http://www.google.com/search" method="get">
  21. <table summary="search" border="0" cellspacing="0" cellpadding="0" bgcolor="#4C6C8F">
  22. <tr>
  23. <td colspan="3"><img height="10" width="1" alt="" src="../../images/spacer.gif"></td>
  24. </tr>
  25. <tr>
  26. <td><img height="1" width="1" alt="" src="../../images/spacer.gif"></td><td nowrap="nowrap"><input name="q" type="hidden"><input size="15" id="query" type="text"><img height="1" width="5" alt="" src="../../images/spacer.gif"><input name="Search" value="Search" type="submit">
  27. <br>
  28. <font face="Arial, Helvetica, Sans-serif" size="2" color="white">
  29. the Apache Ant site
  30. </font></td><td><img height="1" width="1" alt="" src="../../images/spacer.gif"></td>
  31. </tr>
  32. <tr>
  33. <td><img alt="" border="0" height="10" width="9" src="../../images/search-left.gif"></td><td><img height="1" width="1" alt="" src="../../images/spacer.gif"></td><td><img alt="" border="0" height="10" width="9" src="../../images/search-right.gif"></td>
  34. </tr>
  35. </table>
  36. </form>
  37. </td><td bgcolor="#294563"><img height="10" width="10" alt="" src="../../images/spacer.gif"></td>
  38. </tr>
  39. <tr>
  40. <td valign="bottom" bgcolor="#294563" colspan="2">
  41. <div class="tab">
  42. <table summary="tab bar" border="0" cellpadding="0" cellspacing="0">
  43. <tr>
  44. <td width="5"><img alt="" height="8" width="8" src="../../images/spacer.gif"></td><td valign="bottom">
  45. <table summary="non selected tab" style="height: 1.4em" border="0" cellpadding="0" cellspacing="0">
  46. <tr>
  47. <td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a href="../../index.html"><font size="2" face="Arial, Helvetica, Sans-serif">Home</font></a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../images/tab-right.gif"></td>
  48. </tr>
  49. </table>
  50. </td>
  51. <td width="8"><img alt="" height="5" width="8" src="images/spacer.gif"></td><td valign="bottom">
  52. <table summary="selected tab" style="height: 1.5em" border="0" cellpadding="0" cellspacing="0">
  53. <tr>
  54. <td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="../../images/tabSel-left.gif"></td><td valign="middle" bgcolor="#4C6C8F"><font color="#ffffff" size="2" face="Arial, Helvetica, Sans-serif"><b>Projects</b></font></td><td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="../../images/tabSel-right.gif"></td>
  55. </tr>
  56. </table>
  57. </td>
  58. </tr>
  59. </table>
  60. </div>
  61. </td><td bgcolor="#294563"><img alt="" width="1" height="1" src="../../images/spacer.gif"></td>
  62. </tr>
  63. <tr>
  64. <td bgcolor="#4C6C8F" colspan="4"><img width="1" height="10" alt="" src="../../images/spacer.gif"></td>
  65. </tr>
  66. </table>
  67. <table summary="page content" bgcolor="#ffffff" width="100%" border="0" cellpadding="0" cellspacing="0">
  68. <tr>
  69. <td valign="top">
  70. <table summary="menu" border="0" cellspacing="0" cellpadding="0">
  71. <tr>
  72. <td rowspan="3" valign="top">
  73. <table summary="blue line" border="0" cellpadding="0" cellspacing="0">
  74. <tr>
  75. <td bgcolor="#294563"><img width="10" height="1" alt="" src="../../images/spacer.gif"></td>
  76. </tr>
  77. <tr>
  78. <td bgcolor="#CFDCED"><font color="#4C6C8F" size="4" face="Arial, Helvetica, Sans-serif">&nbsp;</font></td>
  79. </tr>
  80. <tr>
  81. <td bgcolor="#294563"><img width="10" height="1" alt="" src="../../images/spacer.gif"></td>
  82. </tr>
  83. </table>
  84. </td><td bgcolor="#294563"><img width="1" height="1" alt="" src="../../images/spacer.gif"></td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../../images/spacer.gif"></td><td nowrap="nowrap" valign="top" bgcolor="#4C6C8F">
  85. <div class="menu"><ul>
  86. <li><font color="#CFDCED">Projects</font>
  87. <ul>
  88. <li>
  89. <a href="../../projects/index.html">Welcome</a>
  90. </li>
  91. </ul>
  92. </li>
  93. <li><font color="#CFDCED">Antidote</font>
  94. <ul>
  95. <li>
  96. <a href="../../projects/antidote/index.html">About Antidote</a>
  97. </li>
  98. <li>
  99. <span class="sel"><font color="#ffcc00">Design Overview</font></span>
  100. </li>
  101. <li>
  102. <a href="../../projects/antidote/module.html">Module HOW-TO</a>
  103. </li>
  104. </ul>
  105. </li>
  106. </ul></div>
  107. </td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../../images/spacer.gif"></td><td bgcolor="#294563"><img width="1" height="1" alt="" src="../../images/spacer.gif"></td>
  108. </tr>
  109. <tr>
  110. <td valign="bottom" align="left" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../images/menu-left.gif"></td><td bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../images/spacer.gif"></td><td valign="bottom" align="right" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../images/menu-right.gif"></td>
  111. </tr>
  112. <tr>
  113. <td height="1" bgcolor="#294563"><img width="1" height="1" alt="" src="../../images/spacer.gif"></td>
  114. </tr>
  115. </table>
  116. </td><td valign="top" width="100%">
  117. <table summary="content" width="100%" border="0" cellpadding="0" cellspacing="0">
  118. <tr>
  119. <td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../../images/spacer.gif"></td>
  120. </tr>
  121. <tr>
  122. <td align="left" width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../../images/spacer.gif"></td><td align="left" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
  123. &nbsp;
  124. </font><img width="10" height="8" alt="" src="../../images/spacer.gif"></td><td align="right" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
  125. &nbsp;
  126. </font><img width="10" height="8" alt="" src="../../images/spacer.gif"></td><td width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../../images/spacer.gif"></td>
  127. </tr>
  128. <tr>
  129. <td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../../images/spacer.gif"></td>
  130. </tr>
  131. <tr>
  132. <td align="left" width="10"><img width="10" height="1" alt="" src="../../images/spacer.gif"></td><td align="left" width="100%">
  133. <div class="content">
  134. <h1 class="title">Design Overview</h1>
  135. <h3 class="section">
  136. <a name="Introduction"></a>
  137. Introduction
  138. </h3>
  139. <p>The purpose of this document is to communicate the overall
  140. structure and design patters used in Antidote, the GUI for
  141. Ant. This document is a work in progress, as well as a living
  142. document, and it is most likely not be in full synchronization with
  143. the source code. Therefore, if there is any doubt, view the source
  144. ;-)
  145. </p>
  146. <h3 class="section">
  147. <a name="Overview"></a>
  148. Overview
  149. </h3>
  150. <p>The Antidote architecture design aims to provide a high level
  151. of modularity and extensibility. Ideally the components of
  152. Antidote will be able to be assembled in different configurations
  153. to provide the type of application or plug-in desired.
  154. </p>
  155. <p>To achieve this modularity, a high level of decoupling is
  156. necessary. The standard UI design approach of providing separation
  157. of view (presentation) from model (data) is applied, leveraging
  158. the built-in Ant data model where possible, as well as the
  159. predefined Swing model interfaces. Furthermore, the architecture
  160. is highly event driven, whereby modules communicate via a shared
  161. communications channel.
  162. </p>
  163. <p>To a large extent, the configuration of application modules is
  164. driven by localized configuration files, allowing new modules or
  165. data views to be added, as well as providing multi-language
  166. support.
  167. </p>
  168. <p>The diagram below conveys a high altitude view of the
  169. application's structure. As the application grows, new components
  170. will be plugged in to what will be described as the <code>EventBus</code>
  171. </p>
  172. <h3 class="section">
  173. <a name="Antidote Component Architecture/Event Bus"></a>
  174. Antidote Component Architecture/Event Bus
  175. </h3>
  176. <pre class="code">
  177. +---------------+ +----------------+ +-------------+ +-------------+
  178. | | | | | | | |
  179. | ActionManager | | EventResponder | | AntModule | | AntModule |
  180. | | | | |(ProjectNav) | |(SourceEdit) |
  181. +---------------+ +----------------+ +-------------+ +-------------+
  182. | ^ ^ ^
  183. | | | |
  184. ActionEvent EventObject AntEvent AntEvent
  185. | | | |
  186. v v v v
  187. /---------------------------------------------------------------------\
  188. / \
  189. &lt; EventBus &gt;
  190. \ /
  191. \---------------------------------------------------------------------/
  192. | ^ ^ ^
  193. | | | |
  194. EventObject ChangeEvent BuildEvent EventObject
  195. | | | |
  196. v | | v
  197. +---------------+ +----------------+ +-------------+ +--------------+
  198. | | | | | | | |
  199. | Console | | ProjectProxy | | Ant | | (Your Module)|
  200. | | | | | | | |
  201. +---------------+ +----------------+ +-------------+ +--------------+
  202. </pre>
  203. <p>The backbone of the application is the <TT>EventBus</TT>. Any
  204. component of the application can post events to the
  205. <code>EventBus</code>. Components that wish to receive events are
  206. called <code>BusMember</code>s.
  207. </p>
  208. <p>The <code>EventBus</code> will dispatch any object of type
  209. <code>java.util.Event</code>, which means that Ant <code>BuildEvent</code>
  210. objects, as well as <code>AWTEvent</code> objects can be posted (if desired). A
  211. new class of events called <code>AntEvent</code> is defined for Antidote
  212. specific events, which have the additional capability of being
  213. canceled mid-dispatch.
  214. </p>
  215. <p>Each <code>BusMember</code> must provide a <code>BusFilter</code> instance,
  216. which is the members' means of telling the bus which
  217. events it is interested in. This allows a <code>BusMember</code> to,
  218. say, only receive <code>AntEvent</code> objects.
  219. </p>
  220. <p>When a <code>BusMember</code> registers itself with the
  221. <code>EventBus</code>, it must provide a (so called) <i>interrupt
  222. level</i> which is a integer value defining a relative ordering
  223. for dispatching <code>EventObject</code>s to <code>BusMember</code>s. The
  224. purpose of this is to allow certain <code>BusMember</code> instances
  225. to see an event before others, and in the case of <code>AntEvent</code>
  226. objects, keep the event from propagating onward. The
  227. <code>EventBus</code> class defines the interrupt level constants
  228. <code>VETOING=1</code>, <code>MONITORING=5</code>, and <code>RESPONDING=10</code> to
  229. help define categories of members. The implied purpose being that:
  230. </p>
  231. <ul>
  232. <li><code>VETOING</code>: Listens for certain types of events, and
  233. may process them in a non-default manner to determine if the
  234. event should be canceled before being dispatched to the
  235. <code>RESPONDING</code> group.
  236. </li>
  237. <li><code>MONITORING</code>: Just listens for events, like a logger
  238. or status monitor.
  239. </li>
  240. <li><code>RESPONDING</code>: Process events in a default manner,
  241. knowing that the event has passed any <code>VETOING</code> members.
  242. </li>
  243. </ul>
  244. <p>Within a specific interrupt level, the order in which members will
  245. receive events is undefined. A <code>BusMember</code> may be registered
  246. at a level that is +/- of one of the defined levels, as long as it
  247. follows the constraint <code>MONITORING &lt;= interruptLevel &lt;=
  248. MAX_INTERRUPT</code>.
  249. </p>
  250. <h3 class="section">
  251. <a name="Actions and ActionManager"></a>
  252. Actions and ActionManager
  253. </h3>
  254. <p>Extensive use of the <code>javax.swing.Action</code> interface is
  255. made for defining the set of menu and tool bar options that are
  256. available. The configuration file <code>action.properties</code>
  257. exists to define what should appear in the menu and toolbar, how
  258. it is displayed, and the <code>Action</code> command name that is
  259. dispatched when the user invokes that action. A class called
  260. <code>ActionManager</code> exists for not only processing the
  261. configuration file, but also for dispatching invoked action events
  262. to the <code>EventBus</code>, and for controlling the enabled state of
  263. an <code>Action</code>. When a new menu item or toolbar button is
  264. desired, first it is added to the <code>action.properties</code> file,
  265. and then the code to respond to it is added to the
  266. <code>EventResponder</code> (see below).
  267. </p>
  268. <h3 class="section">
  269. <a name="Commands and EventResponder"></a>
  270. Commands and EventResponder
  271. </h3>
  272. <p>At some point in the stages of event processing, an event may
  273. require the data model to be modified, or some other task be
  274. performed. The <code>Command</code> interface is defined to classify
  275. code which performs some task or operation. This is distinct from
  276. an <code>Action</code>, which is a user request for an operation. A
  277. <code>Command</code> class is the encapsulation of the operation
  278. itself.
  279. </p>
  280. <p>When an <code>Action</code> generates an <code>ActionEvent</code>, the
  281. event is posted to the <code>EventBus</code> which delivers the event
  282. to all interested <code>BusMember</code>s. It eventually makes it to
  283. the <code>EventResponder</code> instance (registered at the
  284. <code>RESPONDING</code> interrupt level), which is responsible for
  285. translating specific events into <code>Command</code> objects, and
  286. then executing the <code>Command</code> object. For example, when the
  287. user selects the "Open..." menu option, an <code>ActionEvent</code> is
  288. generated by the Swing <code>MenuItem</code> class, which is then
  289. posted to the <code>EventBus</code> by the <code>ActionManager</code>. The
  290. <code>ActionEvent</code> is delivered to the <code>EventResponder</code>,
  291. which converts the <code>ActionEvent</code> into a <code>Command</code>
  292. instance. The <code>EventResponder</code> then calls the method
  293. <code>Command.execute()</code> to invoke the command (which displays a
  294. dialog for selecting a file to open).
  295. </p>
  296. <p>When adding new <code>Action</code>s or general tasks to the
  297. application, a <code>Command</code> object should be created to
  298. encapsulate the behavior. This includes most operations which
  299. modify the state of the data model.
  300. </p>
  301. <p>The purpose of this encapsulation is to allow the clean
  302. separation of making a request, and servicing a request. Due to
  303. various conditions in the application state, the actually response
  304. to a request may change, as well as who services it. This
  305. design approach facilitates that.
  306. </p>
  307. <h3 class="section">
  308. <a name="Data Model and Views"></a>
  309. Data Model and Views
  310. </h3>
  311. <p><i>NB: This part of the architecture is not fleshed out very well. There
  312. needs to be a discussion of the degree to which the Antidote development
  313. should be able to impose changes on the Ant data model, and to what level
  314. that model should be mirrored in the Antidote code base. The coupling
  315. between them should be kept low, and at the same time changes to one should
  316. affect the other minimally. Still, features like property change events and
  317. bean introspection (or BeanInfo) may be needed to be added to the Ant data
  318. model. Right now the data model is encapsulated in the package
  319. <code>org.apache.tools.ant.gui.acs</code> (where "<code>acs</code>" stands for "Ant Construction Set").</i>
  320. </p>
  321. <h3 class="section">
  322. <a name="Application Context"></a>
  323. Application Context
  324. </h3>
  325. <p>In order to keep the coupling among application modules to a
  326. minimum, a single point of reference is needed for coordination
  327. and data sharing. The class <code>AppContext</code> is the catch-all
  328. class for containing the application state. Most modules and
  329. <code>Command</code> classes require an instance of the
  330. <code>AppContext</code> class. Because all state information in
  331. contained in an <code>AppContext</code> instance, multiple instances
  332. of Antidote can run inside the same JVM as long as each has it's
  333. own <code>AppContext</code>. (Interestingly, two instances of the
  334. Antidote could conceivably share an <code>AppContext</code> instance
  335. through RMI, allowing remote interaction/collaboration.)
  336. </p>
  337. <h3 class="section">
  338. <a name="Configuration and ResourceManager"></a>
  339. Configuration and ResourceManager
  340. </h3>
  341. <p>Full "i18n" support should be assumed in modern applications,
  342. and all user viewable strings should be defined in a configuration
  343. file. For Antidote this configuration file is
  344. <code>antidote.properties</code>, which is located (with other UI
  345. resources) in the sub-package "resources".
  346. </p>
  347. <p>To aid in the lookup of text properties, as well as other
  348. resources like icons, a class called <code>ResourceManager</code> is
  349. defined. There are various convenience methods attached to this
  350. class, which will likely grow to make looking up configuration
  351. values as easy as possible.
  352. </p>
  353. <p>The organization of configuration properties is based on the
  354. fully qualified path of the class that requires the property. For
  355. example, the "about" box contains a messages, so it looks for the
  356. property "<code>org.apache.tools.ant.gui.About.message</code>" for the text
  357. message it should display. Therefore, the <code>ResourceManager</code>
  358. method <code>getString()</code> takes a <code>Class</code> instance as
  359. well as a <code>String</code> key. Please see the
  360. <code>ResourceManager</code> documentation for more information. Given
  361. this support, no user visible strings should appear in the source
  362. code itself.
  363. </p>
  364. </div>
  365. </td><td width="10"><img width="10" height="4" alt="" src="../../images/spacer.gif"></td>
  366. </tr>
  367. </table>
  368. </td>
  369. </tr>
  370. </table>
  371. <table summary="footer" cellspacing="0" cellpadding="0" width="100%" border="0">
  372. <tr>
  373. <td colspan="2" height="1" bgcolor="#4C6C8F"><img height="1" width="1" alt="" src="../../images/spacer.gif"><a href="../../images/label.gif"></a><a href="../../images/page.gif"></a><a href="../../images/chapter.gif"></a><a href="../../images/chapter_open.gif"></a><a href="../../images/current.gif"></a><a href="/favicon.ico"></a></td>
  374. </tr>
  375. <tr>
  376. <td colspan="2" bgcolor="#CFDCED" class="copyright" align="center"><font size="2" face="Arial, Helvetica, Sans-Serif">Copyright &copy; 2000-2003&nbsp;The Apache Software Foundation. All rights reserved.<script type="text/javascript" language="JavaScript"><!--
  377. document.write(" - "+"Last Published: " + document.lastModified);
  378. // --></script></font></td>
  379. </tr>
  380. </table>
  381. </body>
  382. </html>