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 25 kB

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