2 Replies Latest reply on May 19, 2004 10:03 AM by bill.burke

    after advice

    kado0002

      Hello,
      Can I define after advices in Jboss AOP like I can do in AspectJ, which executes after the execution of a join point?
      For Example an advice that executes after a method.

      Up to now I didn't need such an advice in JBoss AOP but I've a problem which can only be solved with after advice.

      until soon
      Karsten

        • 1. Re: after advice
          kabirkhan

          Don't know if I have understod correctly, but your advice is responsible for propogating the call itself (i.e. invocation.invokeNext()). Stuff you do before the call to invocation.invokeNext() is done before the method is called, stuff after is doen after the method is called.

          Apologies if I am just throwing spanners in the work!

          • 2. Re: after advice
            bill.burke

            Yes, Kabir is correct. JBoss AOP has no before/after/after returning/after throws, etc...

            These can all be handled implicitly with an around advice.

            This was done on purpose to simplify the model. There is no performance benefit of having before/after. Also, IMO, it is more intuitive to have an around advice because it makes you more aware of the flow of the application and that you are part of the flow of an application.

            So the solution is to have an advice:

            public class MyAspect {
            
            public Object myAdvice(Invocation invocation) throws Throwable {
             Object rtn = invocation.invokeNext();
            
             // DO AFTER STUFF HERE
            
             return rtn;
            }
            
            }
            


            See? Feedback? Maybe I'm missing something.