๐Ÿƒ Spring Basic

๐Ÿƒ Spring

POJO ํŠน์ • ํด๋ž˜์Šค๋ฅผ ์ƒ์†ํ•˜๊ฑฐ๋‚˜ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•˜์ง€ ์•Š๋Š” ํ‰๋ฒ”ํ•œ ์ž๋ฐ” ํด๋ž˜์Šค(๋Š์Šจํ•œ ๊ฒฐํ•ฉ) ๋ฅผ ์ด์šฉํ•˜๋ฉฐ ๋‹จ์ˆœํ•˜์ง€๋งŒ EJB์—์„œ ์ œ๊ณตํ•˜๋Š” ๊ณ ๊ธ‰ ๊ธฐ์ˆ ์„ ์ œ๊ณตํ•œ๋‹ค.

โœ”๏ธ EJB์˜ ๋ฌด๊ฑฐ์› ๋˜ ๋‹จ์ ์„ ๋ณด์™„ํ•ด ๋‚˜์˜จ Spring์€ ๊ฒฝ๋Ÿ‰๊ธ‰ ํ”„๋ ˆ์ž„์›Œํฌ๋กœ RELEASE๋˜์—ˆ๋‹ค.

๐Ÿคพ ์ฃผ์š” ์ „๋žต

1. POJO๋ฅผ ์ด์šฉํ•œ ๊ฐ€๋ณ๊ณ (lightweight) ๋น„์นจํˆฌ์ (non-invasive) ๊ฐœ๋ฐœ

2. DI์™€ ์ธํ„ฐํŽ˜์ด์Šค ์ง€ํ–ฅ์„ ํ†ตํ•œ ๋Š์Šจํ•œ ๊ฒฐํ•ฉ๋„(loose coupling)

3. Aspect์™€ ๊ณตํ†ต ๊ทœ์•ฝ์„ ํ†ตํ•œ ์„ ์–ธ์ (declarative) ํ”„๋กœ๊ทธ๋ž˜๋ฐ

4. Aspect์™€ ํ…œํ”Œ๋ฆฟ(template)์„ ํ†ตํ•œ ๋ฐ˜๋ณต์ ์ด๊ณ  ์ƒํˆฌ์ ์ธ(boilerplate) ์ฝ”๋“œ ์ œ๊ฑฐ

๐Ÿ“ฆ Container

๊ฐ์ฒด๊ด€๋ฆฌ๋ฅผ ์ฃผ๋กœ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ทธ๋ฆ‡์œผ๋กœ ๋นˆ์˜ ์ƒ์„ฑ๊ณผ ๊ด€๊ณ„, ์‚ฌ์šฉ, ์ƒ๋ช… ์ฃผ๊ธฐ๋“ฑ์„ ๊ด€์žฅํ•˜๋Š”๊ณณ. ํ”„๋กœ์ ํŠธ๋‚ด์˜ ์ˆ˜๋งŽ์€ ๊ฐ์ฒด๋“ค์„ ์ƒ์„ฑํ•˜๊ธฐ์œ„ํ•œ new, getter/setter ๋“ค์€ ๊ฐ์ฒด๋“ค๋ผ๋ฆฌ ์„œ๋กœ ์ฐธ์กฐ๋˜๊ณ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ƒํƒœ๋ฅผ ์˜์กด์„ฑ์ด ๋†’์€ ๊ฒฐํ•ฉ๋„๋ฅผ ๋ˆ๋‹ค๋ผ๊ณ  ํ‘œํ˜„ํ•˜๋Š”๋ฐ, ๊ฒฐ๊ตญ ๊ฐ์ฒด์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์— ์ƒ๋ฐ˜๋˜๋Š” ํ˜•ํƒœ๋ฅผ ๋„๋Š”๊ฒƒ์ด๋‹ค. ์ด๋Ÿฌํ•œ ๋†’์€ ์˜์กด์„ฑ์„ ๋‚ฎ์ถ”๊ธฐ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์ด Spring Container ์ด๋‹ค.

๐Ÿ”ฎ POJO

Plain Old Java Object, ๊ฐ์ฒด์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์˜ ๋ณธ ๋ชฉ์ ์— ๋งž๊ฒŒ ์‚ฌ์šฉํ•˜๊ธฐ์œ„ํ•œ ํŠน์ • ํ™˜๊ฒฝ์— ์ข…์†๋˜์ง€ ์•Š๋Š” ๊ฐ„๊ฒฐํ•œ ํด๋ž˜์Šค๋ฅผ ๋งํ•œ๋‹ค.

  • Inversion Of Container

    • ๊ฐ์ฒด์˜ ์ƒ์„ฑ๊ณผ ์‚ฌ์šฉํ•˜๋Š” ํ–‰์œ„๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ์ฃผ์ฒด๊ฐ€ Container๋กœ ๋„˜์–ด๊ฐ€๋Š”๊ฒƒ์„ ๋งํ•œ๋‹ค.
  • Dependency Injection

    • Container ์™ธ๋ถ€์—์„œ ์ƒ์„ฑ๋œ ๊ฐ์ฒด๋ฅผ setter ํ˜น์€ ์ƒ์„ฑ์ž๋ฅผ ์ด์šฉํ•ด ํŠน์ •์ƒํ™ฉ์—์„œ ๊ฐ์ฒด๋ผ๋ฆฌ ์˜์กดํ•˜๋Š” ์ƒํ™ฉ์ผ๋•Œ IoC์ปจํ…Œ์ด๋„ˆ์—์„œ ์ƒ์„ฑ๋œ ๊ฐ์ฒด๋ฅผ ๋„˜๊ฒจ์ฃผ์–ด ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ๊ฒŒํ•˜๋Š”๊ฒƒ.
  • PSA (Portable Service Abstraction)

    • ํ™˜๊ฒฝ์˜ ๋ณ€ํ™”์™€ ๊ด€๊ณ„์—†์ด ์ผ๊ด€๋œ ๋ฐฉ์‹์˜ ๊ธฐ์ˆ ๋กœ์˜ ์ ‘๊ทผ ํ™˜๊ฒฝ์„ ์ œ๊ณตํ•˜๋ ค๋Š” ์ถ”์ƒํ™” ๊ตฌ์กฐ
  • AOP (Aspect Oriented Programming )

    • ๊ธฐ์กด์— OOP์—์„œ ๋ฐ”๋ผ๋ณด๋˜ ๊ด€์ ์„ ๋‹ค๋ฅด๊ฒŒํ•˜์—ฌ ๋ถ€๊ฐ€๊ธฐ๋Šฅ์ ์ธ ์ธก๋ฉด์œผ๋กœ ๋ณด์•˜์„๋•Œ ๊ณตํ†ต๋œ ์š”์†Œ๋ฅผ ์ถ”์ถœํ•ด ๋‚ด ์žฌ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ. (๋กœ๊น…, ํŠธ๋žœ์žญ์…˜, ๋ณด์•ˆ)

๐Ÿ“ข ๐Ÿ”DispatcherServlet

Servlet Container (tomcat)์—์„œ ๋“ค์–ด์˜ค๋Š” ๋ชจ๋“  ์š”์ฒญ์„ ํ”„๋ ˆ์  ํ…Œ์ด์…˜ ๊ณ„์ธต์˜ ์ œ์ผ ์•ž์—๋‘ฌ์„œ ์ค‘์•™์ง‘์ค‘์‹์œผ๋กœ ์ฒ˜๋ฆฌํ•ด์ฃผ๋Š” Front Controller.

๐Ÿ’จ ๋™์ž‘ ๋ฐฉ์‹

99F8E4335A06F70930