What are the differe...
What are the differe...
In Spring Aspect-Oriented Programming (AOP), an advice is an action taken by an aspect at a particular join point. There are five types of advices in Spring AOP:
Before Advice: This type of advice runs before the advised method is invoked. It is typically used to perform certain actions before a method execution, such as logging, security checks, or input validation. It is denoted by the @Before
annotation[1][3].
After Advice: Also known as "after finally" advice, it runs after the advised method execution, regardless of its outcome, meaning it will execute whether the method completes successfully or if it throws an exception. This advice is useful for actions that need to occur no matter what the method outcome is, like releasing resources or logging. It is denoted by the @After
annotation[1][3].
After Returning Advice: This advice runs after the advised method executes successfully, i.e., it does not throw an exception. It is often used for post-processing the return value of a method, such as modifying the result or logging. It is denoted by the @AfterReturning
annotation[1][3].
After Throwing Advice: This advice is executed if the advised method exits by throwing an exception. It is useful for exception handling and logging, allowing developers to react to an exception being thrown. It is denoted by the @AfterThrowing
annotation[1][3].
**Around...
senior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào