1. @Aspect
- Spring 빈(Bean) 클래스에만 적용 가능합니다.
어드바이스 종류
포인트컷
- 포인트컷 Expression Language
- 포인트컷 Expression 형태
포인트컷 Expression 예제
@Around("execution(public * com.sparta.myselectshop.controller..*(..))")
public Object execute(ProceedingJoinPoint joinPoint) throws Throwable { ... }
modifiers-pattern
return-type-pattern
declaring-type-pattern
method-name-pattern(param-pattern)
@Pointcut
- 포인트컷 재사용 가능
- 포인트컷 결합 (combine) 가능
@Component
@Aspect
public class Aspect {
@Pointcut("execution(* com.sparta.myselectshop.controller.*.*(..))")
private void forAllController() {}
@Pointcut("execution(String com.sparta.myselectshop.controller.*.*())")
private void forAllViewController() {}
@Around("forAllContorller() && !forAllViewController()")
public void saveRestApiLog() {
...
}
@Around("forAllContorller()")
public void saveAllApiLog() {
...
}
}