์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- ๋ฐฑ์ค9012
- ๋ฐฐ์ด
- stream
- ๋ฐฑ์ค9093
- StringBuffer
- StringBuilder
- java
- ์ฟ ํกERD
- ์
- ์ฐ
- ์ฐ์ฐ์
- ๋
- ์๋ฐ
- ์ฟ ํกDB
- ๋ฐ์ดํฐํ์
- ํ๋ฐฉ์ฟผ๋ฆฌ
- ๋ฌธ์์ด
- ๋ฐฑ์ค1874
- ์คํ
- ์คํ์์ด
- ๋ฐฑ์ค11053 #ํ์ด์ฌ #python
- ์คํธ๋ฆผ
- Today
- Total
Tech Log ๐ ๏ธ
Application Context VS Bean Factory ๋ณธ๋ฌธ
0. ์คํ๋ง ์ปจํ ์ด๋๋? or IOC Container
- DI ์ ์ด์ฉํ์ฌ ์ ํ๋ฆฌ์ผ์ด์ ์ ๊ตฌ์ฑํ๋ ์ฌ๋ฌ ๋น(Bean)๋ค์ ์๋ช ์ฃผ๊ธฐ(Lifecycle)์ ์ ํ๋ฆฌ์ผ์ด์ ์ ์๋น์ค ์คํ ๋ฑ์ ๊ด๋ฆฌํ๋ฉฐ
์์ฑ๋ ์ธ์คํด์ค๋ค์๊ฒ ๊ธฐ๋ฅ์ ์ ๊ณต
- Bean ์์ฑ, ๊ด๋ฆฌ, ์ ๊ฑฐ ๋ฑ์ ์ญํ ์ ๋ด๋น
- BeanFactory์ ApplicationContext๋ผ๋ 2๊ฐ์ ์ปจํ ์ด๋๋ก ์ ์ดํ๊ณ ๊ด๋ฆฌํ๋ค.
1. Bean Factory๋?
Bean Factory๋ ์คํ๋ง ์ปจํ ์ด๋์ ์ต์์ ์ธํฐํ์ด์ค์ด๋ฉฐ ๋น์ ๊ด๋ฆฌํ๊ณ ์กฐํํ๋ค.
getBean ๋ฉ์๋๋ฅผ ํตํด์ ๋น์ ์ธ์คํด์คํ ํ ์ ์๋ค.
์คํ๋ง์์ ๋น์ ๊ด๋ฆฌํ๊ธฐ ์ํ ๊ธฐ๋ณธ ์ปจํ ์ด๋์ด๋ค.
- ์คํ๋ง ์ปจํ
์ด๋์ ์ต์์ ์ธํฐํ์ด์ค๋ค.
- ์คํ๋ง ๋น์ ๊ด๋ฆฌํ๊ณ ์กฐํํ๋ ์ญํ ์ ๋ด๋นํ๋ค.
- getBean() ์ ์ ๊ณตํ๋ค.
- IoC์ ๊ธฐ๋ณธ ๊ธฐ๋ฅ์ ์ด์
2. Application Context ๋?
Application Context๋ Bean Factory์ ๋ชจ๋ ๊ธฐ๋ฅ ์์ํ๋ฉด์ ์ฌ๋ฌ ๋ถ๊ฐ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ ์ปจํ ์ด๋์ด๋ค.
- BeanFactory ๊ธฐ๋ฅ์ ๋ชจ๋ ์์๋ฐ์์ ์ ๊ณตํ๋ค.
- ์ฌ๋ฌ ๋ถ๊ฐ ๊ธฐ๋ฅ๋ค์ ์ ๊ณตํ๋ค.
- ๋น์ ์์ฑ, ๊ด๊ณ ์ค์ ๋ฑ์ ์ ์ด๋ฅผ ์ด๊ดํ๋ ๊ฒ์ ์ด์
3. ๊ณตํต์
- ์ ๊ณต๋ Bean ์ ์ ๋ฐ ๊ตฌ์ฑ์ ๊ธฐ๋ฐ์ผ๋ก Bean ์ธ์คํด์ค๋ฅผ ์์ฑํ๊ณ ๊ด๋ฆฌ
- ๋น์ ์์ฑ , ์ด๊ธฐํ ๋ฐ ์๋ฉธ์ ํฌํจํ์ฌ ๋น์ ์๋ช ์ฃผ๊ธฐ๋ฅผ ์ฒ๋ฆฌ
4. ์ฐจ์ด์
A. ๊ธฐ๋ฅ์ ์ฐจ์ด
์ ํ๋ฆฌ์ผ์ด์ ์ ๊ฐ๋ฐํ ๋๋ ๋น์ ๊ด๋ฆฌํ๊ณ ์กฐํํ๋ ๊ธฐ๋ฅ์ ๋ฌผ๋ก ์ด๊ณ , ์ ๋ง์ ๋ถ๊ฐ๊ธฐ๋ฅ๋ค์ ์ ๊ณตํ๋ค.
MessageSouce
- ๋ฉ์์ง์์ค๋ฅผ ํ์ฉํ ๊ตญ์ ํ ๊ธฐ๋ฅ
EnvinromentalCapable
- ๋ก์ปฌ, ๊ฐ๋ฐ, ์ด์๋ฑ์ ๊ตฌ๋ถํด์ ์ฒ๋ฆฌ
ApplicationPublisher
- ์ ํ๋ฆฌ์ผ์ด์ ์ด๋ฒคํธ ํ๋ก๊ทธ๋๋ฐ์ ํ์ํ ๊ธฐ๋ฅ์ ์ ๊ณต
ResouceLoader
- ํธ๋ฆฌํ ๋ฆฌ์์ค ์กฐํ ๊ธฐ๋ฅ ์ ๊ณต
B. ๋น ๋ก๋ฉ์์ ์ ์ฐจ์ด
Bean Factory : Lazy Loading
- ํ์ ์์ ๋น์ ๋ก๋ฉํ๋ค.
Application Context : Eager Loading
- ๋ฐํ์ ์คํ ์์ ๋ชจ๋ ๋น์ ๋ก๋ฉํ๋ค.
C. ๊ตฌ์ฑ์ ์ฐจ์ด
BeanFactory๋ ์ฃผ๋ก XML ์ ํตํด ๊ตฌํ๋๋ค.
Application Context๋ XML ์ธ์๋ ์๋ฐ ์ฝ๋๋ ์ด๋ ธํ ์ด์ ๋ฑ์ผ๋ก ์ค์ ์ ๊ตฌ์ฑํ ์ ์๋ค.
5. ๊ฒฐ๋ก
Normally when building most applications in a J2EE-environment, the best option is to use the ApplicationContext
, since it offers all the features of the BeanFactory and adds on to it in terms of features, while also allowing a more declarative approach to use of some functionality, which is generally desirable.
- ์คํ๋ง ๊ณต์ ๋ฌธ์
ApplicationContext๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค. ApplicationContext๋ BeanFactory์ ๋ชจ๋ ๊ธฐ๋ฅ์ ์ ๊ณตํ๊ณ ๊ธฐ๋ฅ ์ธก๋ฉด์์ ์ถ๊ฐํ๊ณ ์ผ๋ถ ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ ๋ฐ ๋ ์ ์ธ์ ์ธ ์ ๊ทผ์ ํ์ฉํ๊ธฐ ๋๋ฌธ์ ๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ๋ฐ๋์งํ ๊ธฐ๋ฅ์ ๋๋ค.
๋ค๋ง ApplicationContext์ ๋ชจ๋ ๊ธฐ๋ฅ์ด ํ์ํ์ง ์๊ฑฐ๋ ๋ฉ๋ชจ๋ฆฌ ๊ด๋ฆฌ ์ ์ธ ์ธก๋ฉด์ด ์ค์ํ ๋๋ Bean Factory๊ฐ ์ ํธ๋ ์ ์๋ค.
์ฐธ๊ณ ์๋ฃ
https://www.geeksforgeeks.org/spring-difference-between-beanfactory-and-applicationcontext/
https://docs.spring.io/spring-framework/docs/1.2.x/reference/beans.html
'TIL' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋์์ธ ํจํด] ์ถ์ ํฉํ ๋ฆฌ ํจํด์ด๋? (0) | 2023.06.09 |
---|---|
StringBuilder VS StringBuffer (0) | 2023.06.04 |
[TIL] ์ธ์ ์ธ์ฆ๊ณผ ํ ํฐ ์ธ์ฆ ๋ฐฉ์ (0) | 2023.03.22 |
[java] ์ ๋ค๋ฆญ (0) | 2023.03.07 |
[java] ์คํธ๋ฆผ ์์ ์ฒ๋ฆฌ (0) | 2023.02.28 |