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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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. <table class="title">
  135. <tr>
  136. <td valign="middle">
  137. <h1>Design Overview</h1>
  138. </td>
  139. </tr>
  140. </table>
  141. <h3 class="section">
  142. <a name="Introduction"></a>
  143. Introduction
  144. </h3>
  145. <p>The purpose of this document is to communicate the overall
  146. structure and design patters used in Antidote, the GUI for
  147. Ant. This document is a work in progress, as well as a living
  148. document, and it is most likely not be in full synchronization with
  149. the source code. Therefore, if there is any doubt, view the source
  150. ;-)
  151. </p>
  152. <h3 class="section">
  153. <a name="Overview"></a>
  154. Overview
  155. </h3>
  156. <p>The Antidote architecture design aims to provide a high level
  157. of modularity and extensibility. Ideally the components of
  158. Antidote will be able to be assembled in different configurations
  159. to provide the type of application or plug-in desired.
  160. </p>
  161. <p>To achieve this modularity, a high level of decoupling is
  162. necessary. The standard UI design approach of providing separation
  163. of view (presentation) from model (data) is applied, leveraging
  164. the built-in Ant data model where possible, as well as the
  165. predefined Swing model interfaces. Furthermore, the architecture
  166. is highly event driven, whereby modules communicate via a shared
  167. communications channel.
  168. </p>
  169. <p>To a large extent, the configuration of application modules is
  170. driven by localized configuration files, allowing new modules or
  171. data views to be added, as well as providing multi-language
  172. support.
  173. </p>
  174. <p>The diagram below conveys a high altitude view of the
  175. application's structure. As the application grows, new components
  176. will be plugged in to what will be described as the <code>EventBus</code>
  177. </p>
  178. <h3 class="section">
  179. <a name="Antidote Component Architecture/Event Bus"></a>
  180. Antidote Component Architecture/Event Bus
  181. </h3>
  182. <pre class="code">
  183. +---------------+ +----------------+ +-------------+ +-------------+
  184. | | | | | | | |
  185. | ActionManager | | EventResponder | | AntModule | | AntModule |
  186. | | | | |(ProjectNav) | |(SourceEdit) |
  187. +---------------+ +----------------+ +-------------+ +-------------+
  188. | ^ ^ ^
  189. | | | |
  190. ActionEvent EventObject AntEvent AntEvent
  191. | | | |
  192. v v v v
  193. /---------------------------------------------------------------------\
  194. / \
  195. &lt; EventBus &gt;
  196. \ /
  197. \---------------------------------------------------------------------/
  198. | ^ ^ ^
  199. | | | |
  200. EventObject ChangeEvent BuildEvent EventObject
  201. | | | |
  202. v | | v
  203. +---------------+ +----------------+ +-------------+ +--------------+
  204. | | | | | | | |
  205. | Console | | ProjectProxy | | Ant | | (Your Module)|
  206. | | | | | | | |
  207. +---------------+ +----------------+ +-------------+ +--------------+
  208. </pre>
  209. <p>The backbone of the application is the <TT>EventBus</TT>. Any
  210. component of the application can post events to the
  211. <code>EventBus</code>. Components that wish to receive events are
  212. called <code>BusMember</code>s.
  213. </p>
  214. <p>The <code>EventBus</code> will dispatch any object of type
  215. <code>java.util.Event</code>, which means that Ant <code>BuildEvent</code>
  216. objects, as well as <code>AWTEvent</code> objects can be posted (if desired). A
  217. new class of events called <code>AntEvent</code> is defined for Antidote
  218. specific events, which have the additional capability of being
  219. canceled mid-dispatch.
  220. </p>
  221. <p>Each <code>BusMember</code> must provide a <code>BusFilter</code> instance,
  222. which is the members' means of telling the bus which
  223. events it is interested in. This allows a <code>BusMember</code> to,
  224. say, only receive <code>AntEvent</code> objects.
  225. </p>
  226. <p>When a <code>BusMember</code> registers itself with the
  227. <code>EventBus</code>, it must provide a (so called) <i>interrupt
  228. level</i> which is a integer value defining a relative ordering
  229. for dispatching <code>EventObject</code>s to <code>BusMember</code>s. The
  230. purpose of this is to allow certain <code>BusMember</code> instances
  231. to see an event before others, and in the case of <code>AntEvent</code>
  232. objects, keep the event from propagating onward. The
  233. <code>EventBus</code> class defines the interrupt level constants
  234. <code>VETOING=1</code>, <code>MONITORING=5</code>, and <code>RESPONDING=10</code> to
  235. help define categories of members. The implied purpose being that:
  236. </p>
  237. <ul>
  238. <li><code>VETOING</code>: Listens for certain types of events, and
  239. may process them in a non-default manner to determine if the
  240. event should be canceled before being dispatched to the
  241. <code>RESPONDING</code> group.
  242. </li>
  243. <li><code>MONITORING</code>: Just listens for events, like a logger
  244. or status monitor.
  245. </li>
  246. <li><code>RESPONDING</code>: Process events in a default manner,
  247. knowing that the event has passed any <code>VETOING</code> members.
  248. </li>
  249. </ul>
  250. <p>Within a specific interrupt level, the order in which members will
  251. receive events is undefined. A <code>BusMember</code> may be registered
  252. at a level that is +/- of one of the defined levels, as long as it
  253. follows the constraint <code>MONITORING &lt;= interruptLevel &lt;=
  254. MAX_INTERRUPT</code>.
  255. </p>
  256. <h3 class="section">
  257. <a name="Actions and ActionManager"></a>
  258. Actions and ActionManager
  259. </h3>
  260. <p>Extensive use of the <code>javax.swing.Action</code> interface is
  261. made for defining the set of menu and tool bar options that are
  262. available. The configuration file <code>action.properties</code>
  263. exists to define what should appear in the menu and toolbar, how
  264. it is displayed, and the <code>Action</code> command name that is
  265. dispatched when the user invokes that action. A class called
  266. <code>ActionManager</code> exists for not only processing the
  267. configuration file, but also for dispatching invoked action events
  268. to the <code>EventBus</code>, and for controlling the enabled state of
  269. an <code>Action</code>. When a new menu item or toolbar button is
  270. desired, first it is added to the <code>action.properties</code> file,
  271. and then the code to respond to it is added to the
  272. <code>EventResponder</code> (see below).
  273. </p>
  274. <h3 class="section">
  275. <a name="Commands and EventResponder"></a>
  276. Commands and EventResponder
  277. </h3>
  278. <p>At some point in the stages of event processing, an event may
  279. require the data model to be modified, or some other task be
  280. performed. The <code>Command</code> interface is defined to classify
  281. code which performs some task or operation. This is distinct from
  282. an <code>Action</code>, which is a user request for an operation. A
  283. <code>Command</code> class is the encapsulation of the operation
  284. itself.
  285. </p>
  286. <p>When an <code>Action</code> generates an <code>ActionEvent</code>, the
  287. event is posted to the <code>EventBus</code> which delivers the event
  288. to all interested <code>BusMember</code>s. It eventually makes it to
  289. the <code>EventResponder</code> instance (registered at the
  290. <code>RESPONDING</code> interrupt level), which is responsible for
  291. translating specific events into <code>Command</code> objects, and
  292. then executing the <code>Command</code> object. For example, when the
  293. user selects the "Open..." menu option, an <code>ActionEvent</code> is
  294. generated by the Swing <code>MenuItem</code> class, which is then
  295. posted to the <code>EventBus</code> by the <code>ActionManager</code>. The
  296. <code>ActionEvent</code> is delivered to the <code>EventResponder</code>,
  297. which converts the <code>ActionEvent</code> into a <code>Command</code>
  298. instance. The <code>EventResponder</code> then calls the method
  299. <code>Command.execute()</code> to invoke the command (which displays a
  300. dialog for selecting a file to open).
  301. </p>
  302. <p>When adding new <code>Action</code>s or general tasks to the
  303. application, a <code>Command</code> object should be created to
  304. encapsulate the behavior. This includes most operations which
  305. modify the state of the data model.
  306. </p>
  307. <p>The purpose of this encapsulation is to allow the clean
  308. separation of making a request, and servicing a request. Due to
  309. various conditions in the application state, the actually response
  310. to a request may change, as well as who services it. This
  311. design approach facilitates that.
  312. </p>
  313. <h3 class="section">
  314. <a name="Data Model and Views"></a>
  315. Data Model and Views
  316. </h3>
  317. <p><i>NB: This part of the architecture is not fleshed out very well. There
  318. needs to be a discussion of the degree to which the Antidote development
  319. should be able to impose changes on the Ant data model, and to what level
  320. that model should be mirrored in the Antidote code base. The coupling
  321. between them should be kept low, and at the same time changes to one should
  322. affect the other minimally. Still, features like property change events and
  323. bean introspection (or BeanInfo) may be needed to be added to the Ant data
  324. model. Right now the data model is encapsulated in the package
  325. <code>org.apache.tools.ant.gui.acs</code> (where "<code>acs</code>" stands for "Ant Construction Set").</i>
  326. </p>
  327. <h3 class="section">
  328. <a name="Application Context"></a>
  329. Application Context
  330. </h3>
  331. <p>In order to keep the coupling among application modules to a
  332. minimum, a single point of reference is needed for coordination
  333. and data sharing. The class <code>AppContext</code> is the catch-all
  334. class for containing the application state. Most modules and
  335. <code>Command</code> classes require an instance of the
  336. <code>AppContext</code> class. Because all state information in
  337. contained in an <code>AppContext</code> instance, multiple instances
  338. of Antidote can run inside the same JVM as long as each has it's
  339. own <code>AppContext</code>. (Interestingly, two instances of the
  340. Antidote could conceivably share an <code>AppContext</code> instance
  341. through RMI, allowing remote interaction/collaboration.)
  342. </p>
  343. <h3 class="section">
  344. <a name="Configuration and ResourceManager"></a>
  345. Configuration and ResourceManager
  346. </h3>
  347. <p>Full "i18n" support should be assumed in modern applications,
  348. and all user viewable strings should be defined in a configuration
  349. file. For Antidote this configuration file is
  350. <code>antidote.properties</code>, which is located (with other UI
  351. resources) in the sub-package "resources".
  352. </p>
  353. <p>To aid in the lookup of text properties, as well as other
  354. resources like icons, a class called <code>ResourceManager</code> is
  355. defined. There are various convenience methods attached to this
  356. class, which will likely grow to make looking up configuration
  357. values as easy as possible.
  358. </p>
  359. <p>The organization of configuration properties is based on the
  360. fully qualified path of the class that requires the property. For
  361. example, the "about" box contains a messages, so it looks for the
  362. property "<code>org.apache.tools.ant.gui.About.message</code>" for the text
  363. message it should display. Therefore, the <code>ResourceManager</code>
  364. method <code>getString()</code> takes a <code>Class</code> instance as
  365. well as a <code>String</code> key. Please see the
  366. <code>ResourceManager</code> documentation for more information. Given
  367. this support, no user visible strings should appear in the source
  368. code itself.
  369. </p>
  370. </div>
  371. </td><td width="10"><img width="10" height="4" alt="" src="../../images/spacer.gif"></td>
  372. </tr>
  373. </table>
  374. </td>
  375. </tr>
  376. </table>
  377. <table summary="footer" cellspacing="0" cellpadding="0" width="100%" border="0">
  378. <tr>
  379. <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>
  380. </tr>
  381. <tr>
  382. <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"><!--
  383. document.write(" - "+"Last Published: " + document.lastModified);
  384. // --></script></font></td>
  385. </tr>
  386. </table>
  387. </body>
  388. </html>