use of org.jboss.metadata.ear.spec.WebModuleMetaData in project wildfly by wildfly.
the class ASHelper method getContextRoot.
/**
* Returns context root associated with webservice deployment.
*
* If there's application.xml descriptor provided defining nested web module, then context root defined there will be
* returned. Otherwise context root defined in jboss-web.xml will be returned.
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
* @return context root
*/
public static String getContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD) {
final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
final JBossAppMetaData jbossAppMD = unit.getParent() == null ? null : ASHelper.getOptionalAttachment(unit.getParent(), WSAttachmentKeys.JBOSS_APP_METADATA_KEY);
String contextRoot = null;
// prefer context root defined in application.xml over one defined in jboss-web.xml
if (jbossAppMD != null) {
final ModuleMetaData moduleMD = jbossAppMD.getModules().get(dep.getSimpleName());
if (moduleMD != null) {
final WebModuleMetaData webModuleMD = (WebModuleMetaData) moduleMD.getValue();
contextRoot = webModuleMD.getContextRoot();
}
}
if (contextRoot == null) {
contextRoot = jbossWebMD != null ? jbossWebMD.getContextRoot() : null;
}
return contextRoot;
}
Aggregations