-
[SpringBoot] AOP카테고리 없음 2021. 8. 22. 19:59

이 포스팅은 인프런에서 스프링 핵심원리 - 기본편을 듣고 작성한 것입니다.
AOP: Aspect Oriented Programming
OOP를 보완할 수단으로, 관점 지향 프로그래밍이라고 불린다.
시간 측정 AOP 등록
package hello.hellospring.aop; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.springframework.stereotype.Component; @Component @Aspect public class TimeTraceAop { @Around("execution(* hello.hellospring..*(..))") public Object execute(ProceedingJoinPoint joinPoint) throws Throwable { long start = System.currentTimeMillis(); System.out.println("START: " + joinPoint.toString()); try { return joinPoint.proceed(); } finally { long finish = System.currentTimeMillis(); long timeMs = finish - start; System.out.println("END: " + joinPoint.toString()+ " " + timeMs + "ms"); } } }