could someone please suggest why this aspect doesn’t catch @Service
methods?
@Aspect
@Component
public class PostPreAuthorizeServiceAdvice {
@AfterThrowing(pointcut = "@within(org.springframework.stereotype.Service) && execution(public * *(..)) && @annotation(preAuthorize)", throwing = "ex")
public void checkPreAuthorizeAfterThrowing(JoinPoint joinPoint, PreAuthorize preAuthorize, Throwable ex) throws Throwable {
throw new EntityNotFoundException();
}
@Around("@within(org.springframework.stereotype.Service) && @annotation(preAuthorize)")
public Object parsePreAuthorize(ProceedingJoinPoint joinPoint, PreAuthorize preAuthorize) throws Throwable {
try {
return joinPoint.proceed();
} catch (AccessDeniedException ex) {
throw new EntityNotFoundException();
}
}
}
Thank you!