-
Notifications
You must be signed in to change notification settings - Fork 0
Spring Aspect
thaoln87 edited this page May 10, 2017
·
4 revisions
Systems are composed of several components
- Components for specific functionality
- Additional responsibility beyond the core functionality, such as: logging, transaction management, security
2 problems solved by the AOP:
- code tangling: there are many code which does not relate to main code; example: UserRepository.getUsers method may contain code for logging, checking if user has permission ...
- code scattering: the same code appears in many places; example: logging code appears in UserRepository.getUsers, OrderRepository.getOrderById ...
With AOP, we can then cover our core application with layers of functionality. These layers can be applied declaratively throughout our application in a flexible manner without our core application even knowing they exist
@EnableAspectJAutoProxy //Enable AOP
public class AppConfig{
}Proxy class is generated which wraps the used class.
AOP is applied for public methods of Spring managed beans.
Join Cross Join Point Advice @Before @After @Throw @Finally @Around