1
votes

I am trying to create a pointcut expression that will fire on all methods in a certain package but not fire based on a custom annotation. Here is what i have so far that works for the first execution but not the second. Thanks for the help!

@AfterThrowing(pointcut = "execution(* services..*.*(..)) && !within(@services.annotation.IgnoreBusinessServiceExceptionTranslation *)", throwing = "ex") 

public void exceptionThrown( Throwable ex ){}

Interface:

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface IgnoreBusinessServiceExceptionTranslation
{}
1

1 Answers

3
votes

Found the answer for anyone else!

@AfterThrowing(pointcut = "execution(* services..*.*(..)) && !@annotation(services.annotation.IgnoreBusinessServiceExceptionTranslation)", throwing = "ex") 

public void exceptionThrown( Throwable ex ){}