0

I have

public interface MyInterface {
    @DoProfile
    void some();
}

and there're some classes that implement this interface.

I want to write an aspect (using Spring AOP) that will run around some() methods of all implementations of this interface.

Generally, I'd like to be able to mark any abstract or interface method with @DoProfile and have its implementations be wrapped with Around aspect.

Simple @Around("@annotation(DoProfile)") doesn't work. It works only when I put @DoProfile on concrete implementations. But I'd like to put @DoProfile to interface / abstract methods.

How to do that?

Mikhail Kopylov
  • 2,008
  • 5
  • 27
  • 58
  • Have a look at this https://stackoverflow.com/questions/13172673/pointcut-is-not-being-applied-to-abstract-method – Nitin Prabhu May 27 '17 at 14:06
  • this doesn't work as `@DoProfile` may be put to any method. – Mikhail Kopylov May 27 '17 at 14:08
  • I just had a look around and found this https://stackoverflow.com/questions/7178782/aspectj-pointcut-for-methods-that-override-an-interface-method-with-an-annotati – Nitin Prabhu May 27 '17 at 14:17
  • 1
    Possible duplicate of [Emulate annotation inheritance for interfaces and methods with AspectJ](https://stackoverflow.com/questions/42607015/emulate-annotation-inheritance-for-interfaces-and-methods-with-aspectj) – kriegaex May 29 '17 at 03:37

0 Answers0