]> source.dussan.org Git - aspectj.git/commitdiff
fixes in annotation docs uncovered through testing
authoracolyer <acolyer>
Wed, 9 Mar 2005 11:16:11 +0000 (11:16 +0000)
committeracolyer <acolyer>
Wed, 9 Mar 2005 11:16:11 +0000 (11:16 +0000)
docs/adk15ProgGuideDB/annotations.xml

index 2a0d02d549f7edbfdeec14a6c3d985fa6eb09712..d7abfe0af11247f7938a421845cf73ffb28640d9 100644 (file)
                @AspectAnnotation
                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) {
         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>
 
   <!-- ============================== -->
       <itemizedlist>
           <listitem>@&lt;qualified-name&gt;, for example, @Foo, or 
           @org.xyz.Foo.</listitem>
-          <listitem>@(&lt;type-pattern&gt;), for example, @(org.xzy..*), or
+          <listitem>@(&lt;type-pattern&gt;), for example, @(org.xyz..*), or
           @(Foo || Boo)</listitem>
       </itemizedlist>
 
         </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 
 
        pointcut txRequiredMethod(Tx transactionAnnotation) :
            execution(* *(..)) && @this(transactionAnnotation) 
-           && if(transactionAnnotation.policy == Tx.Policy.REQUIRED);
+           && if(transactionAnnotation.policy() == TxPolicy.REQUIRED);
        ]]></programlisting>
 
     <para>