Study

์Šคํ”„๋ง์ด ๋‹ค์–‘ํ•œ ์„ค์ • ํ˜•์‹์„(Annotation, xml, etc..) ์ง€์›ํ•  ์ˆ˜ ์žˆ๋Š” ์ด์œ  ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ๋Š” ๋ฉ”ํƒ€์ •๋ณด(beanDefinition)๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์Šคํ”„๋ง ๋นˆ์„ ์ƒ์„ฑํ•œ๋‹ค. XML์„ ์ฝ์–ด์„œ BeanDefinition์„ ๋งŒ๋“ค๋ฉด ๋œ๋‹ค. ์ž๋ฐ” ์ฝ”๋“œ๋ฅผ ์ฝ์–ด์„œ BeanDefinition์„ ๋งŒ๋“ค๋ฉด ๋œ๋‹ค. ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ๋Š” ์ž๋ฐ” ์ฝ”๋“œ์ธ์ง€, XML์ธ์ง€ ๋ชฐ๋ผ๋„ ๋œ๋‹ค. ์˜ค์ง BeanDefinition๋งŒ ์•Œ๋ฉด ๋œ๋‹ค. ๐Ÿ“Œ ์ƒˆ๋กœ์šด ํ˜•์‹์˜ ์„ค์ • ์ •๋ณด๊ฐ€ ์ถ”๊ฐ€๋˜๋ฉด, XxxBeanDefinitionReader๋ฅผ ๋งŒ๋“ค์–ด์„œ BeanDefinition์„ ์ƒ์„ฑํ•˜๋ฉด ๋œ๋‹ค. BeanDefinition BeanClassName: ์ƒ์„ฑํ•  ๋นˆ์˜ ํด๋ž˜์Šค ๋ช…(์ž๋ฐ” ์„ค์ • ์ฒ˜๋Ÿผ ํŒฉํ† ๋ฆฌ ์—ญํ• ์˜ ๋นˆ์„ ์‚ฌ์šฉํ•˜๋ฉด ์—†์Œ) factoryBeanName: ํŒฉํ† ..
BeanFactory์™€ ApplicationContext BeanFactory : ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ์˜ ์ตœ์ƒ์œ„ ์ธํ„ฐํŽ˜์ด์Šค. getBean() ์ œ๊ณต ApplicationContext BeanFactory์˜ ๊ธฐ๋Šฅ์„ ๋ชจ๋‘ ์ƒ์†๋ฐ›์•„์„œ ์‚ฌ์šฉ ์–ดํ”Œ๋ฆฌ์บ์ด์…˜์„ ๊ฐœ๋ฐœํ•  ๋•Œ ๋นˆ์„ ๊ด€๋ฆฌํ•˜๊ณ  ์กฐํšŒํ•˜๋Š” ๊ธฐ๋Šฅ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ, ์ˆ˜ ๋งŽ์€ ๋ถ€๊ฐ€๊ธฐ๋Šฅ์ด ํ•„์š”ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค ๋ฉ”์‹œ์ง€ ์†Œ์Šค๋ฅผ ํ™œ์šฉํ•œ ๊ตญ์ œํ™” ๊ธฐ๋Šฅ ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ด๋ฒคํŠธ ํŽธ๋ฆฌํ•œ ๋ฆฌ์†Œ์Šค ์กฐํšŒ ๊ทธ ์™ธ์˜ ์ฐจ์ด์  Lazy Loading(BeanFactory) vs. Eager Loading(ApplicationContext) BeanFactory loads beans on-demand, while ApplicationContext loads all beans at star..
์Šคํ”„๋ง ๋นˆ ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ์—์„œ ๊ด€๋ฆฌํ•˜๋Š” ๊ฐ์ฒด In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC container are called beans. A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC container. - the Spring Framework documentation ์ปจํ…Œ์ด๋„ˆ์— ๋“ฑ๋ก๋œ ๋ชจ๋“  ๋นˆ ์กฐํšŒ ๋ชจ๋“  ๋นˆ ์ถœ๋ ฅํ•˜๊ธฐ @Test @DisplayName("๋ชจ๋“  ๋นˆ ์ถœ๋ ฅํ•˜๊ธฐ") void findAllBean(){ String[] beanDefiniti..
์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); ApplicationContext๋ฅผ ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ๋ผ ํ•œ๋‹ค. ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ๋Š” @Configuration์ด ๋ถ™์€ AppConfig๋ฅผ ์„ค์ •์ •๋ณด๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ์—ฌ๊ธฐ์„œ @Bean์ด๋ผ ์ ํžŒ ๋ฉ”์„œ๋“œ๋ฅผ ๋ชจ๋‘ ํ˜ธ์ถœํ•ด์„œ ๋ฐ˜ํ™˜๋œ ๊ฐ์ฒด๋ฅผ ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ์— ๋“ฑ๋กํ•œ๋‹ค. ์ด๋ ‡๊ฒŒ ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ์— ๋“ฑ๋ก๋œ ๊ฐ์ฒด๋ฅผ ์Šคํ”„๋ง ๋นˆ์ด๋ผ๊ณ  ํ•œ๋‹ค. ์Šคํ”„๋ง ๋นˆ์€ @Bean์ด ๋ถ™์€ ๋ฉ”์„œ๋“œ์˜ ๋ช…์„ ์Šคํ”„๋ง ๋นˆ์˜ ์ด๋ฆ„์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค ์Šคํ”„๋ง ๋นˆ์€ applicationContext.getBean() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ฐพ์„ ์ˆ˜ ์žˆ๋‹ค ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ๋Š” XML ๊ธฐ๋ฐ˜์œผ๋กœ ๋งŒ๋“ค ์ˆ˜..
1๏ธโƒฃ ์ œ์–ด์˜ ์—ญ์ „ IoC, Inversion of Control ๊ธฐ์กด ํ”„๋กœ๊ทธ๋žจ์€ ํด๋ผ์ด์–ธํŠธ ๊ตฌํ˜„ ๊ฐ์ฒด๊ฐ€ ์Šค์Šค๋กœ ํ•„์š”ํ•œ ์„œ๋ฒ„ ๊ตฌํ˜„ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ณ (new๋กœ ์ง์ ‘ ์ƒ์„ฑ), ์—ฐ๊ฒฐํ•˜๊ณ , ์‹คํ–‰ํ–ˆ๋‹ค. ๋ฐ˜๋ฉด์— AppConfig๊ฐ€ ๋“ฑ์žฅํ•œ ์ดํ›„์— ๊ตฌํ˜„ ๊ฐ์ฒด๋Š” ์ž์‹ ์˜ ๋กœ์ง์„ ์‹คํ–‰ํ•˜๋Š” ์—ญํ• ๋งŒ ๋‹ด๋‹นํ•œ๋‹ค. ํ”„๋กœ๊ทธ๋žจ์˜ ์ œ์–ด ํ๋ฆ„์„ AppConfig๊ฐ€ ๊ฐ€์ ธ๊ฐ„ ๊ฒƒ์ด๋‹ค. ํด๋ผ์ด์–ธํŠธ ๊ฐ์ฒด๋Š” ํ•„์š”ํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋“ค์„ ํ˜ธ์ถœํ•˜์ง€๋งŒ ์–ด๋–ค ๊ตฌํ˜„ ๊ฐ์ฒด๊ฐ€ ์‹คํ–‰๋ ์ง€๋Š” ๋ชจ๋ฅธ๋‹ค. ํ”„๋กœ๊ทธ๋žจ์— ๋Œ€ํ•œ ์ œ์–ด ํ๋ฆ„์€ ๋ชจ๋‘ AppConfig๊ฐ€ ๊ฐ€์ง€๊ณ  ์žˆ๊ฒŒ ๋œ๋‹ค. ์ด๋ ‡๋“ฏ ํ”„๋กœ๊ทธ๋žจ์˜ ์ œ์–ด ํ๋ฆ„์„ ์ง์ ‘ ์ œ์–ดํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์™ธ๋ถ€์—์„œ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ์„ ์ œ์–ด์˜ ์—ญ์ „์ด๋ผ ํ•œ๋‹ค. This chapter covers the Spring Framework implementation o..
YURI๐Ÿ•๐Ÿ“๐Ÿถ
'Study' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (8 Page)