tomcat初始化类加载.docx
《tomcat初始化类加载.docx》由会员分享,可在线阅读,更多相关《tomcat初始化类加载.docx(27页珍藏版)》请在冰豆网上搜索。
![tomcat初始化类加载.docx](https://file1.bdocx.com/fileroot1/2022-10/12/00dabdcd-c0c6-4cb7-b47d-805ccc9c60a9/00dabdcd-c0c6-4cb7-b47d-805ccc9c60a91.gif)
tomcat初始化类加载
Tomcat解析之初始化类加载器(截图)
全部HibernateSpringStrutsiBATIS企业应用LuceneSOAJava综合设计模式TomcatOOJBoss
«上一页12下一页»
浏览7744次
锁定老帖子主题:
Tomcat解析之初始化类加载器(截图)
该帖已经被评为精华帖
作者
正文
∙gogole_09
∙等级:
∙性别:
∙文章:
213
∙积分:
420
∙来自:
杭州
发表时间:
2010-01-30 最后修改:
2010-02-01
<>猎头职位:
上海:
【上海】外资企业高新诚聘web开发工程师
相关文章:
∙Tomcat5.5.26源代码分析——启动过程
(二)
∙Tomcat源代码分析之ClassLoader
∙《HowTomcatWorks》翻译(7)之Tomcat类加载器续集
推荐群组:
Tapestry
更多相关推荐
Java综合
之前有写过关于tomcat中常用的一些类结构的文章。
解析Tomcat之HttpServlet(截图记录)
今天来关注一下,tomcat的类加载器相关的内容。
PS:
由于前一篇文章内容比较简单,有朋友冠以我标题党之嫌,对于此种说法,本人深感抱歉,可能标题确实有点大,但是这些常用的类,我更多的时候只关注其用法,而忽略了内部实现,所以也就把这些内容总结了一下,发了出来。
别无标题党之意,请各位eyer海涵。
OK,现在进入正题.Tomcat类加载器初始化.
开始之前,我们首先需要了解一下几个基本的知识点;
1.tomcat中类加载器的结构与关系。
这里,我引用tomcat文档的一个简图来说明一下,有兴趣深究的朋友,可以去翻看tomcat的文档,理解更多信息.
(tomcat5.5)
(由于参考的是tomcat6.0的源代码,这里纠正一下类加载器的图(如下),以免给别的朋友造成误解,同时也多谢asialee给出的提醒)
(tomcat6.0)
2.每种类加载器分别加载什么资源:
这些内容,可以在tomcat文档的 ClassLoaderHOW-TO找到.
这里我要说明的是,在tomcat中,这些内容是记录在哪里的。
既(程序怎么让tomcat知道,需要加载哪些类)
答案是-----
其通过一个配置文件来指定的:
(catalina.properties),这个文件默认存放在
tomcat路径下的bin/bootstrap.jar中。
如图
打开文件,其内容如下:
Java代码
1.# Licensed to the Apache Software Foundation (ASF) under one or more
2.# contributor license agreements. See the NOTICE file distributed with
3.# this work for additional information regarding copyright ownership.
4.# The ASF licenses this file to You under the Apache License, Version 2.0
5.# (the "License"); you may not use this file except in compliance with
6.# the License. You may obtain a copy of the License at
7.#
8.# /LICENSE-2.0
9.#
10.# Unless required by applicable law or agreed to in writing, software
11.# distributed under the License is distributed on an "AS IS" BASIS,
12.# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13.# See the License for the specific language governing permissions and
14.# limitations under the License.
15.#
16.# List of comma-separated packages that start with or equal this string
17.# will cause a security exception to be thrown when
18.# passed to checkPackageAccess unless the
19.# corresponding RuntimePermission ("accessClassInPackage."+package) has
20.# been granted.
21.package.access=sun.,,,,,sun.beans.
22.#
23.# List of comma-separated packages that start with or equal this string
24.# will cause a security exception to be thrown when
25.# passed to checkPackageDefinition unless the
26.# corresponding RuntimePermission ("defineClassInPackage."+package) has
27.# been granted.
28.#
29.# by default, no packages are restricted for definition, and none of
30.# the class loaders supplied with the JDK call checkPackageDefinition.
31.#
32.package.definition=sun.,java.,,,,
33.#
34.#
35.# List of comma-separated paths defining the contents of the "common"
36.# classloader. Prefixes should be used to define what is the repository type.
37.# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
38.# If left as blank,the JVM system loader will be used as Catalina's "common"
39.# loader.
40.# Examples:
41.# "foo":
Add this folder as a class repository
42.# "foo/*.jar":
Add all the JARs of the specified folder as class
43.# repositories
44.# "foo/bar.jar":
Add bar.jar as a class repository
45.common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar
46.#
47.# List of comma-separated paths defining the contents of the "server"
48.# classloader. Prefixes should be used to define what is the repository type.
49.# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
50.# If left as blank, the "common" loader will be used as Catalina's "server"
51.# loader.
52.# Examples:
53.# "foo":
Add this folder as a class repository
54.# "foo/*.jar":
Add all the JARs of the specified folder as class
55.# repositories
56.# "foo/bar.jar":
Add bar.jar as a class repository
57.server.loader=
58.#
59.# List of comma-separated paths defining the contents of the "shared"
60.# classloader. Prefixes should be used to define what is the repository type.
61.# Path may be relative to the CATALINA_BASE path or absolute. If left as blank,
62.# the "common" loader will be used as Catalina's "shared" loader.
63.# Examples:
64.# "foo":
Add this folder as a class repository
65.# "foo/*.jar":
Add all the JARs of the specified folder as class
66.# repositories
67.# "foo/bar.jar":
Add bar.jar as a class repository
68.# Please note that for single jars, e.g. bar.jar, you need the URL form
69.# starting