final Map<String, DeploymentUnit> deploymentUnitMap = new HashMap<String, DeploymentUnit>();
for (final DeploymentUnit subDeployment : parent.getAttachment(org.jboss.as.server.deployment.Attachments.SUB_DEPLOYMENTS)) {
final ResourceRoot deploymentRoot = subDeployment.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
final ModuleMetaData moduleMetaData = deploymentRoot.getAttachment(Attachments.MODULE_META_DATA);
if (moduleMetaData != null) {
deploymentUnitMap.put(moduleMetaData.getFileName(), subDeployment);
}
}
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
final ModuleMetaData thisModulesMetadata = deploymentRoot.getAttachment(Attachments.MODULE_META_DATA);
if (thisModulesMetadata != null && thisModulesMetadata.getType() != ModuleMetaData.ModuleType.Client) {
ModuleMetaData previous = null;
boolean found = false;
for (ModuleMetaData module : earConfig.getModules()) {
if (module.getType() != ModuleMetaData.ModuleType.Client) {
if (module.getFileName().equals(thisModulesMetadata.getFileName())) {
found = true;
break;
}
previous = module;
}
}
if (previous != null && found) {
//now we know the previous module we can setup the service dependencies
//we setup one on the deployment service, and also one on every component
final ServiceName serviceName = Services.deploymentUnitName(parent.getName(), previous.getFileName());
phaseContext.addToAttachmentList(org.jboss.as.server.deployment.Attachments.NEXT_PHASE_DEPS, serviceName.append(Phase.INSTALL.name()));
final DeploymentUnit prevDeployment = deploymentUnitMap.get(previous.getFileName());
final EEModuleDescription eeModuleDescription = prevDeployment.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
if (eeModuleDescription != null) {
for (final ComponentDescription component : eeModuleDescription.getComponentDescriptions()) {
phaseContext.addToAttachmentList(org.jboss.as.server.deployment.Attachments.NEXT_PHASE_DEPS, component.getStartServiceName());
}