Can we say the @Around annotation in spring boot AOP is a combination of @Before and @After method.
@Around("myPointCut()")
public Object applicationLogger(ProceedingJoinPoint joinPoint){
logger.info(" for the Method : " + joinPoint.getSignature().getName() +
" Request received : {}", Arrays.toString(joinPoint.getArgs()));
Object res = null;
try {
res = joinPoint.proceed();
logger.info(" for the Method :"+ joinPoint.getSignature().getName() +
" Response received : {}", res);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
return res;
}
With this advice method annotated with @Around annotation, we can get the input parameters and also the returned object with proceed() which creates a proxy demo class and calls the actual implemented method. If let's say we don't have @Around annotation, then we would have to use the @Before and @After annotations and two separate methods to achieve the input and output parameters.
So can we say just @Around annotation is enough and we don't require @Before, @After, @AfterReturning annotations as these are all catered by @Around.