Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

How to see an AOP pointcut matches to a method signature

Situation

  • You are developing an Java application with Spring Framework.
  • You are trying to write an AOP pointcut to weave some logic into a method invocation, but the weaved logic doesn't seems be running.

Problem

Mistakes are sometimes in the method signature, sometimes in the pointcut notation, or sometimes you are just running and watching a wrong method to test the weaved logics. So you have to break down the cause of this problem, but (it seems) there is no formulated way to see whether an AOP pointcut matches to a method signature or not.

Solutions

There are some tools and procedures you can use:

  • You can use Eclipse debug perspective to see whether an aspect is weaved or not. Set a break point in the target method and run some test. If the aspect method is in the call stack view, it is weaved properly.