加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

jboss7-的类依赖管理

发布时间:2020-12-13 19:57:05 所属栏目:百科 来源:网络整理
导读:jboss类的加载顺序:1)系统包2) jboss-deployment-structure.xml或者 Dependencies: manifest entry for modules 或者 through Class-Path: for jar files. 3)本地包WEB-INF/classes 和 WEB-INF/lib下的内容 4)内部依赖类:如ear的子包相互依赖 应用
  1. jboss类的加载顺序:1)系统包2)jboss-deployment-structure.xml或者Dependencies:manifest entry for modules 或者throughClass-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-structurexmlns="urn:jboss:deployment-structure:1.2">
    <!--Makesubdeploymentsisolatedbydefault,sotheycannotseeeachothersclasseswithoutaClass-Pathentry设置ear的子应用的包不依赖-->
    <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
    <!--Thiscorrespondstothetopleveldeployment.Forawarthisisthewar'smodule,foranear-->
    <!--Thisisthetoplevelearmodule,whichcontainsalltheclassesintheEAR'slibfolder-->
    <deployment>
    <!--exclude-subsystempreventsasubsystemsdeploymentunitprocessorsrunningonadeployment设置不加载服务器配置文件中的子应用-->
    <!--whichgivesbasicallythesameeffectasremovingthesubsystem,butitonlyaffectssingledeployment-->
    <exclude-subsystems>
    <subsystemname="resteasy"/>
    </exclude-subsystems>
    <!--Exclusionsallowyoutopreventtheserverfromautomaticallyaddingsomedependencies禁止服务器自动添加某些依赖-->
    <exclusions>
    <modulename="org.javassist"/>
    </exclusions>
    <!--Thisallowsyoutodefineadditionaldependencies,itisthesameasusingtheDependencies:manifestattribute添加依赖-->
    <dependencies>
    <modulename="deployment.javassist.proxy"/>
    <modulename="deployment.myjavassist"/>
    <!--ImportMETA-INF/servicesforServiceLoaderimplsaswell-->
    <modulename="myservicemodule"services="import"/>
    </dependencies>
    <!--Theseaddadditionalclassestothemodule.InthiscaseitisthesameasincludingthejarintheEAR'slibdirectory可以添加一些格外的包-->
    <resources>
    <resource-rootpath="my-library.jar"/>
    </resources>
    </deployment>
    <sub-deploymentname="myapp.war">
    <!--Thiscorrespondstothemoduleforawebdeployment-->
    <!--itcanuseallthesametagsasthe<deployment>entryabove-->
    <dependencies>
    <!--Addsadependencyonaejbjar.ThiscouldalsobedonewithaClass-Pathentry-->
    <modulename="deployment.myear.ear.myejbjar.jar"/>
    </dependencies>
    <!--Set'slocalresourcestohavethelowestpriority-->
    <!--Ifthesameclassisbothinthesubdeploymentandinanothersubdeploymentthat-->
    <!--isvisibletothewar,thentheClassfromtheotherdeploymentwillbeloaded,-->
    <!--ratherthantheclassactuallypackagedinthewar.-->
    <!--ThiscanbeusedtoresolveClassCastExceptionsifthesameclassisinmultiplesubdeployments设置本地包加载优先级最后-->
    <local-lastvalue="true"/>
    </sub-deployment>
    <!--Nowwearegoingtodefinetwoadditionalmodules-->
    <!--Thisoneisadifferentversionofjavassistthatwehavepackaged-->
    <modulename="deployment.myjavassist">
    <resources>
    <resource-rootpath="javassist.jar">
    <!--Wewanttousetheserversversionofjavassist.util.proxy.*sowefilteritout-->
    <filter>
    <excludepath="javassist/util/proxy"/>
    </filter>
    </resource-root>
    </resources>
    </module>
    <!--Thisisamodulethatre-exportsthecontainersversionofjavassist.util.proxy-->
    <!--ThismeansthatthereisonlyoneversionoftheProxyclassesdefined-->
    <modulename="deployment.javassist.proxy">
    <dependencies>
    <modulename="org.javassist">
    <imports>
    <includepath="javassist/util/proxy"/>
    <excludepath="/**"/>
    </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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读