6 Replies Latest reply on Aug 6, 2004 2:57 PM by rkadayam

    Multiple pointcut expressions and advice bindings for same s

    rkadayam

      Can I have pointcut expressions that identify a single method and some that are very generic covering range of methods, bind them differently and expect that all of the bindings would take effect in some order. I'd think it might be logical to process the "generic" pointcut bindings and then the very expressive ones after.

      For example, I would like to instrument a session bean that maybe has the following methods

      method1(String)
      method2(int)

      I would like to have an aop xml (the syntax may not be on the dot) that looks like













      So the idea being that if any of the methods are called "global_stack" is invoked. If method1 is invoked, then both global_stack and Interceptor1 are processed. Have'nt experimented this yet but curious if anyone has tried it before? The whole idea being that you don't have to duplicate the global_stack reference in every advice binding

      -thanks
      -rajiv

        • 1. Re: Multiple pointcut expressions and advice bindings for sa
          rkadayam

          Sorry, for some reason my xml lines got stripped off, the aop xml looks like

          <pointcut name="Method1" expr="execution(* test.TestServiceBean->method1(java.lang.String))" />
          <pointcut name="AllMethods" expr="execution(* test.TestServiceBean->*(..))" />
          
          <bind pointcut="Method1">
           <interceptor class="Interceptor1" />
          </bind>
          
          <bind pointcut="AllMethods">
           <stack name = "StackOne" />
          </bind>
          
          


          • 2. Re: Multiple pointcut expressions and advice bindings for sa
            kabirkhan

            In my experience the bindings are applied "top-down", i.e. in your example Interceptor1 should be applied before StackOne. I'm not 100% sure if this is documented behaviour though

            • 3. Re: Multiple pointcut expressions and advice bindings for sa
              kabirkhan

              Taken a quick look at the code for the above, and the assumption above regarding ordering of interceptors seems safe.

              Now, in response to your actual question :-) The global/specific stuff is fine.

              • 4. Re: Multiple pointcut expressions and advice bindings for sa
                bill.burke

                You can hotdeploy a pointcut definition, but this does not cause bindings to be reapplied. Am I making sense? So, if you modify "AllMethods" at runtime and redeploy it, bindings will not be recalculated.

                Currently, the code isn't smart enough to know if the binding references a "named" pointcut.

                Does this screw up what you want to do?

                Bill

                • 5. Re: Multiple pointcut expressions and advice bindings for sa
                  rkadayam

                  Well, not sure if what I'm doing qualifies as hot-deploy or not, but I have a console that acts as an interface to dynamically at run-time attach and detach advices to the advice stacks. And in turn the advice stacks updates every AdviceBinding that it references internally.

                  My concern is more in terms of the order of the interception. I would prefer the interceptors/advices/stacks bound in the "all methods" pointcut intercept first and then the specific method pointcut bindings intercept next.

                  Is that correct?

                  • 6. Re: Multiple pointcut expressions and advice bindings for sa
                    rkadayam

                    So I just did a small experiment and it seems like in whatever order the advice bindings were created, that was the order in which the advices/interceptors were ordered.

                    Meaning if I attached the advice to SpecificMethod pointcut binding first and then AllMethods pointcut binding next. Then that would be the order of the interceptors.

                    Since they are two different "AdviceBindings" I thought the instrumented code would always look for the "AllMethods" advice bindings first and then the "SpecificMethod" advice bindings next.

                    any thoughts ?