-
jboss类的加载顺序:1)系统包2)jboss-deployment-structure.xml或者Dependencies:manifest entry for modules 或者throughClass-Path:for jar files. 3)本地包WEB-INF/classes和WEB-INF/lib下的内容 4)内部依赖类:如ear的子包相互依赖
-
应用程序模块加载的命名约定:deployment.myarchive.war,deployment.myear.ear.mywar.war.不多解释,观察下特征.
-
系统包依赖自动加载.注意一个包在应用程序中和jboss系统中都有的情况下,优先使用了host.xml中配置的子系统的依赖包.当腰改变这种和系统包之间的依赖性,可以配置jboss-deployment-structure.xml文件
-
EAR包中所有子系统的类和包可以设置为共享和独占。但是可以在host.xml中配置独占,默认视共享,即可以从其它子项目加载类:
<subsystemxmlns="urn:jboss:domain:ee:1.0">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
</subsystem>
-
war中的lib和class文件在jboss中是同等对待的
-
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>
-
在<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>