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 参数配置:

<!-- Get the flag indicating if the normal Java2 parent first class
           loading model should be used over the servlet 2.3 web container first
           model.
      -->
      <attribute name="Java2ClassLoadingCompliance">false</attribute>
      <!-- A flag indicating if the JBoss Loader should be used. This loader
           uses a unified class loader as the class loader rather than the tomcat
           specific class loader.
           The default is false to ensure that wars have isolated class loading
           for duplicate jars and jsp files.
      -->
      <attribute name="UseJBossWebLoader">false</attribute>

 配置UseJBossWebLoader为false,则webapp的加载通过独立于jboss的classloader进行加载。

 

WEB-IN/jboss-web.xml , 两种配置方式:

<class-loading java2ClassLoadingCompliance='true'>
       <loader-repository> 
             dot.com:loader=unique-archive-name
             <loader-repository-config>
                 java2ParentDelegaton=true
             </loader-repository-config>
      </loader-repository> 
 </class-loading>

 

或者

<class-loading java2ClassLoadingCompliance='true'></class-loading>

 

   

对于第一种配置,webapp将使用JBoss隔离的UCL作为Classloader,并且是否是parent load模型是由其中的java2ParentDelegaton参数决定,java2ClassLoadingCompliance='true'属性将被忽略。

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

你可能感兴趣的:(tomcat,xml,Web,jboss,配置管理)