Aspects
An aspect is a modularization of such a concern. Instead of scattering code across many classes, we put the logic of handling the concern into an aspect. In Spring AOP, you can implement an aspect in a regular class and annotate it with the @Aspect annotation, which is an annotation from AspectJ (https://www.eclipse.org/aspectj).
Let's say we have methodA() in ClassA, methodB() in ClassB, and methodC() in ClassC, and we need to do security checking inside all of these methods. Before using AOP, we need to add code to handle security checks in all of these methods. And if we also need to execute a security check in other methods, we will need to add checkSecurity() to those methods too. After using AOP, we extract the security check ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access