一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

Tomcat 6.0 Class Loader

 昵稱2829056 2010-08-21
Overview

Like many server applications, Tomcat 6 installs a variety of class loaders (that is, classes that implement java.lang.ClassLoader) to allow different portions of the container, and the web applications running on the container, to have access to different repositories of available classes and resources. This mechanism is used to provide the functionality defined in the Servlet Specification, version 2.4 -- in particular, Sections 9.4 and 9.6.

In a J2SE 2 (that is, J2SE 1.2 or later) environment, class loaders are arranged in a parent-child tree. Normally, when a class loader is asked to load a particular class or resource, it delegates the request to a parent class loader first, and then looks in its own repositories only if the parent class loader(s) cannot find the requested class or resource. The model for web application class loaders differs slightly from this, as discussed below, but the main principles are the same.

When Tomcat 6 is started, it creates a set of class loaders that are organized into the following parent-child relationships, where the parent class loader is above the child class loader:

      Bootstrap
|
System
|
Common
/ \
Webapp1 Webapp2 ...

The characteristics of each of these class loaders, including the source of classes and resources that they make visible, are discussed in detail in the following section.

Class Loader Definitions

As indicated in the diagram above, Tomcat 6 creates the following class loaders as it is initialized:

  • Bootstrap - This class loader contains the basic runtime classes provided by the Java Virtual Machine, plus any classes from JAR files present in the System Extensions directory ($JAVA_HOME/jre/lib/ext). NOTE - Some JVMs may implement this as more than one class loader, or it may not be visible (as a class loader) at all.
  • System - This class loader is normally initialized from the contents of the CLASSPATH environment variable. All such classes are visible to both Tomcat internal classes, and to web applications. However, the standard Tomcat 6 startup scripts ($CATALINA_HOME/bin/catalina.sh or %CATALINA_HOME%\bin\catalina.bat) totally ignore the contents of the CLASSPATH environment variable itself, and instead build the System class loader from the following repositories:
    • $CATALINA_HOME/bin/bootstrap.jar - Contains the main() method that is used to initialize the Tomcat 6 server, and the class loader implementation classes it depends on.
    • $CATALINA_HOME/bin/tomcat-juli.jar - Package renamed Commons logging API, and java.util.logging LogManager.
  • Common - This class loader contains additional classes that are made visible to both Tomcat internal classes and to all web applications. Normally, application classes should NOT be placed here. All unpacked classes and resources in $CATALINA_HOME/lib, as well as classes and resources in JAR files are made visible through this class loader. By default, that includes the following:
    • annotations-api.jar - JEE annotations classes.
    • catalina.jar - Implementation of the Catalina servlet container portion of Tomcat 6.
    • catalina-ant.jar - Tomcat Catalina Ant tasks.
    • catalina-ha.jar - High availability package.
    • catalina-tribes.jar - Group communication package.
    • el-api.jar - EL 2.1 API.
    • jasper.jar - Jasper 2 Compiler and Runtime.
    • jasper-el.jar - Jasper 2 EL implementation.
    • jasper-jdt.jar - Eclipse JDT 3.2 Java compiler.
    • jsp-api.jar - JSP 2.1 API.
    • servlet-api.jar - Servlet 2.5 API.
    • tomcat-coyote.jar - Tomcat connectors and utility classes.
    • tomcat-dbcp.jar - package renamed database connection pool based on Commons DBCP.
    • tomcat-i18n-**.jar - Optional JARs containing resource bundles for other languages. As default bundles are also included in each individual JAR, they can be safely removed if no internationalization of messages is needed.
  • WebappX - A class loader is created for each web application that is deployed in a single Tomcat 6 instance. All unpacked classes and resources in the /WEB-INF/classes directory of your web application archive, plus classes and resources in JAR files under the /WEB-INF/lib directory of your web application archive, are made visible to the containing web application, but to no others.

As mentioned above, the web application class loader diverges from the default Java 2 delegation model (in accordance with the recommendations in the Servlet Specification, version 2.3, section 9.7.2 Web Application Classloader). When a request to load a class from the web application's WebappX class loader is processed, this class loader will look in the local repositories first, instead of delegating before looking. There are exceptions. Classes which are part of the JRE base classes cannot be overriden. For some classes (such as the XML parser components in J2SE 1.4+), the J2SE 1.4 endorsed feature can be used. Last, any JAR containing servlet API classes will be ignored by the classloader. All other class loaders in Tomcat 6 follow the usual delegation pattern.

Therefore, from the perspective of a web application, class or resource loading looks in the following repositories, in this order:

  • Bootstrap classes of your JVM
  • System class loader classes (described above)
  • /WEB-INF/classes of your web application
  • /WEB-INF/lib/*.jar of your web application
  • $CATALINA_HOME/lib
  • $CATALINA_HOME/lib/*.jar

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    熟女乱一区二区三区丝袜| 精品人妻一区二区四区| 亚洲天堂精品1024| 国产传媒欧美日韩成人精品| 欧美日韩少妇精品专区性色| 久久热这里只有精品视频| 日韩中文字幕狠狠人妻| 老鸭窝精彩从这里蔓延| 日韩欧美亚洲综合在线| 日韩专区欧美中文字幕| 中文文精品字幕一区二区| 丰满人妻一二区二区三区av| 国产精品午夜一区二区三区| 99国产精品国产精品九九| 五月婷婷欧美中文字幕| 国产欧美日本在线播放| 午夜精品一区二区av| 99香蕉精品视频国产版| 免费国产成人性生活生活片| 国产又色又粗又黄又爽| 精品国产亚洲av久一区二区三区| 日韩一区二区三区嘿嘿| 国产性色精品福利在线观看| 精品视频一区二区三区不卡| 亚洲丁香婷婷久久一区| 欧美日韩中国性生活视频| 加勒比东京热拍拍一区二区| 黑色丝袜脚足国产一区二区| 女人精品内射国产99| 欧美成人黄色一级视频| 久久亚洲精品成人国产| 久久综合亚洲精品蜜桃| 五月激情综合在线视频| 制服丝袜美腿美女一区二区| 九九九热在线免费视频| 欧美亚洲美女资源国产| 色涩一区二区三区四区| 欧美日韩乱一区二区三区| 福利专区 久久精品午夜| 国产免费一区二区不卡| 日韩日韩日韩日韩在线|