3

Here is a snippet from Spring Framework Core from 1.6.1: Lifecycle Callbacks:

Also, please note that stop notifications are not guaranteed to come before destruction. On regular shutdown, all Lifecycle beans first receive a stop notification before the general destruction callbacks are being propagated. However, on hot refresh during a context’s lifetime or on aborted refresh attempts, only destroy methods are called.

What is hot refresh? Does it have something to do with live reloading?

Andrew Tobilko
  • 48,120
  • 14
  • 91
  • 142
  • I assume that this is a minor inconsistency in wording and that they meant to write [hot swapping](https://docs.spring.io/spring-boot/docs/current/reference/html/howto-hotswapping.html) – Turing85 Sep 07 '19 at 13:43
  • @Turing85 Even I thought so, but the same word is repeated twice in Spring Framework Core, you can search for it in *1.15.2. Standard and Custom Events* –  Sep 07 '19 at 13:45
  • I know, I checked the doc =). Still, I woudl assume it is a minor inconsistency. – Turing85 Sep 07 '19 at 13:47
  • 1
    hot refresh is about reloading your `ApplicationContext` without restart the process see https://stackoverflow.com/questions/24720330/reload-or-refresh-a-spring-application-context-inside-a-test-method – josejuan Sep 07 '19 at 13:47
  • @josejuan Isn't that *hot swapping*? –  Sep 07 '19 at 13:49
  • hot swapping imply change the deployment (the binaries) refresh only the context (aka configuration) – josejuan Sep 07 '19 at 13:51
  • @josejuan It looks like you answered the question. Why don't you turn your comment into an answer so you can get credit? – K Man Sep 07 '19 at 13:56
  • 1
    @josejuan Correct, but partially. –  Sep 07 '19 at 14:26

1 Answers1

2

Answering question by myself.

ContextRefreshedEvent is published when the ApplicationContext is initialized or refreshed (for example, by using the refresh() method on the ConfigurableApplicationContext interface). Here, “initialized” means that all beans are loaded, post-processor beans are detected and activated, singletons are pre-instantiated, and the ApplicationContext object is ready for use. As long as the context has not been closed, a refresh can be triggered multiple times, provided that the chosen ApplicationContext actually supports such “hot” refreshes. For example, XmlWebApplicationContext supports hot refreshes, but GenericApplicationContext does not.

AbstractRefreshableWebApplicationContext:

Provides a "configLocations" property, to be populated through the ConfigurableWebApplicationContext interface on web application startup.

It is the web application context whose config locations property is being replaced without restarting the app.