Eclipse书籍部分翻译(英译中)10
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Eclipse书籍部分翻译(英译中)10相关的知识,希望对你有一定的参考价值。
Issues with Context Classloaders
Since Java 1.2, the Class.forName(String) mechanism has been largely superseded by context classloading. As such, most modern class libraries use a context classloader. In the discussion below, we show how Eclipse transparently converts the use of context classloaders into something equivalent to Class.forName (String). Doing this allows the buddy loading and Dynamic-Import mechanisms described above to be used to eliminate ClassNotFoundExceptions and NoClassDefFoundErrors.
Each Java Thread has an associated context classloader field that contains a classloader. The classloader in this field is set, typically by the application container, to match the context of this current execution. That is, the field contains a classloader that has access to the classes related to the current execution (e.g., Web request being processed). Libraries such as log4j access and use the context classloader with the updated AppenderHelper code pattern below:
By default, the context classloader is set to be the normal Java application classloader. That is, the use of the context classloader in normal Java application scenarios is equivalent to using Class.forName(String) and there is only one classloader, the application classloader. When running inside Eclipse, however, the code pattern outlined above fails because:
•By default, Eclipse does not consult the application classloader. Eclipse-based applications put their code on dynamic plug-in classpaths rather than on the normal Java application classpath.
•Eclipse cannot detect plug-in context switches and set the context classloader as required. That is, there is no way to tell when execution context shifts from one plug-in to the next as is done in Web application servers.
These characteristics, combined with the compositional nature of Eclipse, mean that the value of the context classloader field is seldom useful.
Clients can, however, explicitly set the context classloader before calling libraries that use the context classloader. The snippet below shows an example of calling log4j using this approach:
First the current context classloader is saved. The context classloader is then set to an appropriate value for the current execution and log4j is called. log4j's AppenderHelper uses the context classloader, so in this case, it uses the client's classloader (e.g., this.getClass().getClassLoader()). When the operation is finished, the original context classloader is restored.
这是计算机Eclipse的书籍中的关于插件和打包那部分的外文词汇,其中的Chapter N是指书中第N章。这些是专业词汇的翻译,我要的是通顺的、尽量正确的中文译文。。。。谢谢大家!
由于爪哇1.2 , Class.forName (弦乐)的机制已基本取代了背景classloading 。因此,最现代化的类库使用类加载器的范畴。在下文的讨论,我们将展示如何转换Eclipse的透明的使用范围classloaders成相当于Class.forName (字符串) 。这样做可以让好友装货和动态的进口机制如上所述,用来消除ClassNotFoundExceptions和NoClassDefFoundErrors 。
每个Java线程有相关的背景类加载器领域,其中包含类加载器。在类加载器在这方面设置,一般是通过集装箱的应用,以符合这一背景下当前执行。也就是说,外地包含一个类加载器已获得有关课程到目前执行的(例如, Web请求正在处理中) 。图书馆如log4j访问和使用类加载器的背景与更新AppenderHelper代码模式如下:
默认情况下,背景类装载器将是正常的Java应用类加载器。这就是,使用类加载器的范围内正常的Java应用情景等于使用Class.forName (弦乐)和只有一个类加载器,应用类加载器。当运行在Eclipse的,但代码模式上文所述失败,因为:
•默认情况下, Eclipse的不协商的应用类加载器。基于Eclipse的应用程序将其代码的动态插件classpaths ,而不是正常的Java应用程序类路径。
• Eclipse的无法检测插件上下文切换,并设置背景类装载器的要求。也就是说,没有办法告诉当执行方面的变化从一个插件下的工作是在Web应用服务器。
这些特点,再加上成分性质的Eclipse ,意味着价值的领域范畴类加载器,很少有用的。
客户还可以,但明确规定的范围类加载器之前,要求图书馆,使用类加载器的范畴。片段所示的一个例子,呼吁log4j使用此方法:
一是目前的情况下类装载器被保存。背景类加载器,然后设置为一个适当的值为目前的执行和log4j被称为。 log4j的AppenderHelper使用类加载器的背景,所以在这种情况下,它使用客户端的类加载器(例如, this.getClass ( ) 。 getClassLoader ( ) ) 。当手术完成后,原来的类加载器的范围内得到恢复。 参考技术A sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss nnnnnnnnnnnnnnnnnnnnnnvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvdddddddddddddddddddddddddddddddggggggggggggggggggggggggggggg1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
参考资料:1111111111111
以上是关于Eclipse书籍部分翻译(英译中)10的主要内容,如果未能解决你的问题,请参考以下文章
大学英语综合教程三 Unit 1至Unit 8 课文内容英译中 中英翻译
大学英语综合教程四 Unit 1至Unit 8 课文内容英译中 中英翻译
求助英译中 The effect of concession period design on completion risk management of BOT projects