Apache Tomcat 6.0 Class Loader HOW-TO

xiaoxiao2021-03-01  19

[url]http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html[/url] 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
转载请注明原文地址: https://www.6miu.com/read-3850023.html

最新回复(0)