加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

The Class Loader Hierarchy--转载

发布时间:2020-12-14 06:20:23 所属栏目:Java 来源:网络整理
导读:Class loaders in the Application Server runtime follow a delegation hierarchy that is illustrated in the following figure and fully described in. The following table describes the class loaders in the Application Server. Table 2–1 Sun Jav

Class loaders in the Application Server runtime follow a delegation hierarchy that is illustrated in the following figure and fully described in.

Figure shows the class loader runtime hierarchy.

The following table describes the class loaders in the Application Server.

Table 2–1 Sun Java System Application Server Class Loaders

?Class Loader?

Bootstrap

</td>
<td align="left" valign="top">

The Bootstrap class loader loads the basic runtime classes provided by the JVM,plus any classes from JAR files present in the system extensions directory. It is parent to the System class loader. To add JAR files to the system extensions,directory,see?.

</td>

</tr>
<tr>
<td align="left" valign="top">

System

</td>
<td align="left" valign="top">

The System class loader loads Application Server launch classes. It is parent to the Shared Chain class loader. It is created based on the?system-classpath?attribute of the?java-config?element in the?domain.xml?file. In the Admin Console,select the Application Server component,the JVM Settings tab,and the Path Settings tab,then edit the System Classpath field. See??and?java-config?in?Sun Java System Application Server Platform Edition 9 Administration Reference.

</td>

</tr>
<tr>
<td align="left" valign="top">

Shared Chain?

</td>
<td align="left" valign="top">

The Shared Chain class loader loads most of the core Application Server classes. It is parent to the MBean class loader and the Common class loader. Classes specified by the?classpath-prefix?and?classpath-suffixattributes of the?java-config?element in the?domain.xml?file are added to this class loader. In the Admin Console,then edit the Classpath Prefix or Classpath Suffix field.

The environment classpath is included if?env-classpath-ignored="false"?is set in the?java-configelement.

Use?classpath-prefix?to place libraries ahead of Application Server implementation classes in the shared chain. The?classpath-prefix?is ideal for placing development and diagnostic patches. Use?classpath-suffix?to place libraries after implementation classes in the shared chain.

</td>

</tr>
<tr>
<td align="left" valign="top">

MBean

</td>
<td align="left" valign="top">

The MBean class loader loads the MBean implementation classes. See?.

</td>

</tr>
<tr>
<td align="left" valign="top">

Common

</td>
<td align="left" valign="top">

The Common class loader loads classes in the?domain-dir/lib/classes?directory,followed by JAR files in thedomain-dir/lib?directory. It is parent to the Connector class loader. No special classpath settings are required. The existence of these directories is optional; if they do not exist,the Common class loader is not created. See?.

</td>

</tr>
<tr>
<td align="left" valign="top">

Connector

</td>
<td align="left" valign="top">

The Connector class loader is a single class loader instance that loads individually deployed connector modules,which are shared across all applications. It is parent to the LifeCycleModule class loader and the Application class loader.?

</td>

</tr>
<tr>
<td align="left" valign="top">

LifeCycleModule

</td>
<td align="left" valign="top">

The LifeCycleModule class loader is created once per lifecycle module. Each?lifecycle-module?element’sclasspath?attribute is used to construct its own class loader. For more information on lifecycle modules,see.

</td>

</tr>
<tr>
<td align="left" valign="top">

Application

</td>
<td align="left" valign="top">

The Application class loader loads the classes in a specific enabled individually deployed module or Java EE application. One instance of this class loader is present in each class loader universe; see?. The Application class loader is created with a list of URLs that point to the locations of the classes it needs to load. It is parent to the Web class loader.

The Application class loader loads classes in the following order:?

    Classes specified by the?library-directory?element in the?application.xml?deployment descriptor or the?–-libraries?option during deployment; see?

  1. Classes specified by the application's or module's?location?attribute in the?domain.xml?file,determined during deployment

  2. Classes in the classpaths of the application's sub-modules

  3. Classes in the application's or module's stubs directory

The?location?attribute points to?domain-dir/applications/j2ee-apps/app-name?or?domain-dir/applications/j2ee-modules/module-name.

The stubs directory is?domain-dir/generated/ejb/j2ee-apps/app-name?or?domain-dir/generated/ejb/j2ee-modules/module-name.

</td>

</tr>
<tr>
<td align="left" valign="top">

Web

</td>
<td align="left" valign="top">

The Web class loader loads the servlets and other classes in a specific enabled web module or a Java EE application that contains a web module. This class loader is present in each class loader universe that contains a web module; see?. One instance is created for each web module. The Web class loader is created with a list of URLs that point to the locations of the classes it needs to load. The classes it loads are in?WEB-INF/classes?or?WEB-INF/lib/*.jar. It is parent to the JSP Engine class loader.

</td>

</tr>
<tr>
<td align="left" valign="top">

JSP Engine

</td>
<td align="left" valign="top">

The JSP Engine class loader loads compiled JSP classes of enabled JSP files. This class loader is present in each class loader universe that contains a JSP page; see?. The JSP Engine class loader is created with a list of URLs that point to the locations of the classes it needs to load.

</td>

</tr>

Note that this is not a Java inheritance hierarchy,but a delegation hierarchy. In the delegation design,a class loader delegates classloading to its parent before attempting to load a class itself. A class loader parent can be either the System class loader or another custom class loader. If the parent class loader cannot load a class,the class loader attempts to load the class itself. In effect,a class loader is responsible for loading only the classes not available to the parent. Classes loaded by a class loader higher in the hierarchy cannot refer to classes available lower in the hierarchy.

The Java Servlet specification recommends that the Web class loader look in the local class loader before delegating to its parent. You can make the Web class loader follow the delegation inversion model in the Servlet specification by setting?delegate="false"?in the?class-loader?element of the?sun-web.xml?file. It is safe to do this only for a web module that does not interact with any other modules. For details,see?class-loader?in?Sun Java System Application Server Platform Edition 9 Application Deployment Guide.

The default value is?delegate="true",which causes the Web class loader to delegate in the same manner as the other class loaders. You must use?delegate="true"?for a web application that accesses EJB components or that acts as a web service client or endpoint. For details about?sun-web.xml,see?The sun-web.xml File?in?Sun Java System Application Server Platform Edition 9 Application Deployment Guide.

https://docs.oracle.com/cd/E19501-01/819-3659/beadf/index.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

Description?