转自:http://tanyankai.javaeye.com/blog/569627
- 以下说到的版本是jboss-4.2.3.GA
- 并且假设JBoss安装在D:\Java\jboss-4.2.3.GA
- JBoss部署的时候支持很多种格式打的包,比如说我们从deploy目录下面会看到有后缀名为deployer、sar,war,rar,xml ... (后来发现其实JBoss部署支持的格式,远远不止这些)
- 但是这些不同格式的应用是怎样的一个加载顺序呢?或者说有没有什么规律?带着这个疑问我在Jboss启动的时候仔细的看了一下命令行中的信息,发现两个信息:
- 1、 最先加载的是后缀名为deployer目录下应用或者服务;
- 2、 每次都会等有相同后缀名的应用(或者目录下的应用)完全加载完之后才会去加载另外一种后缀名
- 发现这两点之后,我就找了一下Jboss的一些配置文件,原来在D:\Java\jboss-4.2.3.GA\server\default\conf\xmdesc org.jboss.deployment.MainDeployer-xmbean.xml文件里面有这么一段内容:
- <attribute access='read-write' setMethod='setEnhancedSuffixOrder' getMethod='getEnhancedSuffixOrder'>
- <description>Allows the override of the suffix order declared by subdeployers, using the syntax [order:]suffix
- </description>
- <name>EnhancedSuffixOrder</name>
- <type>[Ljava.lang.String;</type>
- <!--
- Statically set one or more enhanced suffix orders, independent of the value proposed by subdeployers.
- Some deployers may also allow the suffixes/orders to be set locally, so that's preferable too.
- For reference, this is the list of enhanced suffixes likely to be set by deployers (it may not
- be completely up-to-date, or there can be user-defined deployers).
- 050:.deployer,050:-deployer.xml,100:.aop,100:-aop.xml,150:.sar,150:-service.xml,200:. ,250:.rar,300:-ds.xml,350:.har,400:.jar,400:.ejb3,400:.par,500:.war,600:.wsr,650:.ear,700:.jar,750:.zip,800:.bsh,900:.last
- Until we resolve some startup issues, we'll setup some static enhanced suffix orders bellow
- and leave the rest of the suffixes contributed dynamically by registering deployers.
- -->
- <descriptors>
- <value value="250:.rar,300:-ds.xml,400:.jar,500:.war,550:.jse,650:.ear,800:.bsh"/>
- </descriptors>
- </attribute>
- 如果我们需要在JBoss下面部署很多应用,并且有些时候这些应用相互之间需要有先后启动顺序,我们可以通过以下两种方式做到。
- 1、 根据实际需要,部署到不同的子目录下面
- 2、 通过修改下面value值来改变JBoss默认加载顺序
- <descriptors>
- <value value="250:.rar,300:-ds.xml,400:.jar,500:.war,550:.jse,650:.ear,800:.bsh,850:.deployer"/>
- </descriptors>