Sunday Study

Aop 1

스프링 AOP 개념

스프링 3대 요소 중 하나인 AOP

스프링 3대 요소 중 하나인 AOP

개념

image

해결할 문제

적용 가능한 방법

컴파일 시점

클래스 로딩 시점

런타임 시점

조인 포인트

스프링 AOP 관련 용어 및 개념

예시 (로깅을 위한 활용)

@Slf4j
@Aspect
@Component
public class LogIntroduction {
    @Pointcut("execution(* com.dragonguard.backend..*Controller*.*(..))")
    public void allController() {
    }

    @Pointcut("execution(* com.dragonguard.backend..*Service*.*(..))")
    public void allService() {
    }

    @Pointcut("execution(* com.dragonguard.backend..*Repository*.*(..))")
    public void allRepository() {
    }

    @Before("allController()")
    public void controllerLog(JoinPoint joinPoint) {
        log.info(
                "METHOD : {}, ARGS : {}",
                joinPoint.getSignature().toShortString(),
                joinPoint.getArgs());
    }

    @Before("allService() || allRepository()")
    public void serviceAndRepositoryLog(JoinPoint joinPoint) {
        log.debug(
                "METHOD : {}, ARGS : {}",
                joinPoint.getSignature().toShortString(),
                joinPoint.getArgs());
    }
}

다음 AOP 주제들

  1. 프록시의 이해
  2. 적용 방법 (annotation 정의 및 코틀린에서의 예시 포함)
  3. 포인트컷 (execution, this, target 등)
  4. JoinPoint, ProceedingJoinPoint 역할 및 제공 메소드들