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

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