Search
Duplicate
๐ŸŒฑ

Springboot ์„œ๋ฒ„๊ฐ€ ๊ตฌ๋™๋  ๋•Œ

๋นˆ์„ ์ฝ๋Š” ๋ฐฉ๋ฒ•

ConfigurableApplicationContext ๋ฅผ ์„ ํƒํ•˜๋Š” ๋ฐฉ๋ฒ•
SpringApplication ์˜ run ์—์„œ
createApplicationContext() ๋ฅผ ํ†ตํ•ด ์„ ์ •๋œ๋‹ค.
createApplicationContext() ์—์„œ๋Š” SpringApplication ์ด ์ƒ์„ฑ๋  ๋•Œ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์ƒ์„ฑ๋œ ApplicationContextFactory ๋กœ applicationContext ๋ฅผ ๋งŒ๋“ ๋‹ค. ๋งŒ๋“ค ๋•Œ webApplicationType(enum) ์„ ์ธ์ž๋กœ ์ฃผ๋Š”๋ฐ, ์ด ์ธ์ž๋Š” SpringApplication ์˜ ์ƒ์„ฑ์ž์—์„œ deduceFromClasspath() ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด ์„ค์ •๋œ๋‹ค.
ํ•ด๋‹น ๋ฉ”์„œ๋“œ์—์„œ๋Š” DispatcherHandler ๊ฐ€ class loader ์— ์žˆ๊ณ , DispatcherServlet ๊ณผ ServletContainer ๊ฐ€ ์—†์–ด์•ผ REACTIVE ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ณ  ์•„๋‹ˆ๋ฉด SERVLET ์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
ApplicationContextFactory ์˜ ๊ตฌํ˜„์ฒด๋Š” DefaultApplicationContextFactory ์ธ๋ฐ, ์—ฌ๊ธฐ์„œ create ๋ฅผ ํ•œ๋‹ค. ๊ฒฐ๊ณผ์ ์œผ๋กœ context ๋Š” AnnotationConfigReactiveWebServerApplicationContext ์ด ์„ ์ •๋œ๋‹ค.

๋นˆ์€ ์–ธ์ œ ๋“ฑ๋ก๋ ๊นŒ

โ€ข
SpringApplication.createApplicationContext()
โ—ฆ
DefaultApplicationContextFactory.create()
โ—ฆ
DefaultApplicationContextFactory.getFromSpringFactories()
โ—ฆ
ReactiveWebServerApplicationContextFactory.create(WebApplicationType)
โ—ฆ
ReactiveWebServerApplicationContextFactory.createContext()
โ—ฆ
AnnotationConfigReactiveWebServerApplicationContext()
โ—ฆ
initAnnotationConfigReactiveWebServerApplicationContext. newAnnotatedBeanDefinitionReader(this) โ†’ this = ACRWSAC
โ—ฆ
init AnnotatedBeanDefinitionReader.AnnotationConfigUtils.registerAnnotationConfigProcessors()
โ—ฆ
AnnotationConfigUtils.registerAnnotationConfigProcessors()
โ—ฆ
AnnotationConfigUtils.registerPostProcessor()
โ—ฆ
registry.registerBeanDefinition() registry โ†’ GenericApplicationContext
โ—ฆ
GenericApplicationContext.registerBeanDefinition()
โ—ฆ
DefaultListableBeanFactory.registerBeanDefinition()

๋นˆ์€ ์–ด๋””์„œ ๋“ฑ๋ก๋ ๊นŒ

DefaultListableBeanFactory ์˜ registerBeanDefinition