AOP?

์ด์ข…์ฐฌยท2023๋…„ 2์›” 10์ผ
0
post-custom-banner

๐Ÿ“– AOP?

AOP(Aspect-Oriented Programming) ๊ด€์  ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋žจ์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๊ต์ฐจ ์ ˆ๋‹จ ๋ฌธ์ œ๋ฅผ ๋ชจ๋“ˆํ™”ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํŒจ๋Ÿฌ๋‹ค์ž„์ž…๋‹ˆ๋‹ค. ์ฆ‰, ๊ฐœ๋ฐœ์ž๊ฐ€ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ๋™์ž‘์˜ ํŠน์ • ๋ถ€๋ถ„์— ์—ฐ๊ฒฐ๋˜์ง€ ์•Š์€ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์˜ ๋ฌธ์ œ๋ฅผ ๋ถ„๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์Šคํ”„๋ง ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์€ ๋Œ€๋ถ€๋ถ„ MVC ์›น์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. Web Layer, Business Layer, Data Layer๋กœ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

Web Layer : REST API๋ฅผ ์ œ๊ณตํ•˜๋ฉฐ, Client ์ค‘์‹ฌ์˜ ๋กœ์ง์„ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.

Business Layer : ๋‚ด๋ถ€ ์ •์ฑ…์— ๋”ฐ๋ฅธ ๋กœ์ง์„ ๊ฐœ๋ฐœํ•˜๋ฉฐ, ์ฃผ๋กœ ํ•ด๋‹น ๋ถ€๋ถ„์„ ๊ฐœ๋ฐœํ•ฉ๋‹ˆ๋‹ค.

Data Layer : ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ๋ฐ ์™ธ๋ถ€์™€์˜ ์—ฐ๋™์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

Spring AOP๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐœ๋ฐœ์ž๋Š” ์ผ๋ฐ˜์ ์ธ ๊ธฐ๋Šฅ์„ ์บก์Šํ™”ํ•˜๋Š” ํด๋ž˜์Šค์ธ Aspect๋ฅผ ์ •์˜ํ•˜๊ณ  ํฌ์ธํŠธ์ปท๊ณผ ์–ด๋“œ๋ฐ”์ด์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋‹ค๋ฅธ ๋ถ€๋ถ„์— ์ด๋Ÿฌํ•œ aspect๋ฅผ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํฌ์ธํŠธ์ปท์€ ๊ด€์ ์ด ์ ์šฉ๋˜์–ด์•ผ ํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰์˜ ํŠน์ • ์ง€์ ์ธ ๊ฒฐํ•ฉ ์ง€์ ์„ ์ •์˜ํ•˜๊ณ  ์–ด๋“œ๋ฐ”์ด์Šค๋Š” ์ด๋Ÿฌํ•œ ๊ฒฐํ•ฉ ์ง€์ ์—์„œ ์ทจํ•ด์•ผ ํ•˜๋Š” ์กฐ์น˜๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ ๋ฐฉ์‹์œผ๋กœ Spring์˜ AOP๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐœ๋ฐœ์ž๊ฐ€ ๊ด€์‹ฌ์‚ฌ๋ฅผ ๋ถ„๋ฆฌํ•˜๊ณ  ์ฝ”๋“œ๋ฅผ ์ฒด๊ณ„์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ ์šฉ์ดํ•ฉ๋‹ˆ๋‹ค.

โœ… ํŠน์ง•

1. Aspect ๊ฐ€๋กœ์ฑ„๊ธฐ

Aspect๋ฅผ ํ†ตํ•ด ๋ฉ”์„œ๋“œ ํ˜ธ์ถœ์„ ๊ฐ€๋กœ์ฑ„ ๋ฉ”์„œ๋“œ ์ด์ „, ์ดํ›„, ๋˜๋Š” ๊ฐ€๋กœ์ฑˆ ํ˜ธ์ถœ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋งค์ปค๋‹ˆ์ฆ˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ํ™œ์šฉํ•˜์—ฌ ๋ฉ”์„œ๋“œ์˜ ๋กœ๊น… ๋ฐ ๊ตฌ์„ฑ์š”์†Œ๋ฅผ ์žฌ์‚ฌ์šฉ ๋ฐ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

2. ํฌ์ธํŠธ ์ปท ํ‘œํ˜„์‹

AOP๋Š” ํฌ์ธํŠธ์ปท ํ‘œํ˜„์‹์„ ์ •์˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ํฌ์ธํŠธ์ปท ํ‘œํ˜„์‹์€ ์กฐ์ธ ํฌ์ธํŠธ ๋˜๋Š” ๊ด€์ ์ด ์ ์šฉ๋˜์–ด์•ผ ํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰์˜ ํŠน์ง• ์ง€์ ๊ณผ ์ผ์น˜ํ•˜๋Š” ํŒจํ„ด์ž…๋‹ˆ๋‹ค.

๐Ÿ“– ์ข…๋ฅ˜

  • execution : ๋ฉ”์„œ๋“œ ์‹คํ–‰ ์กฐ์ธ ํฌ์ธํŠธ๋ฅผ ๋งค์นญํ•ฉ๋‹ˆ๋‹ค. ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉํ•˜๋Š” ๋งŒํผ ๊ธฐ๋Šฅ๋„ ๋ณต์žกํ•œ ํŽธ์ž…๋‹ˆ๋‹ค.
  • within : ํŠน์ • ํƒ€์ž… ๋‚ด์˜ ์กฐ์ธ ํฌ์ธํŠธ๋ฅผ ๋งค์นญํ•ฉ๋‹ˆ๋‹ค.
  • args : ์ธ์ž๊ฐ€ ์ฃผ์–ด์ง„ ํƒ€์ž…์˜ ์ธ์Šคํ„ด์Šค์ธ ์กฐ์ธ ํฌ์ธํŠธ
  • this : ์Šคํ”„๋ง ๋นˆ ๊ฐ์ฒด(์Šคํ”„๋ง AOP ํ”„๋ก์‹œ)๋ฅผ ๋Œ€์ƒ์œผ๋กœ ํ•˜๋Š” ์กฐ์ธ ํฌ์ธํŠธ
  • target : Target ๊ฐ์ฒด (์Šคํ”„๋ง AOP ํ”„๋ก์‹œ๊ฐ€ ๊ฐ€๋ฆฌํ‚ค๋Š” ์‹ค์ œ ๋Œ€์ƒ)๋ฅผ ๋Œ€์ƒ์œผ๋กœ ํ•˜๋Š” ์กฐ์ธ ํฌ์ธํŠธ
  • @target : ์‹คํ–‰ ๊ฐ์ฒด์˜ ํด๋ž˜์Šค์— ์ฃผ์–ด์ง„ ํƒ€์ž…์˜ ์–ด๋…ธํ…Œ์ด์…˜์ด ์žˆ๋Š” ์กฐ์ธ ํฌ์ธํŠธ
  • @within : ์ฃผ์–ด์ง„ ์–ด๋…ธํ…Œ์ด์…˜์ด ์žˆ๋Š” ํƒ€์ž… ๋‚ด ์กฐ์ธ ํฌ์ธํŠธ
  • @annotation : ๋ฉ”์„œ๋“œ๊ฐ€ ์ฃผ์–ด์ง„ ์–ด๋…ธํ…Œ์ด์…˜์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์กฐ์ธ ํฌ์ธํŠธ๋ฅผ ๋งค์นญ
  • @args : ์ „๋‹ฌ๋œ ์‹ค์ œ ์ธ์ˆ˜์˜ ๋Ÿฐํƒ€์ž„ ํƒ€์ž…์ด ์ฃผ์–ด์ง„ ํƒ€์ž…์˜ ์–ด๋…ธํ…Œ์ด์…˜์„ ๊ฐ–๋Š” ์กฐ์ธ ํฌ์ธํŠธ
  • bean : ์Šคํ”„๋ง ์ „์šฉ ํฌ์ธํŠธ์ปท ์ง€์‹œ์ž, bean์˜ ์ด๋ฆ„์œผ๋กœ ํฌ์ธํŠธ์ปท์„ ์ง€์ •

3.๋™์ ,์„ ์–ธ์ 

AOP๋Š” ๋Ÿฐํƒ€์ž„ ์‹œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์ธก๋ฉด์„ ์ ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์— ๋™์ ์ž…๋‹ˆ๋‹ค. ๋น„๋ช…๋ น์  ๋ฐฉ์‹์œผ๋กœ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋™์ž‘์„ ์ง€์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•œ๋‹ค๋Š” ์ ์—์„œ ์„ ์–ธ์ ์ž…๋‹ˆ๋‹ค.

4.Cross-Cutting Concerns์˜ ๋ชจ๋“ˆํ™”

AOP๋Š” ๋กœ๊น…, ๋ณด์•ˆ ๋ฐ ํŠธ๋žœ์žญ์…˜ ๊ด€๋ฆฌ์™€ ๊ฐ™์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์—ฌ๋Ÿฌ ๋ถ€๋ถ„์˜ ๊ณตํ†ต์ ์ธ ๋ฌธ์ œ๋ฅผ aspect๋ผ๋Š” ์žฌ์‚ฌ์šฉ ๋ฐ ์œ ์ง€ ๊ด€๋ฆฌ ๊ฐ€๋Šฅํ•œ ์ฝ”๋“œ ๋‹จ์œ„๋กœ ๋ชจ๋“ˆํ™” ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

**๐Ÿ™‚ AOP๋Š” ๊ต์ฐจ ์ ˆ๋‹จ ๋ฌธ์ œ๋ฅผ ๋ชจ๋“ˆํ™”ํ•˜๊ณ  ํ•ต์‹ฌ ์‘์šฉํ”„๋กœ๊ทธ๋žจ ๋กœ์ง์—์„œ ๋ถ„๋ฆฌํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ๋ณด๋‹ค ์ฒด๊ณ„ํ™” -> ์œ ์ง€ ๊ด€๋ฆฌ ๋ฐ ์žฌ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.


โœ… ์•Œ์•„์•ผ ํ•˜๋Š” Annotation

  • @Aspect : ์ž๋ฐ”์—์„œ ๋„๋ฆฌ ์‚ฌ์šฉํ•˜๋Š” AOP ํ”„๋ ˆ์ž„์›Œํฌ์— ํฌํ•จ๋˜๋ฉฐ, AOP๋ฅผ ์ •์˜ํ•˜๋Š” Class์— ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค.
  • @Pointcut : ๊ธฐ๋Šฅ์„ ์–ด๋””์— ์ ์šฉ์‹œํ‚ฌ์ง€, ๋ฉ”์†Œ๋“œ, Annotation ๋“ฑ AOP๋ฅผ ์ ์šฉ ์‹œํ‚ฌ ์ง€์ ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
  • @Before : ๋ฉ”์†Œ๋“œ ์‹คํ–‰ํ•˜๊ธฐ ์ด์ „
  • @After : ๋ฉ”์†Œ๋“œ๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ์‹คํ–‰ ํ›„, ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒ ๋˜๋”๋ผ๋„ ์‹คํ–‰
  • @AfterReturing : ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ ์„ฑ๊ณต ์‹คํ–‰ ์‹œ (์˜ˆ์™ธ ๋ฐœ์ƒ ์ œ์™ธ)
  • @AfterThrowing : ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ ์‹คํŒจ ์˜ˆ์™ธ ๋ฐœ์ƒ
  • @Around : Before / After ๋ชจ๋‘ ์ œ์–ด

๐Ÿ˜ฎ ์‚ฌ์šฉ๋˜๋Š” ์‚ฌ๋ก€

Spring์˜ Context์—์„œ AOP๋Š” ์—ฌ๋Ÿฌ ์œ„์น˜์—์„œ ๋™์ผํ•œ ์ฝ”๋“œ๋ฅผ ๋ฐ˜๋ณตํ•  ํ•„์š” ์—†์ด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์—ฌ๋Ÿฌ ๋ถ€๋ถ„์—์„œ ํ•„์š”ํ•œ ๋ณด์•ˆ, ๋กœ๊น…, ํŠธ๋žœ์žญ์…˜ ๊ด€๋ฆฌ์™€ ๊ฐ™์€ ๊ณตํ†ต ์„œ๋น„์Šค, ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

โŒ ๋ฌธ์ œ๊ฐ€ ๋˜๋Š” ๊ฒฝ์šฐ

  1. aspect ๊ฐ€๋กœ์ฑ„๊ธฐ ๋ฉ”์ปค๋‹ˆ์ฆ˜์ด ๋ฉ”์„œ๋“œ ํ˜ธ์ถœ์— ์ถ”๊ฐ€ ์ฒ˜๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์‹คํ–‰ ์‹œ๊ฐ„์„ ๋Šฆ์ถœ ์ˆ˜ ์žˆ์–ด ์„ฑ๋Šฅ ์˜ค๋ฒ„ํ—ค๋“œ๋ฅผ ๋„์ž…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

  2. AOP๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋””๋ฒ„๊น… ๋ฐ ํ…Œ์ŠคํŠธ๊ฐ€ ๋” ์–ด๋ ค์šธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. aspect๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์˜ ๋™์ž‘์— ์˜ˆ๊ธฐ์น˜ ๋ชปํ•œ ๋ฐฉ์‹์œผ๋กœ ์˜ํ–ฅ์„ ์ค„ ์ˆ˜๋„ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ์ฆ‰, AOP์— ๋Œ€ํ•œ ์ดํ•ด๋„๊ฐ€ ๋†’์•„์•ผํ•˜๋ฉฐ ๊ทธ๋ ‡์ง€ ์•Š์€ ๊ฒฝ์šฐ ํ…Œ์ŠคํŠธํ•˜๊ธฐ ๋” ์–ด๋ ค์›Œ์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ‘จโ€๐Ÿ’ป ๊ตฌํ˜„

api ์‹คํ–‰์‹œ๊ฐ„์„ ์ถœ๋ ฅํ•˜๋Š” aop๋ฅผ ๊ตฌํ˜„ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

Timer

@Target({ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Timer {
	
}

Timer ์–ด๋…ธํ…Œ์ด์…˜์„ ๋งŒ๋“ค์–ด api ํ˜ธ์ถœ ํ•  ๋•Œ ์‹คํ–‰๋˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

@Target์€ annotation์ด ์–ด๋””์— ์ ์šฉ๋ ์ง€ ์ •ํ•˜๋Š” ์—ญํ• ์ž…๋‹ˆ๋‹ค. ElementType.METHOD๋Š” ๋ฉ”์„œ๋“œ์— ์ ์šฉํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค.

@Retention ์‹ค์ œ๋กœ ์ ์šฉ๋˜๊ณ  ์žˆ๋Š” ๋ฒ”์œ„๋ฅผ ์ •ํ•˜๋Š” ์–ด๋…ธํ…Œ์ด์…˜์ด๋ฉฐ RetentionPolicy.RUNTIME์€ ์ปดํŒŒ์ผ ์ดํ›„์—๋„ JVM์— ์˜ํ•ด ์ง€์†๋œ๋‹ค๋Š” ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.

controller

api ํ˜ธ์ถœํ•  ๋•Œ ์ด์ „์— ๋งŒ๋“  @Timer๋ฅผ ์จ์ค๋‹ˆ๋‹ค.

@RestController
@RequestMapping("/api")
public class RestApiController {
    @Timer
    @DeleteMapping("/delete")
    public void delete() throws InterruptedException {
        Thread.sleep(1000L * 2);// db logic 1 sec ๋ผ๊ณ  ๊ฐ€์ •
    }
}

TimerAop

@Aspect
@Component
public class TimerAop {
    @Pointcut("execution(* com.example.aoptest.controller..*.*(..))")
    private void cut() {

    }

    //annotation์—๋งŒ ๋กœ๊น…
    @Pointcut("@annotation(com.example.aoptest.annotation.Timer)")
    private void enableTimer() {

    }

    //๋‘๊ฐ€์ง€ ์กฐ๊ฑด ๋‹ค ๋ณธ๋‹ค๋Š” ์˜๋ฏธ
    @Around("cut() && enableTimer()")
    public void around(ProceedingJoinPoint point) throws Throwable {
        StopWatch stopWatch = new StopWatch(); //์‹คํ–‰ ์ „
        stopWatch.start();
        Object obj = point.proceed();
        stopWatch.stop();
        System.out.println("total time : " + stopWatch.getTotalTimeSeconds());
    }
}

@Aspect๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ AOP ํด๋ž˜์Šค์ž„์„ ์ •์˜ํ•ด์ค๋‹ˆ๋‹ค.
@Component๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ bean๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ๊ด€๋ฆฌ ๊ถŒํ•œ์„ Spring์—๊ฒŒ ์œ„์ž„ํ•ด์ค๋‹ˆ๋‹ค.
ํฌ์ธํŠธ์ปท ํ‘œํ˜„์‹์„ ์‚ฌ์šฉ๋ฐฉ์‹์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

  • cut() : controller ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์žˆ๋Š” ๋ชจ๋“  ๊ฐ์ฒด์— ํ•ด๋‹น ๋˜๋„๋ก ์ง€์ •ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • enableTimer() : annotation ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์žˆ๋Š” Timer ์–ด๋…ธํ…Œ์ด์…˜ ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•˜๋Š” ๊ฐ์ฒด์—๊ฒŒ ํ•ด๋‹น ๋˜๋„๋ก ์ง€์ €ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

around()

ํ•ด๋‹น ๋ฉ”์„œ๋“œ์—์„œ ์Šคํƒ‘์›Œ์น˜๊ฐ€ ์‹คํ–‰๋˜๊ณ  @Timer๋ฅผ ์‚ฌ์šฉํ•œ controller์˜ ๋””๋ ‰ํ„ฐ๋ฆฌ์˜ ๋ฉ”์„œ๋“œ ์‹คํ–‰๋˜๊ณ  ๋๋งˆ์นœ ๊ธฐ๊ฐ„์„ ์ถœ๋ ฅํ•ด์ฃผ๋Š” ๋ฉ”์„œ๋“œ ์ž…๋‹ˆ๋‹ค.

ProceedingJoinPoint : JoinPoint์˜ ํ™•์žฅ ๋ฉ”์„œ๋“œ์ด๋ฉฐ proceed()๋ฅผ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Joinpoint์˜ ์—ญํ• ์€ Advice๊ฐ€ ์ ์šฉ๋  ์œ„์น˜, ๋ผ์–ด๋“ค ์ˆ˜ ์žˆ๋Š” ์ง€์ . ๋ฉ”์„œ๋“œ ์ง„์ž… ์ง€์ , ์ƒ์„ฑ์ž ํ˜ธ์ถœ ์‹œ์ , ํ•„๋“œ์—์„œ ๊ฐ’์„ ๊บผ๋‚ด์˜ฌ ๋•Œ ๋“ฑ ๋‹ค์–‘ํ•œ ์‹œ์ ์— ์ ์šฉ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

์‹คํ–‰๊ฒฐ๊ณผ

total time : 2.005126042

Thread.sleep(2000L)๋ฅผ ์‚ฌ์šฉํ•˜์˜€์œผ๋‹ˆ ๋‚˜๋จธ์ง€๊ฐ€ ์ง„์งœ ์‹คํ–‰์‹œ๊ฐ„์ด ๋ฉ๋‹ˆ๋‹ค.

โœ… ์š”์•ฝ

  • AOP๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๊ต์ฐจ ์ ˆ๋‹จ ๋ฌธ์ œ๋ฅผ ๋ชจ๋“ˆํ™”ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํŒจ๋Ÿฌ๋‹ค์ž„์ž…๋‹ˆ๋‹ค.
  • Aspect๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฉ”์„œ๋“œ๋ฅผ ๊ฐ€๋กœ์ฑ„ ๋กœ๊น…, ์žฌ์‚ฌ์šฉ๋“ฑ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
  • ํฌ์ธํŠธ์ปท์„ ํ™œ์šฉํ•˜์—ฌ ์‹คํ–‰ํ•  ์œ„์น˜ ๋ฐ ๋™์ž‘๋ฐฉ์‹์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
  • ๊ด€์‹ฌ์‚ฌ ๋ถ„๋ฆฌ๋ฅผ ์œ„ํ•œ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋ฉฐ ์ž˜ ํ™œ์šฉํ•˜๋ฉด ์ข‹์ง€๋งŒ ๊ทธ๋ ‡์ง€ ์•Š์€ ๊ฒฝ์šฐ ํ…Œ์ŠคํŠธ๊ฐ€ ๋” ์–ด๋ ค์›Œ์ง€๋ฉฐ ์„ฑ๋Šฅ ์˜ค๋ฒ„ํ—ค๋“œ๋ฅผ ์œ ๋ฐœํ•ฉ๋‹ˆ๋‹ค.
  • ๋งŽ์€ ์–ด๋…ธํ…Œ์ด์…˜, ํฌ์ธํŠธ์ปท ํฌํ˜„์‹์„ ์•Œ์•„์•ผํ•˜๋ฉฐ ์ ์žฌ์ ์†Œ์— ์ž˜ ์‚ฌ์šฉํ•ด์•ผ๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ญ๋‹ˆ๋‹ค.
profile
์™œ? ๋ผ๋Š” ์งˆ๋ฌธ์ด ์‚ฌ๋ผ์งˆ ๋•Œ๊นŒ์ง€
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€