Recall & Review
beginner
What is the purpose of the @Around advice in Spring AOP?
The @Around advice allows you to run custom code before and after a method execution, giving full control over the method call, including the ability to modify arguments, control execution, and change the return value.
Click to reveal answer
intermediate
How do you access the method being advised inside an @Around advice?
You use the ProceedingJoinPoint parameter in the advice method. It provides the method signature, arguments, and lets you proceed with the original method call using proceed().
Click to reveal answer
intermediate
What happens if you do not call proceed() inside an @Around advice?
The original method will not be executed. This means you can completely skip the method or replace its execution with your own logic.
Click to reveal answer
intermediate
Can you modify the return value of a method using @Around advice? How?
Yes, by capturing the result of proceed() call, you can modify or replace it before returning it from the advice method.
Click to reveal answer
beginner
Show a simple example of an @Around advice method signature in Spring Boot.
public Object aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
// your code here
Object result = joinPoint.proceed();
return result;
}
Click to reveal answer
What parameter type must an @Around advice method accept to control method execution?
✗ Incorrect
The @Around advice requires ProceedingJoinPoint to control the method execution and call proceed().
What happens if you call proceed() multiple times inside an @Around advice?
✗ Incorrect
Calling proceed() multiple times will execute the original method multiple times, which is usually unintended.
Which of these can you NOT do inside an @Around advice?
✗ Incorrect
You cannot change the method signature at runtime with @Around advice.
If you want to run code only after a method completes successfully, which advice is better than @Around?
✗ Incorrect
@AfterReturning runs only after successful completion, while @Around runs before and after.
What exception must your @Around advice method declare or handle?
✗ Incorrect
The proceed() method throws Throwable, so your advice method must declare or handle it.
Explain how @Around advice gives you full control over a method execution in Spring Boot.
Think about what you can do before and after calling the original method.
You got /5 concepts.
Describe a scenario where using @Around advice is better than @Before or @After advice.
Consider when you want full control, not just before or after.
You got /4 concepts.