Aspect-Oriented Programming (AOP) is a programming paradigm that allows you to separate cross-cutting concerns (logic that affects multiple parts of an application but isn’t part of the core business logic).

In other words:

  • In traditional OOP, you encapsulate logic into classes and methods.
  • In AOP, you encapsulate concerns (like logging, security, transaction management) into separate modules called aspects.

This helps keep your business logic clean while still applying these cross-cutting behaviors across your application.

Key AOP Terminology (Spring Boot-specific)

  • Aspect → Class containing cross-cutting logic (e.g., LoggingAspect).
  • Advice → What the aspect does (e.g., @Before, @After, @Around).
  • Join Point → A point in execution where advice can be applied (for spring it will always be a method call).
  • Pointcut → Expression to select which join points to target. (eg. like @Around("@annotation(com.....ReturnUserOperables)"))
  • Weaving → How are the aspects added to the target code (done at runtime by Spring).

When the advice used is @Around, we will have to call Object result = pjp.proceed(); to execute the target method.

Note:

  • ApiAccessInfoDto implements the UserOperable interface, which then allows it to be handled by the AOP
  • In the setOperations, the UserOperable interface provide multiple methods for the inheriting class to implement. They are all provided with a default implementation, so the inheriting class don’t need to implement it.