Spring Aspects are blocks of code that can be injected into the application at runtime
example logging, transaction management, caching, security.
- Spring uses AspectJ (byte code modification - run time interweaving) for aspecting.
Parts of spring Aspect
- Aspect - a class that implements enterprise application concerns that cut across multiple classes. Aspects can be a normal class configured through Spring XML configuration or we can use Spring AspectJ integration to define a class as Aspect using @Aspect annotation.
- Join Point - the place or specific point in the application code flow where the aspect code will be applied
- Point Cut - a selection criteria to select the 'Join Point' to apply the aspect code.
- Advice - The advice is the aspect class method that will be applied at the 'Join Point' selected by the 'Point Cut'
Point Cut:
Syntax: designator("r p.c.m(arg)")
r- return type
p- package
c-class
m-method
arg-arguments
designator-there are several designators provided by spring which can be used to implement an aspect.
e.g. execution - for matching method execution
within-for matching within certain types
target-for matching a specific type
@annotation-for matching a specific annotation
No comments:
Post a Comment