In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to use prepareRefresh ()". In daily operation, I believe many people have doubts about how to use prepareRefresh (). The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use prepareRefresh ()"! Next, please follow the editor to study!
Refresh ()
This method mainly does the following things:
Preparation before container refresh
Initialize beanFactory, load and parse the configuration
Set the properties of beanFactory
Post-processing work after the creation of BeanFactory
The method of executing BeanFactoryPostProcessor
Register for BeanPostProcessor
Initialize the MessageSource component
Initialize event dispatcher
Subclass overrides this method to customize the logic when the container is refreshed
Register the ApplicationListener in all projects in the container
Initialize all remaining single instance bean
After the initialization and creation of BeanFactory, the IOC container is created.
Here, let's take a look at what the container did before it was refreshed.
PrepareRefresh ()
There is not much source code for the method, as follows:
Protected void prepareRefresh () {/ / Switch to active. / / this sentence obviously gets the current time of the system. In fact, its function is to record the this.startupDate = System.currentTimeMillis () of the current startup time; / / the settings of these two states, the former closes the program to be set to false, and the latter's running flag is set to true this.closed.set (false); this.active.set (true) If (logger.isDebugEnabled ()) {if (logger.isTraceEnabled ()) {logger.trace ("Refreshing" + this);} else {logger.debug ("Refreshing" + getDisplayName ());} / / Initialize any placeholder property sources in the context environment. / / currently it is an empty method, so initPropertySources () should be added later; / / Validate that all properties marked as required are resolvable: / / see ConfigurablePropertyResolver#setRequiredProperties / / verify the xml configuration file getEnvironment () .validateRequiredProperties (); / / Store pre-refresh ApplicationListeners... / / determine whether the collection of application listeners before refresh is empty, initialize applicationListeners listeners, and not empty, then empty the listener if (this.earlyApplicationListeners = = null) {this.earlyApplicationListeners = new LinkedHashSet (this.applicationListeners);} else {/ / Reset local application listeners to pre-refresh state. This.applicationListeners.clear (); this.applicationListeners.addAll (this.earlyApplicationListeners);} / / Allow for the collection of early ApplicationEvents, / / to be published once the multicaster is available... / / create the event collection before refresh this.earlyApplicationEvents = new LinkedHashSet ();}
This method prepareRefresh () is added after spring5.3, so there is no way to see the previous version.
That's all I've done.
Set the startup time of the container
Set active status to true
Set the shutdown status to false
Get the Environment object and load the current system environment into Environment
Prepare the collection object for listeners and events. Default is empty.
At this point, the study on "how to use prepareRefresh ()" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.