After Aspect

Learn how to perform a task after an intercepted method call has been executed and what to do in case it throws an exception.

Logging is a cross-cutting concern for which aspects can be created. In this lesson, we will create another aspect that will log the values returned after the methods have been executed.

We will create an aspect in the io.datajek.springaop.movierecommenderaop.aspect package. Create a class named LoggingAspect and mark it with @Aspect and @Configuration annotations.

@Aspect
@Configuration
public class LoggingAspect {
private Logger logger = LoggerFactory.getLogger(this.getClass());
}
LoggingAspect class

@AfterReturning annotation

The LoggingAspect class will have a method LogAfterExecution(), which will print a message if the method ...