1. In setLoader of ContainerBase, loader. setContainer (this );
2. The setContainer () of WepappLoader is called ()
If (this. container! = Null) & (this. container instanceof Context) {// if it is a Context container
SetReloadable (Context) this. container). getReloadable ());
(Context) this. container). addPropertyChangeListener (this );
}
3. Start the thread in setReloadable (boolean reloadable) to continuously check the timestamp threadStart () of the class files and JAR files under the WEB-INF directory ();
4. threadStart start similar start () method: generate a new thread, call run () reload class, and generate threadStart ()
5. policycontext (); WebappContextNotifier notifier = new WebappContextNotifier ();
(New Thread (notifier). start ();
6. WebappContextNotifier is an internal class, and only run () is a method. Execute (Context) container). reload (); call the reload () method of StandardContext
7. business logic of the reload () method of StandardContext:
7.1 Shut down our session manager
7.2 Shut down the current version of all active servlets
7.3 Shut down application event listeners
7.4 Clear all application-originated servlet context attributes
7.5 Shut down filters
7.6 Shut down our application class loader
7.7 Restart our application class loader
7.8 Restart our application event listeners and filters
7.9 Restore the "Welcome Files" and "Resources" context attributes
7.10 Restart our currently defined servlets :( (Lifecycle) wrapper). start ();
7.11 Reinitialize all load on startup servlets: loadOnStartup (children );
7.12 Restart our session manager
8. loadOnStartup (Container children []) --> wrapper. load () --> StandardWarpper loadServlet ();
From the code point of view, servlet is dynamic, all are first uninstalled, and then all are loaded.
Author rain