Search code examples
javaannotationsmetricsspring-annotations

How can I apply an annotation to every method of a class?


I have an annotation that meters the execution time placed on a method level. I would like to know if it is possible to, for example, create a new annotation on a class level that applies my "timed" annotation on every method of this class. I'm a bit new with AOP. Maybe someone has an idea? I'm using:

  • JDK 1.8

Solution

  • Just to answer my own question, I finally used Srping AOP and AspectJ to target every methods of a class (without annotation) so that it is easily deactivable.

    Something like this :

    https://howtodoinjava.com/spring-aop/spring-aop-aspectj-xml-configuration-example/