You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

quickreference.xml 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <appendix id="quickreference" xreflabel="AspectJ Quick Reference">
  2. <title>AspectJ Quick Reference</title>
  3. <indexterm><primary>AspectJ</primary><secondary>semantics</secondary>
  4. <tertiary>quick reference</tertiary>
  5. </indexterm>
  6. <sect1>
  7. <title>Pointcut Designators</title>
  8. <table frame="all" id="qrpointcutdesignators">
  9. <title>Pointcut Designators</title>
  10. <tgroup cols="2" align="left">
  11. <colspec colname="c1"/>
  12. <colspec colname="c2"/>
  13. <spanspec spanname="hspan" namest="c1" nameend="c2" align="left"/>
  14. <tbody valign="middle">
  15. <row>
  16. <entry spanname="hspan">
  17. <emphasis role="bold">Methods and Constructors</emphasis>
  18. </entry>
  19. </row>
  20. <row>
  21. <entry>
  22. <literal>call(<replaceable>Signature</replaceable>)</literal>
  23. </entry>
  24. <entry>
  25. Method or constructor call join points when the signature
  26. matches <replaceable>Signature</replaceable>
  27. </entry>
  28. </row>
  29. <row>
  30. <entry>
  31. <literal>execution(<replaceable>Signature</replaceable>)</literal>
  32. </entry>
  33. <entry>
  34. Method or constructor execution join points when the
  35. signature matches
  36. <replaceable>Signature</replaceable>
  37. </entry>
  38. </row>
  39. <row>
  40. <entry>
  41. <literal>initialization(<replaceable>Signature</replaceable>)</literal>
  42. </entry>
  43. <entry>
  44. Object initialization join point when the first
  45. constructor called in the type matches
  46. <replaceable>Signature</replaceable>
  47. </entry>
  48. </row>
  49. <row>
  50. <entry spanname="hspan">
  51. <emphasis role="bold">Exception Handlers</emphasis>
  52. </entry>
  53. </row>
  54. <row rowsep="1">
  55. <entry>
  56. <literal>handler(<replaceable>TypePattern</replaceable>)</literal>
  57. </entry>
  58. <entry>
  59. Exception handler execution join points when
  60. try handlers for the throwable types in
  61. <replaceable>TypePattern</replaceable> are executed.
  62. The exception object can be accessed with an
  63. <literal>args</literal> pointcut.
  64. </entry>
  65. </row>
  66. <row>
  67. <entry spanname="hspan">
  68. <emphasis role="bold">Fields</emphasis>
  69. </entry>
  70. </row>
  71. <row>
  72. <entry>
  73. <literal>get(<replaceable>Signature</replaceable>)</literal>
  74. </entry>
  75. <entry>
  76. Field reference join points when the field matches
  77. <replaceable>Signature</replaceable>
  78. </entry>
  79. </row>
  80. <row>
  81. <entry>
  82. <literal>set(<replaceable>Signature</replaceable>)</literal>
  83. </entry>
  84. <entry>
  85. Field assignment join points when the field matches
  86. <replaceable>Signature</replaceable>. The new value
  87. can be accessed with an <literal>args</literal>
  88. pointcut.
  89. </entry>
  90. </row>
  91. <row>
  92. <entry spanname="hspan">
  93. <emphasis role="bold">Static Initializers</emphasis>
  94. </entry>
  95. </row>
  96. <row rowsep="1">
  97. <entry>
  98. <literal>staticinitialization(<replaceable>TypePattern</replaceable>)</literal>
  99. </entry>
  100. <entry>
  101. Static initializer execution join points for the types in
  102. <replaceable>TypePattern</replaceable>.
  103. </entry>
  104. </row>
  105. <row>
  106. <entry spanname="hspan">
  107. <emphasis role="bold">Objects</emphasis>
  108. </entry>
  109. </row>
  110. <row>
  111. <entry>
  112. <literal>this(<replaceable>TypePattern</replaceable>)</literal>
  113. </entry>
  114. <entry>
  115. Join points when the currently executing object is an
  116. instance of a type in <replaceable>TypePattern</replaceable>
  117. </entry>
  118. </row>
  119. <row>
  120. <entry>
  121. <literal>target(<replaceable>TypePattern</replaceable>)</literal>
  122. </entry>
  123. <entry>
  124. Join points when the target object is an instance
  125. of a type in <replaceable>TypePattern</replaceable>
  126. </entry>
  127. </row>
  128. <row>
  129. <entry>
  130. <literal>args(<replaceable>TypePattern</replaceable>, ...)</literal>
  131. </entry>
  132. <entry>
  133. Join points when the argument objects are instances of
  134. the <replaceable>TypePattern</replaceable>s
  135. </entry>
  136. </row>
  137. <!--
  138. <row rowsep="1">
  139. <entry>
  140. <literal>hasaspect(<replaceable>TypePattern</replaceable>)</literal>
  141. </entry>
  142. <entry>
  143. Join points where an aspect instance of a type in
  144. <replaceable>TypePattern</replaceable> is associated
  145. with the join point
  146. </entry>
  147. </row>
  148. -->
  149. <row>
  150. <entry spanname="hspan">
  151. <emphasis role="bold">Lexical Extents</emphasis>
  152. </entry>
  153. </row>
  154. <row>
  155. <entry>
  156. <literal>within(<replaceable>TypePattern</replaceable>)</literal>
  157. </entry>
  158. <entry>
  159. Join points when the code executing is defined in the
  160. types in <replaceable>TypePattern</replaceable>
  161. </entry>
  162. </row>
  163. <row>
  164. <entry>
  165. <literal>withincode(<replaceable>Signature</replaceable>)</literal>
  166. </entry>
  167. <entry>
  168. Join points when the code executing is defined in the
  169. method or constructor with signature
  170. <replaceable>Signature</replaceable>
  171. </entry>
  172. </row>
  173. <row>
  174. <entry spanname="hspan">
  175. <emphasis role="bold">Control Flow</emphasis>
  176. </entry>
  177. </row>
  178. <row>
  179. <entry>
  180. <literal>cflow(<replaceable>Pointcut</replaceable>)</literal>
  181. </entry>
  182. <entry>
  183. Join points in the control flow of the join points
  184. specified by <replaceable>Pointcut</replaceable>
  185. </entry>
  186. </row>
  187. <row>
  188. <entry>
  189. <literal>cflowbelow(<replaceable>Pointcut</replaceable>)</literal>
  190. </entry>
  191. <entry>
  192. Join points in the control flow below the join points
  193. specified by <replaceable>Pointcut</replaceable>
  194. </entry>
  195. </row>
  196. <row>
  197. <entry spanname="hspan">
  198. <emphasis role="bold">Conditional</emphasis>
  199. </entry>
  200. </row>
  201. <row>
  202. <entry>
  203. <literal>if(<replaceable>Expression</replaceable>)</literal>
  204. </entry>
  205. <entry>
  206. Join points when the boolean
  207. <replaceable>Expression</replaceable> evaluates
  208. to <literal>true</literal>
  209. </entry>
  210. </row>
  211. <row>
  212. <entry spanname="hspan">
  213. <emphasis role="bold">Combination</emphasis>
  214. </entry>
  215. </row>
  216. <row>
  217. <entry>
  218. <literal>! <replaceable>Pointcut</replaceable></literal>
  219. </entry>
  220. <entry>
  221. Join points that are not picked out by
  222. <replaceable>Pointcut</replaceable>
  223. </entry>
  224. </row>
  225. <row>
  226. <entry>
  227. <literal><replaceable>Pointcut0</replaceable> <![CDATA[&&]]> <replaceable>Pointcut1</replaceable></literal>
  228. </entry>
  229. <entry>
  230. Join points that are picked out by both
  231. <replaceable>Pointcut0</replaceable> and
  232. <replaceable>Pointcut1</replaceable>
  233. </entry>
  234. </row>
  235. <row>
  236. <entry>
  237. <literal><replaceable>Pointcut0</replaceable> || <replaceable>Pointcut1</replaceable></literal>
  238. </entry>
  239. <entry>
  240. Join points that are picked out by either
  241. <replaceable>Pointcut0</replaceable> or
  242. <replaceable>Pointcut1</replaceable>
  243. </entry>
  244. </row>
  245. <row>
  246. <entry>
  247. <literal>( <replaceable>Pointcut</replaceable> )</literal>
  248. </entry>
  249. <entry>
  250. Join points that are picked out by the parenthesized
  251. <replaceable>Pointcut</replaceable>
  252. </entry>
  253. </row>
  254. </tbody>
  255. </tgroup>
  256. </table>
  257. </sect1>
  258. <sect1>
  259. <title>Type Patterns</title>
  260. <para>
  261. </para>
  262. <table frame="all" id="qrtypenamepatterns">
  263. <title>Type Name Patterns</title>
  264. <tgroup cols="2" colsep="1" rowsep="0">
  265. <tbody>
  266. <row>
  267. <entry><literal>*</literal> alone</entry>
  268. <entry>all types</entry>
  269. </row>
  270. <row>
  271. <entry><literal>*</literal> in an identifier</entry>
  272. <entry>any sequence of characters, not including "."</entry>
  273. </row>
  274. <row>
  275. <entry><literal>..</literal> in an identifier</entry>
  276. <entry>any sequence of characters starting and ending
  277. with "."</entry>
  278. </row>
  279. </tbody>
  280. </tgroup>
  281. </table>
  282. <para>
  283. The + wildcard can be appended to a type name pattern to
  284. indicate all subtypes.
  285. </para>
  286. <para>
  287. Any number of []s can be put on a type name or subtype pattern
  288. to indicate array types.
  289. </para>
  290. <table frame="all" id="qrtypepatterns">
  291. <title>Type Patterns</title>
  292. <tgroup cols="2" colsep="1" rowsep="0">
  293. <tbody>
  294. <row>
  295. <entry><replaceable>TypeNamePattern</replaceable></entry>
  296. <entry>all types in <replaceable>TypeNamePattern</replaceable></entry>
  297. </row>
  298. <row>
  299. <entry><replaceable>SubtypePattern</replaceable></entry>
  300. <entry>all types in <replaceable>SubtypePattern</replaceable>, a
  301. pattern with a +. </entry>
  302. </row>
  303. <row>
  304. <entry><replaceable>ArrayTypePattern</replaceable></entry>
  305. <entry>all types in <replaceable>ArrayTypePattern</replaceable>,
  306. a pattern with one or more []s. </entry>
  307. </row>
  308. <row>
  309. <entry><literal>!<replaceable>TypePattern</replaceable></literal></entry>
  310. <entry>all types not in <replaceable>TypePattern</replaceable></entry>
  311. </row>
  312. <row>
  313. <entry><literal><replaceable>TypePattern0</replaceable>
  314. <![CDATA[&&]]> <replaceable>TypePattern1</replaceable></literal></entry>
  315. <entry>all types in both
  316. <replaceable>TypePattern0</replaceable> and <replaceable>TypePattern1</replaceable></entry>
  317. </row>
  318. <row>
  319. <entry><literal><replaceable>TypePattern0</replaceable> || <replaceable>TypePattern1</replaceable></literal></entry>
  320. <entry>all types in either
  321. <replaceable>TypePattern0</replaceable> or <replaceable>TypePattern1</replaceable></entry>
  322. </row>
  323. <row>
  324. <entry><literal>( <replaceable>TypePattern</replaceable> )</literal></entry>
  325. <entry>all types in <replaceable>TypePattern</replaceable></entry>
  326. </row>
  327. </tbody>
  328. </tgroup>
  329. </table>
  330. </sect1>
  331. <sect1>
  332. <title>Advice</title>
  333. <para></para>
  334. <table frame="all" id="qradvice">
  335. <title>Advice</title>
  336. <tgroup cols="2" colsep="1" rowsep="0">
  337. <tbody>
  338. <row>
  339. <entry>
  340. <literal>before(<replaceable>Formals</replaceable>) : </literal>
  341. </entry>
  342. <entry>
  343. Run before the join point.
  344. </entry>
  345. </row>
  346. <row>
  347. <entry>
  348. <literal>after(<replaceable>Formals</replaceable>) returning
  349. [ (<replaceable>Formal</replaceable>) ] : </literal>
  350. </entry>
  351. <entry>
  352. Run after the join point if it returns normally. The
  353. optional formal gives access to the returned value.
  354. </entry>
  355. </row>
  356. <row>
  357. <entry>
  358. <literal>after(<replaceable>Formals</replaceable>) throwing [
  359. (<replaceable>Formal</replaceable>) ] : </literal>
  360. </entry>
  361. <entry>
  362. Run after the join point if it throws an exception. The
  363. optional formal gives access to the
  364. <literal>Throwable</literal> exception value.
  365. </entry>
  366. </row>
  367. <row>
  368. <entry>
  369. <literal>after(<replaceable>Formals</replaceable>) : </literal>
  370. </entry>
  371. <entry>
  372. Run after the join point both when it returns normally and
  373. when it throws an exception.
  374. </entry>
  375. </row>
  376. <row>
  377. <entry>
  378. <literal><replaceable>Type</replaceable>
  379. around(<replaceable>Formals</replaceable>) [ throws
  380. <replaceable>TypeList</replaceable> ] :</literal>
  381. </entry>
  382. <entry>
  383. Run instead of the join point. The join point can be
  384. executed by calling <literal>proceed</literal>.
  385. </entry>
  386. </row>
  387. </tbody>
  388. </tgroup>
  389. </table>
  390. </sect1>
  391. <sect1>
  392. <title>Static Crosscutting</title>
  393. <para></para>
  394. <table frame="all" id="qrintroduction">
  395. <title>Introduction</title>
  396. <tgroup cols="2" colsep="1" rowsep="0">
  397. <tbody>
  398. <row>
  399. <entry>
  400. <replaceable>Modifiers Type TypePattern.Id(Formals) { Body }</replaceable>
  401. </entry>
  402. <entry>
  403. Defines a method on the types in <replaceable>TypePattern</replaceable>.
  404. </entry>
  405. </row>
  406. <row>
  407. <entry>
  408. <literal>abstract <replaceable>Modifiers Type TypePattern.Id(Formals)</replaceable>;</literal>
  409. </entry>
  410. <entry>
  411. Defines an abstract method on the types in <replaceable>TypePattern</replaceable>.
  412. </entry>
  413. </row>
  414. <row>
  415. <entry>
  416. <literal><replaceable>Modifiers TypePattern</replaceable>.new<replaceable>(Formals) { Body }</replaceable></literal>
  417. </entry>
  418. <entry>
  419. Defines a a constructor on the types in <replaceable>TypePattern</replaceable>.
  420. </entry>
  421. </row>
  422. <row>
  423. <entry>
  424. <replaceable>Modifiers Type TypePattern.Id [ = Expression ];</replaceable>
  425. </entry>
  426. <entry>
  427. Defines a field on the types in <replaceable>TypePattern</replaceable>.
  428. </entry>
  429. </row>
  430. </tbody>
  431. </tgroup>
  432. </table>
  433. <table frame="all" id="qrotherdeclarations">
  434. <title>Other declarations</title>
  435. <tgroup cols="2" colsep="1" rowsep="0">
  436. <tbody>
  437. <row>
  438. <entry>
  439. <literal>declare parents: <replaceable>TypePattern</replaceable> extends <replaceable>TypeList</replaceable>;</literal>
  440. </entry>
  441. <entry>
  442. Declares that the types in <replaceable>TypePattern</replaceable> extend the types of <replaceable>TypeList</replaceable>.
  443. </entry>
  444. </row>
  445. <row>
  446. <entry>
  447. <literal>declare parents: <replaceable>TypePattern</replaceable> implements <replaceable>TypeList</replaceable>;</literal>
  448. </entry>
  449. <entry>
  450. Declares that the types in <replaceable>TypePattern</replaceable> implement the types of <replaceable>TypeList</replaceable>.
  451. </entry>
  452. </row>
  453. <row>
  454. <entry>
  455. <literal>declare warning: <replaceable>Pointcut</replaceable>: <replaceable>String</replaceable>;</literal>
  456. </entry>
  457. <entry>
  458. Declares that if any of the join points in
  459. <replaceable>Pointcut</replaceable> possibly exist in
  460. the program, the compiler should emit a warning of
  461. <replaceable>String</replaceable>.
  462. </entry>
  463. </row>
  464. <row>
  465. <entry>
  466. <literal>declare error: <replaceable>Pointcut</replaceable>: <replaceable>String</replaceable>;</literal>
  467. </entry>
  468. <entry>
  469. Declares that if any of the join points in
  470. <replaceable>Pointcut</replaceable> possibly exist in
  471. the program, the compiler should emit an error of
  472. <replaceable>String</replaceable>.
  473. </entry>
  474. </row>
  475. <row>
  476. <entry>
  477. <literal>declare soft:
  478. <replaceable>TypePattern</replaceable>:
  479. <replaceable>Pointcut</replaceable>; </literal>
  480. </entry>
  481. <entry>
  482. Declares that any exception of a type in
  483. <replaceable>TypePattern</replaceable> that gets
  484. thrown at any join point picked out by
  485. <replaceable>Pointcut</replaceable> will be wrapped in
  486. <literal>org.aspectj.lang.SoftException</literal>.
  487. </entry>
  488. </row>
  489. </tbody>
  490. </tgroup>
  491. </table>
  492. </sect1>
  493. <sect1>
  494. <title>Aspect Associations</title>
  495. <para>
  496. </para>
  497. <table frame="all" id="qrassociations">
  498. <title>Associations</title>
  499. <tgroup cols="3" align="left" colsep="1" rowsep="1">
  500. <thead>
  501. <row>
  502. <entry>modifier</entry>
  503. <entry>Description</entry>
  504. <entry>Accessor</entry>
  505. </row>
  506. </thead>
  507. <tbody>
  508. <row>
  509. <entry>
  510. [ <literal>issingleton</literal> ]
  511. </entry>
  512. <entry>
  513. One instance of the aspect is made. This is
  514. the default.
  515. </entry>
  516. <entry>
  517. <literal>aspectOf()</literal> at all join points
  518. </entry>
  519. </row>
  520. <row>
  521. <entry>
  522. <literal>perthis(<replaceable>Pointcut</replaceable>)</literal>
  523. </entry>
  524. <entry>
  525. An instance is associated with each object that is the
  526. currently executing object at any join point in
  527. <replaceable>Pointcut</replaceable>.
  528. </entry>
  529. <entry>
  530. <literal>aspectOf(Object)</literal> at all join points</entry>
  531. </row>
  532. <row>
  533. <entry>
  534. <literal>pertarget(<replaceable>Pointcut</replaceable>)</literal>
  535. </entry>
  536. <entry>
  537. An instance is associated with each object that is the
  538. target object at any join point in
  539. <replaceable>Pointcut</replaceable>.
  540. </entry>
  541. <entry>
  542. <literal>aspectOf(Object)</literal> at all join points</entry>
  543. </row>
  544. <row>
  545. <entry>
  546. <literal>percflow(<replaceable>Pointcut</replaceable>)</literal>
  547. </entry>
  548. <entry>
  549. The aspect is defined for each entrance to the control flow of
  550. the join points defined by <replaceable>Pointcut</replaceable>. </entry>
  551. <entry>
  552. <literal>aspectOf()</literal> at join points in
  553. <literal>cflow(<replaceable>Pointcut</replaceable>)</literal>
  554. </entry>
  555. </row>
  556. <row>
  557. <entry>
  558. <literal>percflowbelow(<replaceable>Pointcut</replaceable>)</literal>
  559. </entry>
  560. <entry>
  561. The aspect is defined for each entrance to the control flow
  562. below the join points defined by <replaceable>Pointcut</replaceable>.
  563. </entry>
  564. <entry>
  565. <literal>aspectOf()</literal> at join points in
  566. <literal>cflowbelow(<replaceable>Pointcut</replaceable>)</literal>
  567. </entry>
  568. </row>
  569. </tbody>
  570. </tgroup>
  571. </table>
  572. </sect1>
  573. </appendix>
  574. <!-- Local variables: -->
  575. <!-- fill-column: 79 -->
  576. <!-- sgml-local-ecat-files: progguide.ced -->
  577. <!-- sgml-parent-document:("progguide.sgml" "book" "appendix") -->
  578. <!-- End: -->