Bird
0
0

You want to monitor execution time of all service methods but exclude methods annotated with @SkipTiming. Which AOP pointcut expression correctly achieves this?

hard📝 Best Practice Q15 of 15
Spring Boot - Aspect-Oriented Programming
You want to monitor execution time of all service methods but exclude methods annotated with @SkipTiming. Which AOP pointcut expression correctly achieves this?
Aexecution(* com.example.service..*(..)) && !@annotation(com.example.SkipTiming)
Bexecution(* com.example.service..*(..)) || @annotation(com.example.SkipTiming)
Cexecution(* com.example.service..*(..)) && @annotation(com.example.SkipTiming)
D!execution(* com.example.service..*(..)) && !@annotation(com.example.SkipTiming)
Step-by-Step Solution
Solution:
  1. Step 1: Understand pointcut logic for inclusion and exclusion

    We want all service methods except those with @SkipTiming annotation.
  2. Step 2: Use && with negation to exclude annotated methods

    Use 'execution(...) && !@annotation(...)' to include methods but exclude those annotated.
  3. Final Answer:

    execution(* com.example.service..*(..)) && !@annotation(com.example.SkipTiming) -> Option A
  4. Quick Check:

    Exclude annotated methods with !@annotation [OK]
Quick Trick: Use && !@annotation to exclude methods [OK]
Common Mistakes:
  • Using || which includes annotated methods
  • Using && @annotation which includes only annotated
  • Negating execution pointcut incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes