May 2015
Intermediate to advanced
234 pages
4h 18m
English
An after advice executes some extra code after the execution of the target method, even if an exception is thrown during its execution. Use this advice to clean up resources by removing a temporary file or closing a database connection. In this recipe, we will just log the target method name.
We will use the aspect class defined in the Creating a Spring AOP aspect class recipe.
Here are the steps for using an after advice:
@After. Make it take JoinPoint as an argument:@After("execution(* com.spring_cookbook.controllers.*.*(..))")
public void cleanUp(JoinPoint joinPoint) {
...
}Read now
Unlock full access