ee/src/main/java/org/jboss/as/ee/component/deployers/EarApplicationNameProcessor.java
private String getApplicationName(DeploymentUnit deploymentUnit) {
        final DeploymentUnit parentDU = deploymentUnit.getParent();
        if (parentDU == null) {
            final EarMetaData earMetaData = deploymentUnit.getAttachment(org.jboss.as.ee.structure.Attachments.EAR_METADATA);
            if (earMetaData != null) {
                final String overriddenAppName = earMetaData.getApplicationName();
                if (overriddenAppName == null) {
                    return this.getEarName(deploymentUnit);
                }
                return overriddenAppName;
            } else {
                return this.getEarName(deploymentUnit);
            }
        }
        // traverse to top level DU
        return this.getApplicationName(parentDU);
    }
private String getApplicationName(DeploymentUnit deploymentUnit) {
        final DeploymentUnit parentDU = deploymentUnit.getParent();
        if (parentDU == null) {
            final EarMetaData earMetaData = deploymentUnit.getAttachment(org.jboss.as.ee.structure.Attachments.EAR_METADATA);
            if (earMetaData != null) {
                final String overriddenAppName = earMetaData.getApplicationName();
                if (overriddenAppName == null) {
                    return this.getEarName(deploymentUnit);
                }
                return overriddenAppName;
            } else {
                return this.getEarName(deploymentUnit);
            }
        }
        // traverse to top level DU
        return this.getApplicationName(parentDU);
    }
private String getApplicationName ( DeploymentUnit deploymentUnit ) { final DeploymentUnit parentDU = deploymentUnit . getParent ( ) ; if ( parentDU == null ) { final EarMetaData earMetaData = deploymentUnit . getAttachment ( org . jboss . as . ee . structure . Attachments . EAR_METADATA ) ; if ( earMetaData != null ) { final String overriddenAppName = earMetaData . getApplicationName ( ) ; if ( overriddenAppName == null ) { return this . getEarName ( deploymentUnit ) ; } return overriddenAppName ; } else { return this . getEarName ( deploymentUnit ) ; } } // traverse to top level DU return this . getApplicationName ( parentDU ) ; }
Returns the application name for the passed deployment. If the passed deployment isn't an .ear or doesn't belong
to a .ear, then this method returns null. Else it returns the application-name set in the application.xml of the .ear
or if that's not set, will return the .ear deployment unit name (stripped off the .ear suffix).

@param deploymentUnit The deployment unit
Returns the application name for the passed deployment . If the passed deployment isn t an . ear or doesn t belong to a . ear then this method returns null . Else it returns the application - name set in the application . xml of the . ear or if that s not set will return the . ear deployment unit name ( stripped off the . ear suffix ) .