}
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final ServiceModuleLoader moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
if(deploymentUnit.getParent() != null) {
//if the parent has already attached parsed data for this sub deployment we need to process it
if(deploymentRoot.hasAttachment(SUB_DEPLOYMENT_STRUCTURE)) {
final ModuleSpecification subModuleSpec = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
handleDeployment(deploymentUnit, subModuleSpec, deploymentRoot.getAttachment(SUB_DEPLOYMENT_STRUCTURE));
}
}
VirtualFile deploymentFile = null;
for (final String loc : DEPLOYMENT_STRUCTURE_DESCRIPTOR_LOCATIONS) {
final VirtualFile file = deploymentRoot.getRoot().getChild(loc);
if (file.exists()) {
deploymentFile = file;
break;
}
}
if (deploymentFile == null) {
return;
}
if (deploymentUnit.getParent() != null) {
ServerLogger.DEPLOYMENT_LOGGER.jbossDeploymentStructureIgnored(deploymentFile.getPathName());
return;
}
try {
final ParseResult result = parse(deploymentFile.getPhysicalFile(), deploymentUnit, moduleLoader);
final ModuleSpecification moduleSpec = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
if (result.getEarSubDeploymentsIsolated() != null) {
// set the ear subdeployment isolation value overridden via the jboss-deployment-structure.xml
moduleSpec.setSubDeploymentModulesIsolated(result.getEarSubDeploymentsIsolated());
}
// handle the the root deployment
final ModuleStructureSpec rootDeploymentSpecification = result.getRootDeploymentSpecification();
if (rootDeploymentSpecification != null) {
handleDeployment(deploymentUnit, moduleSpec, rootDeploymentSpecification);
}
// handle sub deployments
final List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
final Map<String, ResourceRoot> subDeploymentMap = new HashMap<String, ResourceRoot>();
for (final ResourceRoot root : resourceRoots) {
if(SubDeploymentMarker.isSubDeployment(root)) {
subDeploymentMap.put(root.getRoot().getPathNameRelativeTo(deploymentRoot.getRoot()), root);
}
}
for (final Entry<String, ModuleStructureSpec> entry : result.getSubDeploymentSpecifications().entrySet()) {
final String path = entry.getKey();
final ModuleStructureSpec spec = entry.getValue();
if (!subDeploymentMap.containsKey(path)) {
throw subDeploymentNotFound(path, subDeploymentMap.keySet());
}
final ResourceRoot subDeployment = subDeploymentMap.get(path);
subDeployment.putAttachment(SUB_DEPLOYMENT_STRUCTURE, spec);
}
// handle additional modules
for (final ModuleStructureSpec additionalModule : result.getAdditionalModules()) {
for(final ModuleIdentifier identifier : additionalModule.getAnnotationModules()) {