Skip to content

Spring Listenerย #6

Description

@dev-xong

๐Ÿ”น ServletContextListener ์™€ SpringFrameWork

  • Spring์˜ ApplicationEventPublisher๊ฐ€ ๋ฐœํ–‰ํ•˜๋Š” ์ด๋ฒคํŠธ๋ฅผ ๊ตฌ๋…ํ•˜๋Š” ์ปดํฌ๋„ŒํŠธ
  • ์Šคํ”„๋ง ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์›น ํ”„๋กœ์ ํŠธ์—์„œ ๋ฏธ๋ฆฌ ๋กœ๋”ฉํ•˜๋Š” ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•  ๋•Œ ServletContextListener ์‚ฌ์šฉ
  • ์ด๋ฒคํŠธ๊ฐ€ ApplicationvEvent๋ฅผ ์ƒ์†ํ•˜๊ฑฐ๋‚˜, ์ผ๋ฐ˜ ๊ฐ์ฒด(POJO)๋กœ๋„ ์‚ฌ์šฉ ๊ฐ€๋Šฅ
  • ์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ํ•ด๋‹น ์ด๋ฒคํŠธ ํƒ€์ž…์„ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ๋ฆฌ์Šค๋„ˆ๊ฐ€ ์ž๋™์œผ๋กœ ํ˜ธ์ถœ
  • Servlet Context์—๋Š” setAttribute()๋ฅผ ์ด์šฉํ•ด ์›ํ•˜๋Š” ์ด๋ฆ„์œผ๋กœ ๊ฐ์ฒด ๋ณด๊ด€
  • ์„œ๋ธ”๋ฆฟ API ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ
    • ํ•ด๋‹น ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์‹œ์ž‘๋˜๊ฑฐ๋‚˜ ์ข…๋ฃŒ๋  ๋•Œ ํŠน์ •ํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰
      • ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ contextInitialized
      • ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒ contextDestroyed
    • HttpSession์— ํŠน์ •ํ•œ ์ž‘์—…์— ๋Œ€ํ•œ ๊ฐ์‹œ์™€ ์ฒ˜๋ฆฌ
      • HttpSessionAttributeListener
        • attributeAdded()
        • attributeRemoved()
        • attributeReplaced()
    • HttpServletRequest์— ํŠน์ •ํ•œ ์ž‘์—…์— ๋Œ€ํ•œ ๊ฐ์‹œ์™€ ์ฒ˜๋ฆฌ

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions