Google News
logo
Java Springs - Interview Questions
What is execution Pointcut in Spring AOP.
Execution pointcut applies to the execution of a method, and we can use the following Pointcut expression language to match the method name.
execution(modifiers-pattern? return-type-pattern declaring-type-pattern?
   method-name-pattern(param-pattern) throws-pattern?)
 
The modifiers in Spring AOP only supports public, and return type can be void, boolean, List and others. The declaring type is the class name that you use for the given method, you can give the actual method name on the method name pattern or make use of wildcards. The method can be matched for a given parameter list using the param pattern, and finally, we have a throws pattern that throws a given exception. The pattern is optional if it has a question mark “?”.
 
@Before("execution(public void com.freetimelearn.app.CustomerDAO.addCustomer())")
 
In this example, we want to match on only the addCustomer method in the CustomerDAO class, and if those items match, then we will apply our advice for that Pointcut, and that is all for matching on execution calls for a given method name.
Advertisement