Aspect after advice (finally) method runs after a matching method execution exits. Use?@After?annotation to declare an After advice and must handle both normal and exception return conditions.?
This after finally method will always executes after the target method regardless of any exception.
This method is equivalent to the finally block of the traditional try-catch-finally exception handling mechanism. Finally block always executes after try or catch block. In the same way, after finally method will always execute after the target method execution. Even if the target method throws exception, this advice will still execute.
Use this AspectJ After advice to clean up, release resources, and so on.
The first argument of this method is of type org.aspecj.lang.JoinPoint. To know more on JoinPoint argument used in this method, see JoinPoint article.
@After("execution(* com..repositories..*(..))") public void afterFinally(JoinPoint joinPoint) { logger.info("After Advice method started : " + joinPoint.getSignature().getName()); logger.info("After Advice method stopper : " + joinPoint.getSignature().getName()); }
You can refer to our other articles on Spring AOP to learn more.
Great article! For me was very useful!