天天看點

jboss classloader加載機制

1. 概念

ucl : org.jboss.mx.loading.unifiedclassloader3 ,它繼承标準的java.net.urlclassloader,覆寫了标準parent delegation模型以使用共享class和資源倉庫

倉庫(responsitory): org.jboss.mx.loading.unifiedloaderrepository3。

平面模型:為了熱deploy子產品的需要,jboss實作了自己的類裝載器unifiedclassloader3,一般來說,一個頂層的deployment就有一個unifiedclassloader3執行個體為之工作。一個deployment所裝載的類,其他 deployment是可見的。全局唯一的unifiedloaderrepository3執行個體用于管理這些類,以及裝載它們的unifiedclassloader3。unifiedloaderrepository3執行個體和

unifiedclassloader3執行個體是一對多的關系。

寫道

there are two levels of scoping, isolation from other deployments, and isolation that overrides the loading of jboss server classes. with nested modules, only the top level file may specify class loader scoping. if you have a .ear file containing other modules, only scoping specified in the .ear 's meta-inf/jboss-app.xml is used. this also applies for any other deployment which contains sub-deployments. for example, if a .sar contains a .war deployment, only the .sar meta-inf/jboss-service.xml scoping has effect.

 意思是說,scope配置隻能是頂級下的配置,比如一個.sar中包含.war都配置了scope,隻有.sar下的 meta-inf/jboos-service.xml才有效。

meta-inf/jboos-service.xml 參數配置:

配置usejbosswebloader為false,則webapp的加載通過獨立于jboss的classloader進行加載。

web-in/jboss-web.xml , 兩種配置方式:

或者

對于第一種配置,webapp将使用jboss隔離的ucl作為classloader,并且是否是parent load模型是由其中的java2parentdelegaton參數決定,java2classloadingcompliance='true'屬性将被忽略。

java2parentdelegaton='true'或者'false'決定了是否采用parent first/child first模型。