aop

Aspect Oriented Programming

비즈니스 로직과 다른 로직을 분리 시키는 프로그래밍 기법 Spring의 Transactional이 대표적인 aop이다. spring-aop는 그것을 쉽게 구현해주는 프레임워크이다.

// build.gradle
dependencies {
  implementation 'org.springframework.boot:spring-boot-starter-aop'
}
// Aspect 설정을 bean으로 등록 시킨다.
@Aspect
@Component
@RequiredArgsConstructor
public class StatisticAspect {

    @AfterReturning( ~) // 어떤 메서드에 추가할 것인지 지정 [Advice]
    public void afterHandleInput(JoinPoint joinPoint, ~) {
        // 어떤 로직을 추가할 것인지 구현
        ~
    }
}