Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,26 @@ | ||
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 // config에 넣어서 쓰기도 함 | ||
@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"); | ||
} | ||
} | ||
} |