JBoss.org Community Documentation

21.3. Nested deployments

Nested deployments are found by calling the addAllChildren() method in AbstractStructureDeployer and passing in a reference to the deployment root and the current nested deployment along with the StructureMetaData and VFSStructuralDeployers references:


public abstract class AbstractStructureDeployer implements StructureDeployer
{
    ...

   protected void addAllChildren(VirtualFile root, VirtualFile parent, StructureMetaData metaData, VFSStructuralDeployers deployers) throws Exception
   {
      addChildren(root, parent, metaData, deployers, null);
   }

   protected void addChildren(VirtualFile root, VirtualFile parent, StructureMetaData metaData, VFSStructuralDeployers deployers, VisitorAttributes attributes) throws Exception
   {
      if (parent == null)
         throw new IllegalArgumentException("Null parent");
      
      VirtualFileVisitor visitor = candidateStructureVisitorFactory.createVisitor(root, parent, metaData, deployers, attributes);
      parent.visit(visitor);
   }

    ...
}

This in turn calls the addChildren() method which creates a VirtualFileVisitor that is passed to the virtual file representing the current deployment. Each child file or directory of the current deploment is then visited using the visitor which use the VFSStructuralDeployers object to iterate through the list of StructureDeployers . These then determine whether the child represents a nested deployment. If a nested deployment is found then the process is repeated in order to recurse through the entire directory structure. This happens regardless of whether the deployment is packaged or unpackaged as the Virtual File System takes care of accessing the actual files.

Due to this recursive algorithm you can freely nest any type of deployment within any other type of deployment to any level. There is one exection to this with WAR archives which cannot contain nested deployments. All you need to ensure is that you have defined a StructureDeployer implementation capable of recognising your deployment.