Spring AOP Flashcards

1
Q

What is “aspect-oriented programming”? Define an aspect.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give an example of a cross-cutting concern you could use AOP to address

A

Transactional concern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Join Point?

A

A join point is a point in the control flow of a program where the control flow can arrive via two different paths.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Pointcut?

A

An expression targeting a set of JoinPoints respecting the Pointcut Expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an Advice?

A

When and what do you want to execute. In Java, an Advice is simply a method containing code implement the cross-cutting concern.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the different types of advice? What is special about the @Around advice? How is the ProceedingJoinPoint used?

A
  • @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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What visibility must Spring bean methods have to be proxied using Spring AOP?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly