use of org.jboss.metadata.web.jboss.JBoss70WebMetaData in project wildfly by wildfly.
the class EarContextRootProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData == null) {
// Nothing we can do without WarMetaData
return;
}
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
if (deploymentRoot == null) {
// We don't have a root to work with
return;
}
final DeploymentUnit parent = deploymentUnit.getParent();
if (parent == null || !DeploymentTypeMarker.isType(DeploymentType.EAR, parent)) {
// Only care if this war is nested in an EAR
return;
}
final EarMetaData earMetaData = parent.getAttachment(Attachments.EAR_METADATA);
if (earMetaData == null) {
// Nothing to see here
return;
}
final ModulesMetaData modulesMetaData = earMetaData.getModules();
if (modulesMetaData != null)
for (ModuleMetaData moduleMetaData : modulesMetaData) {
if (Web.equals(moduleMetaData.getType()) && moduleMetaData.getFileName().equals(deploymentRoot.getRootName())) {
String contextRoot = WebModuleMetaData.class.cast(moduleMetaData.getValue()).getContextRoot();
if (contextRoot == null && (warMetaData.getJBossWebMetaData() == null || warMetaData.getJBossWebMetaData().getContextRoot() == null)) {
contextRoot = "/" + parent.getName().substring(0, parent.getName().length() - 4) + "/" + deploymentUnit.getName().substring(0, deploymentUnit.getName().length() - 4);
}
if (contextRoot != null) {
JBossWebMetaData jBossWebMetaData = warMetaData.getJBossWebMetaData();
if (jBossWebMetaData == null) {
jBossWebMetaData = new JBoss70WebMetaData();
warMetaData.setJBossWebMetaData(jBossWebMetaData);
}
jBossWebMetaData.setContextRoot(contextRoot);
}
return;
}
}
}
Aggregations