Entering a recommendation to a recursive method in Spring.Net?

I am trying to use Spring.NET AOP support to make dependency / inversion of control / aspect-oriented programming (sorry for a lot of words) - maybe I will post a separate question asking someone to clarify the difference :)).

In particular, I want to intercept a call to a recursive method, so that every time a method is called, an AOP tip / interceptor is called.

Spring.Net does not intercept anything except the very first method call. I think Spring.Net supports exactly one chain of interceptors per instance and no longer intercepts calls until this first method call completes.

Does anyone have any information on how to fire an interceptor (tip) to call EACH method, including recursive calls?

I can provide code / example output if this is helpful. Thanks!

+3
source share
3 answers

If you use proxy-based AOP, this will not work for calls to recursive methods. The first call against the target will be intercepted by the proxy server and your advice will be launched. Then the method on the target side will be called, and subsequent calls will remain within the target class, not knowing the proxy. The only way to do this work is to actually modify your bytecode so that the class itself contains the behavior.

Spring.NET( Spring Java), , , , .NET.

+2

I know this is not Spring.NET as such, but check out PostSharp . This gives you compilation time that does not rely on dynamic proxies and handles the call of a recursive method. The configuration is a little different though ...

0
source

Source: https://habr.com/ru/post/1702223/


All Articles