问题描述
的WebSphere自带的父母最后和父母第一次。这是兼容Java EE?这是由是Java EE的所有应用程序服务器支持5兼容的?
WebSphere comes with parent last and parent first. Is this Java EE compliant? Is this supported by all application servers that are Java EE 5 compliant?
推荐答案
我做我自己的研究(通过规范和一些博客会)及以下是我已经想通
I did my own research (going through the specs and few blogs) and below is what I've figured
EAR
该规范不定义或强制怎样的类加载器应在EAR内工作。然而,它定义了
The spec DOES NOT define or mandate how the class loaders should work within an EAR. It however defines that
- 应该有每个线程的上下文类加载器的类加载运行库
- 有可能是解决类层次结构类加载机制(应用服务器厂商可以自由地实现他们选择的任何方式)
- 顶层类加载器(WAR / EAR)可授权水平低的类装载器(如引导,推广等)。这是符合J2SE的类加载器代理模型(PARENT_FIRST在WAS)
WAR
Servlet规范定义并授权一个PARENT_LAST的支持(在附带的应用服务器的库即WAR / WEB-INF / classes和WAR / WEB-INF / lib中取precedence)类加载模型。但是,这只是WAR模块。 Servlet规范在这种情况下PARENT_FIRST标准J2SE委托模型发散。
Servlet specification defines and mandates the support of a PARENT_LAST (i.e. WAR/web-inf/classes and WAR/web-inf/lib take precedence over the libraries that come with the app server) class loading model. But this is just for WAR modules. The Servlet spec diverges from the standard J2SE delegation model of PARENT_FIRST in this case.
参考
规格:Servlet 2.3的,科:9.7.2 Web应用程序类加载器
Spec: Servlet 2.3, Section: 9.7.2 Web Application Classloader
规格:Java EE 5中,科:EE.6.2.4.7上下文类加载器
Spec: Java EE 5, Section: EE.6.2.4.7 Context Class Loader
应用服务器细节
有趣的是,虽然,它似乎最重要的应用服务器都支持关闭代表团(如有必要,因为冲突或其他方式)的应用程序从应用服务器隔离的一些机制:的WebSphere - 父母最后一个,GlassFish的 - <类加载器的委托=false的>
时,JBoss - java2ParentDelegation = FALSE
时,Geronimo - < Java2的-delgation模型>假LT; / Java2的授权模型>
Interestingly, though, it appears most major app servers support some mechanism of turning off delegation to isolate the application from the app server if necessary (because of conflicts or otherwise): WebSphere - "parent-last", GlassFish - <class-loader delegate="false">
, JBoss - java2ParentDelegation=false
, Geronimo - <java2-delgation-model>false</java2-delegation-model>
这篇关于Java EE的类加载标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!