Eclipse书籍部分翻译(英译中)11

来源:百度知道 编辑:UC知道 时间:2024/06/21 17:41:17
The assumption here is that the client's classloader is able to load all required classes. This may or may not be true. Even if it can, the coding pattern is cumbersome to use and hard to maintain for any significant number of library calls. Ideally, log4j would be able to dynamically discover the context relevant to a particular classloading operation. Eclipse enables this using the context finder.
The context finder is a kind of ClassLoader that is installed by Eclipse as the default context classloader. When invoked, it searches down the Java execution stack for a classloader other than the system classloader. In the AppenderHelper example above, it finds the log4j plug-in's classloaderthe one that loaded AppenderHelper. The context finder then delegates the load request to the discovered classloader.
This mechanism transforms log4j's call to getContextClassLoader(). loadClass(String) to the equivalent Class.forName(String) call using log4j's classloader to

这里的假设是,客户端的类加载器可以加载所有必需的课程。这可能是也可能不是真的。即使可以,编码模式是繁琐的使用和难以维持的任何相当数量的图书馆电话。最理想的是, log4j将能够动态发现相关的背景某一classloading运作。这使Eclipse的使用范围搜寻背景查找是一种类加载器是安装的Eclipse作为默认的背景类加载器。当调用,它搜查了Java运行栈的类加载器以外的其他系统

这里的假设是,客户端的类加载器可以加载所有必需的课程。这可能是也可能不是真的。即使可以,编码模式是繁琐的使用和难以维持的任何相当数量的图书馆电话。最理想的是, log4j将能够动态发现相关的背景某一classloading运作。这使Eclipse的使用范围查找。
背景查找是一种类加载器是安装的Eclipse作为默认的背景类加载器。当调用,它搜查了Java运行栈的类加载器以外的系统类加载器。在AppenderHelper上述范例中,它发现了log4j插件的classloaderthe一个装货AppenderHelper 。背景查找然后代表的负荷要求发现的类加载器。
这种机制转换log4j的呼吁, getContextClassLoader ( ) 。 loadClass (弦乐)相当于Class.forName (弦乐)呼叫使用log4j的类加载器来加载特定类别。现在的好友classloading技术讨论20.5.1节中可用于帮助log4j负载所需要的appender班。
净效果是,客户log4j不必使用繁琐的编码方式上文所述,尽管他们称之为图书馆的范围内使用类加载器。这种做法推广到其他方面classloading情况。
班级管理JRE环境
由于各种原因,一些图书馆包括软件包,通常是发现了JRE环境。例如, 2.6版的Xalan的XML转换引擎,配备各类org.w3c.dom.xpath从包中xalan.jar 。这些类型还包括一部分典型的JRE环境分布。当xalan.jar是用来作为正常的Java应用,它被添加到类路径,但它的XPath类所掩盖那些在JRE环境。一切都很好。
当您捆绑Xalan ,模具生产出口包装的项目在所有软件包xalan.jar 。然而,刀具无法知道,它应该增加进口org.w3c.