This spring AOP example will teach us to use AspectJ @AfterReturning annotation. @AfterReturning annotated methods run after the method (matching with pointcut expression) is executed usually and do not throw any error/exception.
In this example, We will create a simple spring application, add a login feature, and request a feature based on point information that has been added to the annotation @AfterReturning.
In this spring AOP, after returning the sample example, we will discuss how to use the AspectJ @AfterReturning annotation for java configuration in the app. In the spring AOP, After Returning Tip that will be used after completing the joining point in general: for example, if the route returns without a separate release. I.e., The method described by the AspectJ @AfterReturning annotation starts immediately after the regular use of all the methods associated with pointcut expression. But After Returning, Advice cannot prevent execution flow from proceeding to the joining point.
The @AfterThrowing is a Spring AOP advice. The advice in Aspect-Oriented Programming incorporates some divisive concerns so that targeted classes can focus on core performance.
As the name denotes, AfterThrowing advice executes when the target method throws an exception, and it won’t run if the method finishes successfully or swallows the thrown exception. Thus, the AfterThrowing advice is helpful. We want to build a standard exception handler for an application that can catch different exceptions thrown by another targeting method and take action.