Performance: Pointcut expressions
Pointcut expressions affect the runtime performance by determining which methods are intercepted for aspect logic, impacting method call overhead and application responsiveness.
@Pointcut("execution(* com.example.service.UserService.*(..))")
public void specificPointcut() {}@Pointcut("execution(* com.example..*(..))")
public void broadPointcut() {}| Pattern | Method Matches | Advice Calls | CPU Overhead | Verdict |
|---|---|---|---|---|
| Broad pointcut (e.g., com.example..*) | Many methods | Many advice calls | High CPU overhead | [X] Bad |
| Specific pointcut (e.g., com.example.service.UserService.*) | Few methods | Few advice calls | Low CPU overhead | [OK] Good |
com.example.service using a pointcut expression?execution(* com.example.service.*.*(..)) matches any return type, any class in the package com.example.service, and any method with any parameters... which matches subpackages, not just the package. execution(* com.example.service.*(..)) misses the class wildcard.execution(public * com.example.repo.*Repository.find*(..)), which methods will it match?public * means any public return type, com.example.repo.*Repository matches classes ending with 'Repository' in the package, and find*(..) matches methods starting with 'find' with any parameters.execution(* com.example..service.*(..)com.app.service and its subpackages, but only methods that have exactly two parameters of any type. Which expression is correct?com.app.service..* matches classes in the package and all subpackages.(* , *) means exactly two parameters of any type. (..) means any number of parameters, so it's incorrect here.Pass the test and this pattern moves unknown