您的位置:首页 > 其它

jboss7-的类依赖管理

2013-03-18 13:15 429 查看
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的子包相互依赖

应用程序模块加载的命名约定: 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-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>


在<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息