Isn't advising the proceed basically the same as advising the target joinpoint again.
I can create two pieces of around advice that will apply at the same joinpoint and they will be called in a reliable sequence (if from the same aspect or ordering set with declare precedence). === aspect X { void around(): execution(* m(..)) {/*set message*/;proceed();} void around(): execution(* m(..)) {/*do indentation and log actual message */proceed();/*do unindent*/} } public class A { public static void main(String []argv) { new A().m(); } public void m() {} } === Andy On 25 August 2012 02:57, Alexander Kriegisch <alexan...@kriegisch.name> wrote: > I have asked this question on StackOverflow [1] before, but received no > answer so far. Maybe somebody here has one for me: > > Because it is impossible to bind a constant or dynamic parameter to an > advice in a pointcut [2], I have a bunch of logging around() advice A > which set a message to be logged (ThreadLocal private member of aspect) > and then call proceed(). I would like to be able to intercept the > proceed() in any of those advice from another advice B which does the > actual logging and indentation work so as to avoid code duplication in > the other advice, but there is no joinpoint available to do that. I > verified this by logging *all* joinpoints within those advice. > > What I came up with is a rather complicated combination of > - intercepting the set() operations on the internal variable > containing the log message in an after() advice, doing indentation > and pre-proceed() logging there, and > - Java annotation tags on the many advice A plus another after() > advice capturing the end of each advice A, doing dedentation > and post-proceed() logging there. > > If anyone is interested I can post real or pseudo code, but I just > wanted to explain *why* I need an interceptable joinpoint on proceed() > if I do not want to use any tricks or trade one type of code repetition > (the logging/indentation calls) for another (chaining all logging > pointcuts used on advice of type A like "a() || b() || c() || ...", > repeating them and having to update them if I add another logging > pointcut + advice. > > Attention: I *cannot* just use another around() advice intercepting the > other adviceexecution()s because I need to wait until the log message > has been constructed inside of them. That would not be a problem either > if I could intercept proceed() and would have the additional advantage > that after proceed() I could even do other things in the advice, e.g. > log more info not captured by the one-line message logged by my > hypothetical advice B. > > I hope that all of this was understandable. Otherwise, please ask. > > Bottom line: My wish is a pointcut "proceedexecution()" or similar. > > [1] > http://stackoverflow.com/questions/12018585/how-to-intercept-proceed-in-another-aspectj-aspect > [2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=92889 > -- > Alexander Kriegisch > > _______________________________________________ > aspectj-users mailing list > aspectj-users@eclipse.org > https://dev.eclipse.org/mailman/listinfo/aspectj-users _______________________________________________ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users