[Spring] SpringApplication의 refreshContext


[Spring] SpringApplication의 refreshContext

refreshContext springboot의 run 메서드에서 동작하는 기능 중 하나인 refreshContext이다. 동작 과정 먼저 shutdownhook을 등록을 해준다 shutdownhook은 프로그램의 종료를 감지해 프로그램 종료 시에 후처리 작업을 진행하는 기술 프로세스가 갑자기 죽어버리면 연결 종료, 자원 반납 등의 처리를 못 하는데 shutdownhook을 사용해서 프로그램이 종료되어도 별도의 쓰레드가 올바른 프로그램 종료를 위한 작업 처리할 수 있게 한다. 스프링은 DisposableBean 인터페이스나 @PreDestroy 또는 @Bean에 소멸자 메서드를 지정해서 소멸자를 구현할 수 있는데 SpringApplication이 여기에 shutdownHook을 추가해서 소멸자 메서드를 처리할 수 있게 한다. 그리고 applicationContext를 refresh 해준다. refresh는 각 applicationContext에 맞게 구현이 되어 있다. 기본으로 하게...


#refresh #spring #springapplication #스프링

원문링크 : [Spring] SpringApplication의 refreshContext