Search
Duplicate
๐ŸŒฑ

Conditional

๋ฌธ์ œ์ 

ํ˜„์žฌ @PerformanceTracker ๋ฅผ ๋ถ™์ด๋ฉด ๋นˆ์œผ๋กœ ๋“ฑ๋ก๋˜๋Š” ํด๋ž˜์Šค๋“ค์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.
ํ•„์š”ํ•˜์ง€ ์•Š์€๋ฐ๋„, ๋ชจ๋‘ @Component ๋ฅผ ๋ถ™์—ฌ์„œ ๋นˆ์œผ๋กœ ๋“ฑ๋ก์ด ๋œ๋‹ค.
โ†’ ์ด๋ฅผ @Conditional ๊ณผ properties ๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ฐœ์„ ํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค.

๊ฐœ์„  ๋ฐฉ์•ˆ

1.
accumulator, result mapper, object mapper ๋Š” performance tracker ๊ธฐ๋Šฅ์˜ ๊ฐ€์žฅ ๊ทผ๊ฐ„์ด ๋˜๋Š” ํด๋ž˜์Šค๋กœ ์–ธ์ œ๋‚˜ ๋“ฑ๋ก์ด ๋˜๋„๋ก ํ•œ๋‹ค.
2.
web, query, rest ๋Š” ๋งค๋ฒˆ ๋นˆ์œผ๋กœ ๋“ฑ๋ก๋  ํ•„์š”๊ฐ€ ์—†๋‹ค.
a.
data jpa test ๋ฅผ ํ•œ๋‹ค๋ฉด interceptor ์— ์ ‘๊ทผํ•˜์ง€ ์•Š์•„ ์ธก์ •์„ ์•„์˜ˆ ํ•˜์ง€ ์•Š์ง€๋งŒ web ๊ณผ rest ๊ด€๋ จ ๋นˆ๋“ค์ด ๋“ฑ๋ก๋œ๋‹ค.
b.
์ด์— ๋”ฐ๋ผ ํ˜„์žฌ ํŒจํ‚ค์ง€๊ฐ€ web, query, rest ๋กœ ๋‚˜๋ˆ ์ ธ์žˆ๊ธฐ๋•Œ๋ฌธ์— @Conditional ๊ณผ @ComponentScan ์„ ์ด์šฉํ•˜์—ฌ ๋นˆ์œผ๋กœ ๋“ฑ๋ก๋  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.
3.
descriptor ๊ด€๋ จ ๋นˆ์€ @ConfigurationProperties, @ConditionalOnProperty, properties ๋ฅผ ํ†ตํ•ด logging ๋˜๋Š” json ์œผ๋กœ ์„ ํƒ์ ์œผ๋กœ ๋นˆ ๋“ฑ๋ก์ด ๋œ๋‹ค.
4.
context manager
a.
๊ธฐ์กด์—๋Š” context manager ๋ฅผ ๋ชจ๋‘ ๋นˆ์œผ๋กœ ๋“ฑ๋กํ•˜๊ณ  @PerformanceTracker ์˜ ์˜ต์…˜์œผ๋กœ ์‚ฌ์šฉ์ž๊ฐ€ context ๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜์˜€๋‹ค.
b.
๋ชจ๋‘ ๋“ฑ๋กํ•  ํ•„์š”๊ฐ€ ์—†๊ธฐ๋„ ํ•˜๊ณ  class ๋งˆ๋‹ค context ๋ฅผ ๋ฐ”๊ฟ€ ์š”๊ตฌ๋„ ๋“œ๋ฌผ๋‹ค๊ณ  ํŒ๋‹จํ•˜์—ฌ context manager ๋˜ํ•œ properties ๋กœ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.
c.
Condition ์„ ๊ตฌํ˜„ํ•˜์—ฌ ์ปค์Šคํ…€ ์–ด๋…ธํ…Œ์ด์…˜์„ ๋งŒ๋“ค์–ด ์„ ํƒ์ ์œผ๋กœ ๋นˆ ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.
d.
๋”์šฑ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์ด ํŽ˜์ด์ง€