Created
August 3, 2021 08:50
-
-
Save yooniversal/995168063a42ae31515123bea8079e5f to your computer and use it in GitHub Desktop.
AOP 적용 : TimeTraceAop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
@Aspect | |
@Component | |
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"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment