Spring AOP
Spring Aspect oriented Programming:
Spring Framework provide AOP module which is used to separate cross cutting logics in application.
what is cross cutting logic:
Aop will take care of integrating business logic with secondary component logic in runtime and will execute it
To seperate the business logic and secondary logic for this AOP there
Aspect: The Class which contains secondary logic (cross cutting logic)
ex: Logging Aspect, Auditing Aspect, SecurityAspect, TxAspect, ExceptionHandlingAspect
Advice: It represents when aspect logic should execute
Joinpoint: it represents where secondary logic should integrate with primary logic . Spring Aop supports method level join point.
pointcut: It represent for which business methods should secondary logic should apply, bydeafult secondary logic aspect logic is applicable for all methods in target.
weaving: The process of combining target and aspect is called as weaving
target: The class which contains business logic
poxy: weaving will generate one new class by combining target and aspect that class class proxy. and spring aop will execute this proxy at runtime.
Types of Advice:
before Advice: It will execute before business logic execution
After Returning Advice: will execute after business logic
Around Advice: will execute before and after business logic
Throws Advice: will execute when exception occurs in business Logic