I am familiar with Spring AOP
. As i read in the spring documentation http://docs.spring.io/spring/docs/3.1.x/spring-framework-reference/html/aop.html, Spring AOP
works on the concept of proxies.
In the section 8.2.3.1 Supported Pointcut Designators, i found the below note
Due to the proxy-based nature of Spring's AOP framework, protected methods are by definition not intercepted, neither for JDK proxies (where this isn't applicable) nor for CGLIB proxies (where this is technically possible but not recommendable for AOP purposes). As a consequence, any given pointcut will be matched against public methods only!
At first, I didn't believe it, so i tried to implement it without using interfaces where all methods are public by default and was surprised that the above is true. Since proxy classes are subclasses of the advised/target object and protected methods can be accessed by a subclass so I thought protected methods would work fine.
Can someone please let me know why protected methods are not intercepted? Am I missing something?
JDK proxies are based on interfaces and this means that all implemented methods will be public
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With