Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Spring AOP

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 for spring aop, which gives that information?

like image 993
Jens Schauder Avatar asked Feb 28 '11 12:02

Jens Schauder


1 Answers

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.

like image 171
Grzegorz Oledzki Avatar answered Oct 12 '22 11:10

Grzegorz Oledzki