jboss7-的类依赖管理

  1. jboss类的加载顺序:1)系统包2)jboss-deployment-structure.xml或者 Dependencies: manifest entry for modules 或者 through Class-Path: for jar files. 3)本地包WEB-INF/classesWEB-INF/lib下的内容 4)内部依赖类:如ear的子包相互依赖

  2. 应用程序模块加载的命名约定: deployment.myarchive.war ,deployment.myear.ear.mywar.war.不多解释,观察下特征

  3. 系统包依赖自动加载.注意一个包在应用程序中和jboss系统中都有的情况下,优先使用了host.xml中配置的子系统的依赖包.当腰改变这种和系统包之间的依赖性,可以配置jboss-deployment-structure.xml文件

  4. EAR包中所有子系统的类和包可以设置为共享和独占。但是可以在host.xml中配置独占,默认视共享,即可以从其它子项目加载类:

    <subsystemxmlns="urn:jboss:domain:ee:1.0">            

      <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

    </subsystem>

  5. war中的lib和class文件在jboss中是同等对待的

  6. jboss-deployment-structure.xml的作用,放在顶级应用中包添加或者删除依赖性。文件方放在META-INF (或者WEB-INF)中. 

    jboss-deployment-structure.xml
    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
      <!-- Make sub deployments isolated by default, so they cannot see each others classes without a Class-Path entry设置ear的子应用的包不依赖 -->
      <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
      <!-- This corresponds to the top level deployment. For a war this is the war's module, for an ear -->
      <!-- This is the top level ear module, which contains all the classes in the EAR's lib folder     -->
      <deployment>
         <!-- exclude-subsystem prevents a subsystems deployment unit processors running on a deployment设置不加载服务器配置文件中的子应用 -->
         <!-- which gives basically the same effect as removing the subsystem, but it only affects single deployment -->
         <exclude-subsystems>
            <subsystem name="resteasy" />
        </exclude-subsystems>
        <!-- Exclusions allow you to prevent the server from automatically adding some dependencies 禁止服务器自动添加某些依赖   -->
        <exclusions>
            <module name="org.javassist" />
        </exclusions>
        <!-- This allows you to define additional dependencies, it is the same as using the Dependencies: manifest attribute 添加依赖 -->
        <dependencies>
          <module name="deployment.javassist.proxy" />
          <module name="deployment.myjavassist" />
          <!-- Import META-INF/services for ServiceLoader impls as well -->
          <module name="myservicemodule" services="import"/>
        </dependencies>
        <!-- These add additional classes to the module. In this case it is the same as including the jar in the EAR's lib directory 可以添加一些格外的包-->
        <resources>
          <resource-root path="my-library.jar" />
        </resources>
      </deployment>
      <sub-deployment name="myapp.war">
        <!-- This corresponds to the module for a web deployment -->
        <!-- it can use all the same tags as the <deployment> entry above -->
        <dependencies>
          <!-- Adds a dependency on a ejb jar. This could also be done with a Class-Path entry -->
          <module name="deployment.myear.ear.myejbjar.jar" />
        </dependencies>
        <!-- Set's local resources to have the lowest priority -->
        <!-- If the same class is both in the sub deployment and in another sub deployment that -->
        <!-- is visible to the war, then the Class from the other deployment will be loaded,  -->
        <!-- rather than the class actually packaged in the war. -->
        <!-- This can be used to resolve ClassCastExceptions  if the same class is in multiple sub deployments 设置本地包加载优先级最后-->
        <local-last value="true" />
      </sub-deployment>
      <!-- Now we are going to define two additional modules -->
      <!-- This one is a different version of javassist that we have packaged -->
      <module name="deployment.myjavassist" >
        <resources>
         <resource-root path="javassist.jar" >
           <!-- We want to use the servers version of javassist.util.proxy.* so we filter it out-->
           <filter>
             <exclude path="javassist/util/proxy" />
           </filter>
         </resource-root>
        </resources>
      </module>
      <!-- This is a module that re-exports the containers version of javassist.util.proxy -->
      <!-- This means that there is only one version of the Proxy classes defined          -->
      <module name="deployment.javassist.proxy" >
        <dependencies>
          <module name="org.javassist" >
            <imports>
              <include path="javassist/util/proxy" />
              <exclude path="/**" />
            </imports>
          </module>
        </dependencies>
      </module>
    </jboss-deployment-structure>
  7. <subsystemxmlns="urn:jboss:domain:ee:1.0"> 可以设置全局依赖性:

    <subsystem xmlns="urn:jboss:domain:ee:1.0">            

      <global-modules>

        <modulename="org.javassist"slot="main"/>            

      </global-modules> 

    </subsystem>

转载于:https://my.oschina.net/fir01/blog/114426

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值