Spring AOP Flashcards
What are cross cutting concerns?
Functionalities that are orthogonal to the business requirement and cut across multiple points of application are called cross cutting concerns. Some examples are like Authentication, Authorization, Logging, Metrics, etc.
Give example of common cross cutting concerns
Logging, Security, Transaction management
What does AOP provide us?
Ability to decouple these cross cutting concerns from main business logic and make the code resuable.
Which are various AOP jargons?
1) Aspect
2) Advice
3) Pointcut
4) JoinPoint
What is Aspect?
Cross cutting concerns can be modularized into special classes called aspects.
What is Advice?
The piece of code that is invoked during program execution. Advice defines both when and what of aspect.
What is Joinpoint?
This represents a point in your application where you can plug in AOP aspect. In spring a join point is always a method.
What is pointcut?
Pointcuts define the when of aspect. It is an expression which defines filter. This is a set of one or more joinpoints where an advice should be executed.
What is weaving?
Weaving is the process of linking the aspets with other application types or objects to create an adviced object. There are two types of weaving.
1) Compile time weaving
2) Runtime weaving.
Which expression types are supported when defining pointcut?
1) execution
2) args
3) within
4) this
5) target
Define execution expression in pointcut
For matching method execution join points, this is primary pointcut designator what you will use
Define args expression in pointcut
Limits matching to joinpoints where the arguments are instances of the given types.
Define within expression in pointcut
Limits matching to join points within certain types
Define this expression in pointcut
Limits matching to joinpoints where the bean reference is an instance of the given type.
Define target expression in joinpoint
Limits matching to joinpoints where the target object is an instance of the given type.