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

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