Tags

links:
http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
http://www.javaworld.com/javaworld/javaqa/2003-06/01-qa-0606-load.html
http://www.javaworld.com/javaworld/jw-03-2000/jw-03-classload.html
http://www.objectsource.com/j2eechapters/Ch21-ClassLoaders_and_J2EE.htm
http://onjava.com/pub/a/onjava/2003/11/12/classloader.html
http://stackoverflow.com/questions/1184556/servlet-context-scope-vs-global-variable
http://stackoverflow.com/questions/2424604/what-is-a-java-classloader
http://bitshub.blogspot.com/2010/01/java-classloader.html

summary:
– 1 jvm is 1 process
– within 1 jvm/process, using classloader to set class scope and namespace effectively
– often CLs are parent-child; scope mostly exists among peer CLs
– e.g. tomcat is 1 process, but need diff CLs to separate different webapp from class conflicts

console apps hierarchy
======================
primordial/bootstrap(native)<–extended(basics)<–system/yourapp(classpath)

tomcat hierarchy
================
bootstrap(jre)<–system(modified CP/bin)<–common(lib)<–webappA/B(app specific)

notes:
– 3 commonly available classloades: system, current ctx, thread ctx
– system CL mostly for standalone app, often not used if webserver
– pick the child CL (mostly superset of parent), if current and thread are parent-child
– if current and thread are both siblings, then mostly pick thread ctx CL
– Servlet context scope is NOT same vs global variable, since ServletCtx can maintain servlet scope across classloaders but global variable cannot.

Advertisements