5 Replies Latest reply on May 13, 2005 8:20 AM by nthx

    'within' and 'set' and documentation page

      Hi guys.

      I've tried to define pointcut:

      <bind pointcut="
       set(* my.*->*)
       AND
       within(my.Pojo)
       ">
       <interceptor class="WriteOperationsInterceptor"/>
      </bind>


      But it doesn't intercepts what I want. It works with 'call' and 'execution' pointcut types.
      I need that combination..

      PS. Maybe there should be separate page on JBossAOP Wiki about "with and withincode". They are quite important in AOP.


      Regards,
      Tomasz



        • 1. Re: 'within' and 'set' and documentation page

          Sorry, it was to hurry.

          My pointcut doesn't make sense at all. I can have "set(my.*->*)" without using "within".

          I've tried to use it in another poincut together with "(set(...) OR call(...) OR execution(...)) AND within(my.package)". That's why.

          Sorry, forget about that.

          t.

          • 2. Re: 'within' and 'set' and documentation page
            bill.burke

            execution and set/get do not make sense with within as their purpose
            is to totally wrap EVERY invocation.

            within and withcode only make sense with call. I guess a callfield is necessary. I'll add that to the TODO.

            Bill

            • 3. Re: 'within' and 'set' and documentation page

               

              "bill.burke@jboss.com" wrote:
              execution and set/get do not make sense with within as their purpose
              is to totally wrap EVERY invocation.

              within and withcode only make sense with call. I guess a callfield is necessary. I'll add that to the TODO.

              Bill


              Hi there!

              I came to that problem tonight again..

              Actually, it does make sense. One can has
              "execution(* class->method(..)) AND !within(ExcludedClass)" in AspectJ.

              It makes sense. I'd like to intercept any execution of method "method", but not in the class "ExcludedClass". How would that be with JBAOP?

              Tomasz Nazar



              • 4. Re: 'within' and 'set' and documentation page
                kabirkhan

                Hi Tomasz,

                "within" only works with call, i.e "instrument the caller of xxx only if we are making the call from within yyy".

                In the case of "normal"/execution of instumentation we do not care (or have any info about) who is calling the target. AspectJ's weaving works differently. To achieve what you want with JBoss AOP you wuld currently have to use cflow.

                Cheers,

                Kabir

                • 5. Re: 'within' and 'set' and documentation page

                  Hi there!

                  Yes, as a workaround I've used cflow.

                  AspectJ weaves in different way, but the semantic stays the same.

                  Isn't there really any info about a method's class?
                  'within' takes class expression as an argument, right?

                  If you have access to a method, then you should also have access to the method's class. You weave the method itself, so you have access to the method's class. I don't know the details but it seems possible.

                  Comment..?

                  Tomasz Nazar

                  PS. I cannot use "call" because calls are made by Struts framework. Let's assume I log '* Action->execute(..)'.