Search code examples
javaspringaopspring-aop

spring aop advice methods in a subclass


I want to advice a particular method in all class that extends or implements a particular interface or abstract class. How can this be achieved using spring aop 2.5.


Solution

  • Using the pointcut expression:

    within(some.package.MyInterface+)
    

    The plus (+) means "this class/interface and all subclasses/implementors".

    AspectJ Subtype patterns.