aboutsummaryrefslogtreecommitdiffstats
path: root/docs/progGuideDB/idioms.xml
diff options
context:
space:
mode:
authorehilsdal <ehilsdal>2003-04-08 21:59:39 +0000
committerehilsdal <ehilsdal>2003-04-08 21:59:39 +0000
commite2af842ae7dbf3b0315a5f73d3d5ec9b7f041556 (patch)
treea4e993a588298b0d6babdf643de8d35991a2ebd6 /docs/progGuideDB/idioms.xml
parentf11709f8bc26a053ff573039cc0b5ee887c005ff (diff)
downloadaspectj-e2af842ae7dbf3b0315a5f73d3d5ec9b7f041556.tar.gz
aspectj-e2af842ae7dbf3b0315a5f73d3d5ec9b7f041556.zip
folded in material from README-11.html
finally totally and completely stomped out "introduction" minor formatting changes generating better filenames for the progguide added A4 version of quick reference
Diffstat (limited to 'docs/progGuideDB/idioms.xml')
-rw-r--r--docs/progGuideDB/idioms.xml70
1 files changed, 20 insertions, 50 deletions
diff --git a/docs/progGuideDB/idioms.xml b/docs/progGuideDB/idioms.xml
index 5898dbd9e..c6297c90b 100644
--- a/docs/progGuideDB/idioms.xml
+++ b/docs/progGuideDB/idioms.xml
@@ -1,17 +1,20 @@
<chapter id="idioms" xreflabel="Idioms">
<title>Idioms</title>
- <sect1><!-- About this Chapter -->
- <title>About this Chapter</title>
+ <sect1 id="idioms-intro">
+ <title>Introduction</title>
- <para>This chapter consists of very short snippets of AspectJ code,
- typically pointcuts, that are particularly evocative or useful.
- This section is a work in progress.
+ <para>
+ This chapter consists of very short snippets of AspectJ code,
+ typically pointcuts, that are particularly evocative or useful.
+ This section is a work in progress.
</para>
- <para> Here's an example of how to enfore a rule that code in the java.sql
- package can only be used from one particular package in your system. This
- doesn't require any access to code in the java.sql package.
+ <para>
+ Here's an example of how to enfore a rule that code in the
+ java.sql package can only be used from one particular package in
+ your system. This doesn't require any access to code in the
+ java.sql package.
</para>
<programlisting><![CDATA[
@@ -19,7 +22,7 @@
pointcut restrictedCall():
call(* java.sql.*.*(..)) || call(java.sql.*.new(..));
-/* Any code in my system not in the sqlAccess package */
+/* Any code in my system not in the sqlAccess package */
pointcut illegalSource():
within(com.foo..*) && !within(com.foo.sqlAccess.*);
@@ -31,9 +34,9 @@ declare error: restrictedCall() && illegalSource():
not exactly equal to AbstractFacade:</para>
<programlisting><![CDATA[
-pointcut nonAbstract(AbstractFacade af):
- call(* *(..))
- && target(af)
+pointcut nonAbstract(AbstractFacade af):
+ call(* *(..))
+ && target(af)
&& !if(af.getClass() == AbstractFacade.class);
]]></programlisting>
@@ -42,7 +45,7 @@ pointcut nonAbstract(AbstractFacade af):
<programlisting><![CDATA[
pointcut nonAbstract(AbstractFacade af):
- call(* *(..))
+ call(* *(..))
&& target(af);
]]></programlisting>
@@ -51,8 +54,8 @@ pointcut nonAbstract(AbstractFacade af):
</para>
<programlisting><![CDATA[
-pointcut callToUndefinedMethod():
- call(* AbstractFacade+.*(..))
+pointcut callToUndefinedMethod():
+ call(* AbstractFacade+.*(..))
&& !call(* AbstractFacade.*(..));
]]></programlisting>
@@ -62,43 +65,10 @@ pointcut callToUndefinedMethod():
<programlisting><![CDATA[
pointcut executionOfUndefinedMethod():
- execution(* *(..))
- && within(AbstractFacade+)
+ execution(* *(..))
+ && within(AbstractFacade+)
&& !within(AbstractFacade)
]]></programlisting>
- <para>To use a per-class variable declared on many classes,
- you can defer initialization until you are in a non-static instance context
- so you can refer to the particular class member. If you want to use
- it from advice (without knowing the particular class at compile-time),
- you can declare a method on the type.
- </para>
-
-<programlisting><![CDATA[
-aspect Logging {
-
- //...
-
- /** per-Loggable-class reference to per-class Logger */
- static private Logger Loggable+.staticLogger;
-
- /** instance getter for static logger (lazy construction) */
- public Logger Loggable+.getLogger() { // XXX make private to aspect?
- if (null == staticLogger) {
- staticLogger = Logger.getLoggerFor(getClass());
- }
- return staticLogger;
- }
-
- /** when logging and logger enabled, log the target and join point */
- before(Loggable loggable) : target(loggable) && logging() {
- Logger logger = loggable.getLogger();
- if (logger.enabled()) {
- logger.log(loggable + " at " + thisJoinPoint);
- }
- }
-}
-]]></programlisting>
-
</sect1>
</chapter>