Search in sources :

Example 1 with WebModuleMetaData

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;
}
Also used : JBossAppMetaData(org.jboss.metadata.ear.jboss.JBossAppMetaData) WebModuleMetaData(org.jboss.metadata.ear.spec.WebModuleMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) WebModuleMetaData(org.jboss.metadata.ear.spec.WebModuleMetaData) ModuleMetaData(org.jboss.metadata.ear.spec.ModuleMetaData)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 JBossAppMetaData (org.jboss.metadata.ear.jboss.JBossAppMetaData)1 ModuleMetaData (org.jboss.metadata.ear.spec.ModuleMetaData)1 WebModuleMetaData (org.jboss.metadata.ear.spec.WebModuleMetaData)1