3 Replies Latest reply on Jun 11, 2007 1:51 PM by system.out

    annotation

    system.out

      I am trying to tag the intercepted methods individually using annotation as described in userguide 4.1. Methods and annotations.

      I created a sample code and it is working fine (similar to Method Interception Sample). However when I tried to apply similar approach to intercept the session bean, interception didn't happen:

      Here is the jboss-aop.xml:

      <aop>
       <aspect class="OnewayAspect" />
       <bind pointcut="execution(void *->@Oneway(..))">
       <advice name="oneway" aspect="OnewayAspect" />
       </bind>
      </aop>


      all methods in session bean have Oneway annotation !!

      After that I modified the jboss-aop.xml with the following:
      <typedef name="MySessionBeans" expr="class($instanceof{javax.ejb.SessionBean}) AND class(org.jboss.injbossaop.ejb.*)" />
       <bind pointcut="execution(* $typedef{MySessionBeans}->getValue(..))">
       <interceptor class="org.jboss.injbossaop.lib.SimpleInterceptor"/>
       </bind>

      It was intercepted!

      Can anybody tell me what is wrong?


        • 1. Re: annotation
          system.out

          I also tried this:

          <typedef name="MySessionBeans" expr="class($instanceof{javax.ejb.SessionBean}) AND class(org.jboss.injbossaop.ejb.*)" />
           <bind pointcut="execution(* $typedef{MySessionBeans}->@Oneway(..))">
           <interceptor class="org.jboss.injbossaop.lib.SimpleInterceptor"/>
           </bind>


          With no success. I have getValue() method in org.jboss.injbossaop.ejb package annotated with @Oneway.

          Please note that if I replace @Oneway with getValue, it will work!!

          Maybe this syntax is not valid, however, I don't get any exceptions in AS. What I am looking for is abstracting method names with annotations.

          • 2. Re: annotation
            kabirkhan

            YOu need to fully qualify the annotation e.g.

            execution(* $typedef{MySessionBeans}->@org.blah.Oneway(..))
            


            • 3. Re: annotation
              system.out

              It rocks now! Thanks kabir for your prompt reply!
              mike