When is ContextRefreshedEvent fired in Spring?

I know that it is fired once when the ApplicationContext is fully loaded, but what about after that during runtime? The word "Refreshed" implies that it will be triggered on a refresh but I wonder what Spring qualifies as an ApplicationContext refresh?

Followup question: Can this event be triggered by concurrent threads? Do I need to make the EventHandler for this event thread safe?


it is fired when properties, xml or any schema files are loaded/refreshed, http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/support/AbstractApplicationContext.html#refresh--

Load or refresh the persistent representation of the configuration, which might an XML file, properties file, or relational database schema.

It is fired implicitly by spring usually, but you should be able to fire that on certain instances, But here is java doc says when that happens

As this is a startup method, it should destroy already created singletons if it fails, to avoid dangling resources. In other words, after invocation of that method, either all or no singletons at all should be instantiated.

链接地址: http://www.djcxy.com/p/36696.html

上一篇: JavaScript setDate返回错误的日期

下一篇: 什么时候在Spring中触发ContextRefreshedEvent?