开发者

How to debug Spring AOP

开发者 https://www.devze.com 2023-02-14 01:49 出处:网络
I have a problem with Spring AOP which doesn\'t ties an aspect to all the methods it should (in my opinion) (see this question for more about the root problem: Spring AOP ignores some methods of Hessi

I have a problem with Spring AOP which doesn't ties an aspect to all the methods it should (in my opinion) (see this question for more about the root problem: Spring AOP ignores some methods of Hessian Service).

How can I debug, what methods and instances get combined with what aspect? Is there something like a verbose flag 开发者_如何学Pythonfor spring aop, which gives that information?


There seems not to be too much logging code in the Spring AOP classes, but...

In case Spring AOP decides to use Cglib to create proxy, there's one line which might help you:

    // in org.springframework.aop.framework.Cglib2AopProxy.getProxy(ClassLoader)
    if (logger.isDebugEnabled()) {
        logger.debug("Creating CGLIB2 proxy: target source is " + this.advised.getTargetSource());
    }

A similar one seems to come in handy when JDK proxies are used:

    // in org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(ClassLoader)
    if (logger.isDebugEnabled()) {
        logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource());
    }

Just try to turn on DEBUG-level logging for these two classes and see what's the output.

0

精彩评论

暂无评论...
验证码 换一张
取 消