3 Replies Latest reply on Nov 28, 2005 11:38 AM by Kabir Khan

    using cflow to prevent

    Josh Male Newbie

      Hi, I've just started playing around with JBoss AOP (and AOP in general).

      I want to intercept method calls which are annotated with a "@Collaboratable" tag. The contents of the XML file defining the point-cut is shown below:

      <aop>
       <aspect class="adi.framework.business.CollaborationAspectJboss"/>
      
       <!-- Prevent the triggering of @Collaboratable methods which have been called from within the dynamic context of other @Collaboratable methods. -->
      
       <cflow-stack name="duplicateCollab">
       <called expr="* *->@adi.framework.business.Collaboratable(..)"/>
       </cflow-stack>
      
       <bind pointcut="execution(* *->@adi.framework.business.Collaboratable(..))" cflow="!duplicateCollab">
       <advice name="collab"
       aspect="adi.framework.business.CollaborationAspectJboss"/>
       </bind>
      </aop>



      I also want to prevent the advice being triggered if a method annotated with @Collaboratable has another (or same) method annotated with @Collaboratable in its call stack. I haven't been able to achieve this with the "cflow" clause above. I was wondering if I'm doing this the right way.

      Thanks...
      Josh


        • 1. Re: using cflow to prevent
          Kabir Khan Master

          instead of

          <cflow-stack name="duplicateCollab">
           <called expr="* *->@adi.framework.business.Collaboratable(..)"/>
           </cflow-stack>
          
           <bind pointcut="execution(* *->@adi.framework.business.Collaboratable(..))" cflow="!duplicateCollab">
           <advice name="collab"
           aspect="adi.framework.business.CollaborationAspectJboss"/>
           </bind>
          


          Try

          <cflow-stack name="duplicateCollab">
           <not-called expr="* *->@adi.framework.business.Collaboratable(..)"/>
           </cflow-stack>
          
           <bind pointcut="execution(* *->@adi.framework.business.Collaboratable(..))" cflow="duplicateCollab">
           <advice name="collab"
           aspect="adi.framework.business.CollaborationAspectJboss"/>
           </bind>
          



          • 2. Re: using cflow to prevent
            Josh Male Newbie

            Thanks Kabir for the reply.

            I tried what you suggested but without success.

            Investigating a bit further I found that the "cflow" statements did operate as expected if I used ordinary method patterns for the "called expr" attribute. It seems to break if I specify an annotated method pattern however. I was wondering if this was by design or whether it might be a bug - I am using version 1.3.4