问题
tomcat加载servlet用的什么加载器
tomcat修改了java的双亲委派模型,在自定义加载器方面,实现了自己的类加载器:CommonClassLoader、CatalinaClassLoader、SharedClassLoader和WebappClassLoader
参考:
https://blog.csdn.net/wangziman/article/details/105665057
类加载器对象的特点
类加载器对象一般是单例的吧,也允许多例;
ClassLoader的构造函数
private ClassLoader(Void var1, ClassLoader var2) {
this.classes = new Vector();
this.defaultDomain = new ProtectionDomain(new CodeSource((URL)null, (Certificate[])null), (PermissionCollection)null, this, (Principal[])null);
this.packages = new HashMap();
this.nativeLibraries = new Vector();
this.defaultAssertionStatus = false;
this.packageAssertionStatus = null;
this.classAssertionStatus = null;
this.parent = var2;
if (ClassLoader.ParallelLoaders.isRegistered(this.getClass())) {
this.parallelLockMap = new ConcurrentHashMap();
this.package2certs = new ConcurrentHashMap();
this.domains = Collections.synchronizedSet(new HashSet());
this.assertionLock = new Object();
} else {
this.parallelLockMap = null;
this.package2certs = new Hashtable();
this.domains = new HashSet();
this.assertionLock = this;
}
}
protected ClassLoader(ClassLoader var1) {
this(checkCreateClassLoader(), var1);
}
protected ClassLoader() {
this(checkCreateClassLoader(), getSystemClassLoader());
}