Spring AOP Flashcards
What is “aspect-oriented programming”? Define an aspect.
Aspect-oriented programming (AOP) is an approach to programming that allows global properties of a program to determine how it is compiled into an executable program. AOP can be used with object-oriented programming ( OOP ).
An aspect is a subprogram that is associated with a specific property of a program.
Give an example of a cross-cutting concern you could use AOP to address
Transactional concern
What is a Join Point?
A join point is a point in the control flow of a program where the control flow can arrive via two different paths.
What is a Pointcut?
An expression targeting a set of JoinPoints respecting the Pointcut Expression.
What is an Advice?
When and what do you want to execute. In Java, an Advice is simply a method containing code implement the cross-cutting concern.
What are the different types of advice? What is special about the @Around advice? How is the ProceedingJoinPoint used?
- @Before, @AfterReturning, @AfterThrowing, @After, @Around
- @Around: surrounds a join point, can perform custom behavior before and after method invocation. Chooses to proceed with join point or to shortcut the advised method execution by returning its own value or throwing an exception.
-ProceedingJoinPoint: Exposes the proceed method in order to support around advice, allows the around advice to be called before a specific method.
What visibility must Spring bean methods have to be proxied using Spring AOP?
For JDK proxies, only public interface method calls on the proxy can be intercepted. With CGLIB, public and protected method calls on the proxy will be intercepted, and even package-visible methods if necessary. However, common interactions through proxies should always be designed through public signatures.