Java Aspect-Oriented Programming with Annotations
Let’s imagine you want to log the time taken by some annoted methods using a @LogExecTime annotation. I first create an annotation LogExecTime: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface LogExecTime { } Then I define an aspect: @Component // For Spring AOP @Aspect public class LogTimeAspect { @Around(value = “@annotation(annotation)”) public Object LogExecutionTime(final ProceedingJoinPoint joinPoint, final LogExecTime … Read more