[jboss-cvs] JBossAS SVN: r58286 - trunk/server/src/main/org/jboss/web/deployers

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Nov 12 17:39:22 EST 2006


Author: scott.stark at jboss.org
Date: 2006-11-12 17:39:20 -0500 (Sun, 12 Nov 2006)
New Revision: 58286

Modified:
   trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
Log:
Look to the ear metadata for an override of the war context root

Modified: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java	2006-11-12 22:36:39 UTC (rev 58285)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java	2006-11-12 22:39:20 UTC (rev 58286)
@@ -35,8 +35,11 @@
 import javax.management.ObjectName;
 
 import org.jboss.deployers.plugins.deployers.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.plugins.deployers.helpers.AttachmentLocator;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployment.J2eeApplicationMetaData;
+import org.jboss.deployment.J2eeModuleMetaData;
 import org.jboss.metadata.WebMetaData;
 import org.jboss.mx.util.MBeanServerLocator;
 import org.jboss.system.metadata.ServiceConstructorMetaData;
@@ -266,7 +269,7 @@
     * on the war deployment name.
     * 
     * @see #deployWebModule(DeploymentUnit, WebMetaData, AbstractWarDeployment)
-    * @see #buildWebContext(String, String, WebMetaData)
+    * @see #buildWebContext(DeploymentUnit, String, String, WebMetaData)
     * 
     * @param unit - the war for the deployment
     * @param metaData - the metadata for the deployment
@@ -334,9 +337,9 @@
 
          metaData.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
 
-         // Build the context root if its not been set 
+         // Build the context root if its not been set or is specified at the ear
          String webContext = metaData.getContextRoot();
-         webContext = buildWebContext(webContext, warName, metaData);
+         webContext = buildWebContext(webContext, warName, metaData, unit);
          metaData.setContextRoot(webContext);
 
          AbstractWarDeployment deployment = getDeployment(unit, metaData);
@@ -438,13 +441,28 @@
    webContext value is null which indicates a standalone war deployment.
    A war name of ROOT.war is handled as a special case of a war that
    should be installed as the default web context.
+   @param ctxPath - war level context-root
+   @param warName - 
    */
-   protected String buildWebContext(String ctxPath, String warName, WebMetaData metaData)
+   protected String buildWebContext(String ctxPath, String warName,
+         WebMetaData metaData, DeploymentUnit unit)
    {
       // Build a war root context from the war name if one was not specified
       String webContext = ctxPath;
+      // Check for an ear level specification
       if( webContext == null )
-         webContext = metaData.getContextRoot();
+      {
+         J2eeApplicationMetaData earMetaData = AttachmentLocator.search(unit, J2eeApplicationMetaData.class);
+         if( earMetaData != null )
+         {
+            String path = unit.getRelativePath();
+            J2eeModuleMetaData webModule = earMetaData.getModule(path);
+            if( webModule != null )
+               webContext = webModule.getWebContext();
+         }
+      }
+
+      // Build the context from the deployment name
       if( webContext == null )
       {
          // Build the context from the war name, strip the .war suffix




More information about the jboss-cvs-commits mailing list