171114 ServletContextListener - RYUDONGJIN/Memo_wiki GitHub Wiki

ServletContextListener

  • μ›Ήμ–΄ν”Œλ¦¬μΌ€μ΄μ…˜μ˜ 생λͺ…μ£ΌκΈ°λ₯Ό κ°μ‹œν•˜λŠ” λ¦¬μŠ€ν„°.
  • λ¦¬μŠ€λ„ˆμ˜ ν•΄λ‹Ή λ©”μ†Œλ“œκ°€ μ›Ή μ–΄ν”Œλ¦¬μΌ€μ΄μ…˜μ˜ μ‹œμž‘κ³Ό μ’…λ£Œμ‹œ 호좜
  • contextInitialized() , contextDestroyed()

μ‹€ν–‰ μˆœμ„œ

contextInitialized() -> @PostConstruct -> init() -> doGet()/doPost()/service() -> destroy() -> @PreDestroy -> contextDestroyed()

  <listener>
  	<listener-class>com.javalec.ex.ContextListenerEx</listener-class>
  </listener>
@WebListener
public class ContextListenerEx implements ServletContextListener{
	public ContextListenerEx() {
	}
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.println("contextDestroyed");
	}
	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		System.out.println("contextInitialized");
	}
}
⚠️ **GitHub.com Fallback** ⚠️