diff options
author | acolyer <acolyer> | 2005-03-09 11:16:11 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-03-09 11:16:11 +0000 |
commit | ef868243d36ab20062e7aae6828bc17987a018a5 (patch) | |
tree | f0677d0cc6518402b66730f52d42553b41121cda /docs/adk15ProgGuideDB | |
parent | 3bb1ffe98ec0b6dacf9440998f5db1103ca05e85 (diff) | |
download | aspectj-ef868243d36ab20062e7aae6828bc17987a018a5.tar.gz aspectj-ef868243d36ab20062e7aae6828bc17987a018a5.zip |
fixes in annotation docs uncovered through testing
Diffstat (limited to 'docs/adk15ProgGuideDB')
-rw-r--r-- | docs/adk15ProgGuideDB/annotations.xml | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/docs/adk15ProgGuideDB/annotations.xml b/docs/adk15ProgGuideDB/annotations.xml index 2a0d02d54..d7abfe0af 100644 --- a/docs/adk15ProgGuideDB/annotations.xml +++ b/docs/adk15ProgGuideDB/annotations.xml @@ -213,29 +213,39 @@ public abstract aspect ObserverProtocol { @InterfaceAnnotation + interface Observer {} + + @InterfaceAnnotation interface Subject {} @ITDFieldAnnotation - private List Subject.observers; + private List<Observer> Subject.observers; @ITDMethodAnnotation - public void Subject.addObserver() { ... } + public void Subject.addObserver(Observer o) { + observers.add(o); + } @ITDMethodAnnotation - public void Subject.removeObserver() { ... } + public void Subject.removeObserver(Observer o) { + observers.remove(o); + } @MethodAnnotation - private void notifyObservers(Subject subject) { ... } + private void notifyObservers(Subject subject) { + for(Observer o : subject.observers) + notifyObserver(o,subject); + } /** * Delegate to concrete sub-aspect the actual form of - * notification for a given type of Subject. + * notification for a given type of Observer. */ @MethodAnnotation - protected abstract void notifySubject(Subject s); + protected abstract void notifyObserver(Observer o, Subject s); /* no annotations on pointcuts */ - abstract pointcut observedEvent(Subject subject); + protected abstract pointcut observedEvent(Subject subject); @AdviceAnnotation after(Subject subject) returning : observedEvent(subject) { @@ -255,10 +265,32 @@ will be emitted by the compiler if the pointcut expression associated with an advice statement can be statically determined to not match any join points. The warning can be suppressed for an individual advice statement by using the - <literal>@SuppressAjWarnings({"unmatched"})</literal> annotation. This works in + <literal>@SuppressAjWarnings({"adviceDidNotMatch"})</literal> annotation. This works in the same way as the Java 5 SuppressWarnings annotation (See JLS 9.6.1.5), but has class file retention. </para> + + <programlisting><![CDATA[ + import org.aspectj.lang.annotation.SuppressAjWarnings; + + public aspect AnAspect { + + pointcut anInterfaceOperation() : execution(* AnInterface.*(..)); + + + @SuppressAjWarnings // may not match if there are no implementers of the interface... + before() : anInterfaceOperation() { + // do something... + } + + @SuppressAjWarnings("adviceDidNotMatch") // alternate form + after() returning : anInterfaceOperation() { + // do something... + } + } + ]]></programlisting> + + </sect1> <!-- ============================== --> @@ -298,7 +330,7 @@ <itemizedlist> <listitem>@<qualified-name>, for example, @Foo, or @org.xyz.Foo.</listitem> - <listitem>@(<type-pattern>), for example, @(org.xzy..*), or + <listitem>@(<type-pattern>), for example, @(org.xyz..*), or @(Foo || Boo)</listitem> </itemizedlist> @@ -660,7 +692,7 @@ </varlistentry> <varlistentry> - <term>execution(public (@Immutable *) org.xyz..*.*(..)</term> + <term>execution(public (@Immutable *) org.xyz..*.*(..))</term> <listitem> <para> The execution of any public method in a package with prefix @@ -790,7 +822,7 @@ pointcut txRequiredMethod(Tx transactionAnnotation) : execution(* *(..)) && @this(transactionAnnotation) - && if(transactionAnnotation.policy == Tx.Policy.REQUIRED); + && if(transactionAnnotation.policy() == TxPolicy.REQUIRED); ]]></programlisting> <para> |