[jboss-as7-dev] Bundling content with deployments

David M. Lloyd david.lloyd at redhat.com
Thu Jun 2 16:22:28 EDT 2011


I was chatting with Ales about his issues trying to incorporate a 
seam-int module into a deployment, such that every deployment (which 
bundles seam) would get a copy of those classes added to it.

So I thought I'd cover some options for a general approach to solving 
this issue.

First, it is important to note that such content should NOT be made into 
a static module.  Modules are only for JARs which only have a single 
instance in the app server.

I think a good possible approach would be to define a resource root in a 
(different) module which contains the JAR file itself as an opaque 
resource, and then reference that resource when constructing the deployer.

In this example I'll have a fictional module called 
"org.jboss.ales.deployer".

The module.xml for this module should look something like this:

<module xmlns="urn:jboss:module:1.0" name="org.jboss.ales.deployer">

     <resources>
         <resource-root path="bundled"/>
         <!-- Insert resources here -->
     </resources>

     <dependencies>
         <module name="org.jboss.as.controller"/>
         <module name="org.jboss.as.server"/>
         ...other modules here...
     </dependencies>
</module>

Then we deposit the nested seam-int JAR into the "bundled" subdirectory 
of our module through some sort of build.xml modification, taking care 
to use a predictable name for the JAR (as opposed to the long Maven name).

Having done this, code from the org.jboss.ales.deployer module can now 
reliably acquire this file path:

File jarFile = new File(getClass().getResource("/seam-int.jar").toURI());

The File can then make its way to the deployment as a resource root, 
thus creating a copy of the content in each deployment which our 
deployer wishes to add it to.

Questions/comments?
-- 
- DML


More information about the jboss-as7-dev mailing list