final Module module = unit.getAttachment(Attachments.MODULE);
if (module == null) {
throw new DeploymentUnitProcessingException("failed to resolve module for deployment " + deploymentRoot);
}
final ClassLoader classLoader = module.getClassLoader();
final ArchiveDeployment dep = this.newDeployment(unit.getName(), classLoader);
try {
List<VirtualFile> virtualFiles = root.getChildrenRecursively(WS_FILE_FILTER);
final Set<UnifiedVirtualFile> uVirtualFiles = new HashSet<UnifiedVirtualFile>();
for (VirtualFile vf : virtualFiles) {
// Adding the roots of the virtual files.
uVirtualFiles.add(new VirtualFileAdaptor(vf));
}
dep.setMetadataFiles(new LinkedList<UnifiedVirtualFile>(uVirtualFiles));
} catch (IOException e) {
this.log.warn("Could not load metadata files for deployment root " + root, e);
}
if (unit.getParent() != null) {
final String parentDeploymentName = unit.getParent().getName();
final Module parentModule = unit.getParent().getAttachment(Attachments.MODULE);
if (parentModule == null) {
throw new DeploymentUnitProcessingException("failed to resolve module for parent of deployment "
+ deploymentRoot);
}
final ClassLoader parentClassLoader = parentModule.getClassLoader();
this.log.debug("Creating new WS deployment model for parent: " + unit.getParent());
final ArchiveDeployment parentDep = this.newDeployment(parentDeploymentName, parentClassLoader);
dep.setParent(parentDep);
}
dep.setRootFile(new VirtualFileAdaptor(root));
dep.setRuntimeClassLoader(classLoader);