Integrating Spring AOP with AEM

Spring AOP (Aspect-oriented programming) framework is used to modularize cross-cutting concerns in aspects.Some of cases where we can use it are to control some of common things like logging , adding some extra feature without actually touching the core logic.

This blog post will explain how to enable aspects in our AEM projects using aspectj-maven-plugin.
Below are the steps for various configuration we need to make.

execution(public * com.ig.core.*.*(..)) : the execution of any method defined in the core package or a sub-package@Before Before advice It will execute before the method execution@After After returning advice tt will execute after the method is returned a result.

Refer Spring’s AOP documentation for Joint Point, Advice, Pointcuts, etc. and depending upon the use case in your application select the right one.