"In-depth understanding of java virtual machine" study notes EIGHT - Chapter IX

The ninth chapter of case in which loading and execution subsystem and actual combat

Q: If there are 10 WEB applications are using Spring to organization and management, you can put under the Spring Common or Shared directory (Tomcat5.0) to make these programs share. Spring should be the class of the user program management, natural to be able to have access to the type of user program and the user program is clearly on the / WEB-INF directory. So how loaded CommonClassLoader or not the user access SharedClassLoader Spring program within its load range it?

A: Using thread context class loader to achieve, spring loaded class classloader is used by Thread.currentThread () getContextClassLoader () to get in, and when the thread is created by default setContextClassLoader (AppClassLoader), that is always spring. can get to this AppClassLoader (in the tomcat is WebAppClassLoader) sub-class loader to load the bean, after any thread can getContextClassLoader () to get the WebAppClassLoader to getbean

Reference blog links :

Acting reference https://www.cnblogs.com/AmyZheng/p/9264215.html

https://blog.csdn.net/u013678930/article/details/51995251

The ninth chapter of case in which loading and execution subsystem and actual combat

Q: If there are 10 WEB applications are using Spring to organization and management, you can put under the Spring Common or Shared directory (Tomcat5.0) to make these programs share. Spring should be the class of the user program management, natural to be able to have access to the type of user program and the user program is clearly on the / WEB-INF directory. So how loaded CommonClassLoader or not the user access SharedClassLoader Spring program within its load range it?

A: Using thread context class loader to achieve, spring loaded class classloader is used by Thread.currentThread () getContextClassLoader () to get in, and when the thread is created by default setContextClassLoader (AppClassLoader), that is always spring. can get to this AppClassLoader (in the tomcat is WebAppClassLoader) sub-class loader to load the bean, after any thread can getContextClassLoader () to get the WebAppClassLoader to getbean

Reference blog links :

Acting reference https://www.cnblogs.com/AmyZheng/p/9264215.html

https://blog.csdn.net/u013678930/article/details/51995251

Guess you like

Origin www.cnblogs.com/manmanchanglu/p/11621850.html