[jboss-cvs] JBossAS SVN: r83766 - in branches/tdiesler: server/src/main/org/jboss/web/deployers and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 2 04:54:27 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-02-02 04:54:27 -0500 (Mon, 02 Feb 2009)
New Revision: 83766

Modified:
   branches/tdiesler/server/src/main/org/jboss/web/WebApplication.java
   branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
   branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
   branches/tdiesler/server/src/main/org/jboss/web/deployers/WebModule.java
   branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
   branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
   branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
   branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatService.java
Log:
Restore testsuite functionality

Modified: branches/tdiesler/server/src/main/org/jboss/web/WebApplication.java
===================================================================
--- branches/tdiesler/server/src/main/org/jboss/web/WebApplication.java	2009-02-02 09:30:08 UTC (rev 83765)
+++ branches/tdiesler/server/src/main/org/jboss/web/WebApplication.java	2009-02-02 09:54:27 UTC (rev 83766)
@@ -25,7 +25,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.metadata.web.jboss.JBossWebMetaData;
 
 /** A WebApplication represents the information for a war deployment.
@@ -39,7 +39,7 @@
 public class WebApplication
 {
    /** */
-   private DeploymentUnit unit;
+   private VFSDeploymentUnit unit;
    /** Class loader of this application */
    protected ClassLoader classLoader = null;
    /** name of this application */
@@ -102,11 +102,11 @@
       this.classLoader = classLoader;
    }
 
-   public DeploymentUnit getDeploymentUnit()
+   public VFSDeploymentUnit getDeploymentUnit()
    {
       return unit;
    }
-   public void setDeploymentUnit(DeploymentUnit unit)
+   public void setDeploymentUnit(VFSDeploymentUnit unit)
    {
       this.unit = unit;
    }
@@ -168,6 +168,8 @@
     */
    public void setURL(URL url)
    {
+      if (url == null)
+         throw new IllegalArgumentException("Null URL");
       this.url = url;
    }
 

Modified: branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
===================================================================
--- branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java	2009-02-02 09:30:08 UTC (rev 83765)
+++ branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java	2009-02-02 09:54:27 UTC (rev 83766)
@@ -30,7 +30,6 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
@@ -41,6 +40,7 @@
 import org.jboss.deployers.spi.deployer.helpers.AttachmentLocator;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
 import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
@@ -87,668 +87,659 @@
  */
 public abstract class AbstractWarDeployer extends AbstractSimpleRealDeployer<JBossWebMetaData>
 {
-  public static final String DEPLOYER = "org.jboss.web.AbstractWebContainer.deployer";
-  public static final String WEB_APP = "org.jboss.web.AbstractWebContainer.webApp";
-  public static final String WEB_MODULE = "org.jboss.web.AbstractWebContainer.webModule";
-  public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
+   public static final String DEPLOYER = "org.jboss.web.AbstractWebContainer.deployer";
+   public static final String WEB_APP = "org.jboss.web.AbstractWebContainer.webApp";
+   public static final String WEB_MODULE = "org.jboss.web.AbstractWebContainer.webModule";
+   public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
 
-  /** A mapping of deployed warUrl strings to the WebApplication object */
-  protected HashMap deploymentMap = new HashMap();
-  /** The parent class loader first model flag */
-  protected boolean java2ClassLoadingCompliance = false;
-  /** A flag indicating if war archives should be unpacked */
-  protected boolean unpackWars = true;
-  /** A flag indicating if local dirs with WEB-INF/web.xml should be treated as wars
-   */
-  protected boolean acceptNonWarDirs = false;
+   /** A mapping of deployed warUrl strings to the WebApplication object */
+   protected HashMap deploymentMap = new HashMap();
+   /** The parent class loader first model flag */
+   protected boolean java2ClassLoadingCompliance = false;
+   /** A flag indicating if war archives should be unpacked */
+   protected boolean unpackWars = true;
+   /** A flag indicating if local dirs with WEB-INF/web.xml should be treated as wars
+    */
+   protected boolean acceptNonWarDirs = false;
 
-  /** If true, ejb-links that don't resolve don't cause an error (fallback to jndi-name) */
-  protected boolean lenientEjbLink = false;
+   /** If true, ejb-links that don't resolve don't cause an error (fallback to jndi-name) */
+   protected boolean lenientEjbLink = false;
 
-  /** The default security-domain name to use */
-  protected String defaultSecurityDomain = "java:/jaas/other";
-  /** The request attribute name under which the JAAS Subject is store */
-  private String subjectAttributeName = null;
-  /** Legacy support for MBeanServer */
-  private MBeanServer server;
-  private MainDeployerStructure mainDeployer;
+   /** The default security-domain name to use */
+   protected String defaultSecurityDomain = "java:/jaas/other";
+   /** The request attribute name under which the JAAS Subject is store */
+   private String subjectAttributeName = null;
+   /** Legacy support for MBeanServer */
+   private MBeanServer server;
+   private MainDeployerStructure mainDeployer;
+   
+   private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
 
-  private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+   /**
+    * Create a new AbstractWarDeployer.
+    */
+   public AbstractWarDeployer()
+   {
+      super(JBossWebMetaData.class); 
+      setOutput(ServiceMetaData.class);
+      setOutput(WarDeployment.class);
+   }
 
-  /**
-   * Create a new AbstractWarDeployer.
-   */
-  public AbstractWarDeployer()
-  {
-    super(JBossWebMetaData.class);
-    setOutput(ServiceMetaData.class);
-    setOutput(WarDeployment.class);
-  }
+   /** Get the flag indicating if the normal Java2 parent first class loading
+    * model should be used over the servlet 2.3 web container first model.
+    * @return true for parent first, false for the servlet 2.3 model
+    * @jmx:managed-attribute
+    */
+   public boolean getJava2ClassLoadingCompliance()
+   {
+      return java2ClassLoadingCompliance;
+   }
 
-  /** Get the flag indicating if the normal Java2 parent first class loading
-   * model should be used over the servlet 2.3 web container first model.
-   * @return true for parent first, false for the servlet 2.3 model
-   * @jmx:managed-attribute
-   */
-  public boolean getJava2ClassLoadingCompliance()
-  {
-    return java2ClassLoadingCompliance;
-  }
+   /** Set the flag indicating if the normal Java2 parent first class loading
+    * model should be used over the servlet 2.3 web container first model.
+    * @param flag true for parent first, false for the servlet 2.3 model
+    * @jmx:managed-attribute
+    */
+   public void setJava2ClassLoadingCompliance(boolean flag)
+   {
+      java2ClassLoadingCompliance = flag;
+   }
 
-  /** Set the flag indicating if the normal Java2 parent first class loading
-   * model should be used over the servlet 2.3 web container first model.
-   * @param flag true for parent first, false for the servlet 2.3 model
-   * @jmx:managed-attribute
-   */
-  public void setJava2ClassLoadingCompliance(boolean flag)
-  {
-    java2ClassLoadingCompliance = flag;
-  }
+   /** Set the flag indicating if war archives should be unpacked. This may
+    * need to be set to false as long extraction paths under deploy can
+    * show up as deployment failures on some platforms.
+    * 
+    * @jmx:managed-attribute
+    * @return true is war archives should be unpacked
+    */
+   public boolean getUnpackWars()
+   {
+      return unpackWars;
+   }
 
-  /** Set the flag indicating if war archives should be unpacked. This may
-   * need to be set to false as long extraction paths under deploy can
-   * show up as deployment failures on some platforms.
-   * 
-   * @jmx:managed-attribute
-   * @return true is war archives should be unpacked
-   */
-  public boolean getUnpackWars()
-  {
-    return unpackWars;
-  }
+   /** Get the flag indicating if war archives should be unpacked. This may
+    * need to be set to false as long extraction paths under deploy can
+    * show up as deployment failures on some platforms.
+    * 
+    * @jmx:managed-attribute
+    * @param flag , true is war archives should be unpacked
+    */
+   public void setUnpackWars(boolean flag)
+   {
+      this.unpackWars = flag;
+   }
 
-  /** Get the flag indicating if war archives should be unpacked. This may
-   * need to be set to false as long extraction paths under deploy can
-   * show up as deployment failures on some platforms.
-   * 
-   * @jmx:managed-attribute
-   * @param flag , true is war archives should be unpacked
-   */
-  public void setUnpackWars(boolean flag)
-  {
-    this.unpackWars = flag;
-  }
+   /**
+    * Get the flag indicating if local dirs with WEB-INF/web.xml should be
+    * treated as wars
+    * @return true if local dirs with WEB-INF/web.xml should be treated as wars
+    * @jmx.managed-attribute
+    */
+   public boolean getAcceptNonWarDirs()
+   {
+      return acceptNonWarDirs;
+   }
 
-  /**
-   * Get the flag indicating if local dirs with WEB-INF/web.xml should be
-   * treated as wars
-   * @return true if local dirs with WEB-INF/web.xml should be treated as wars
-   * @jmx.managed-attribute
-   */
-  public boolean getAcceptNonWarDirs()
-  {
-    return acceptNonWarDirs;
-  }
+   /**
+    * Set the flag indicating if local dirs with WEB-INF/web.xml should be
+    * treated as wars
+    * @param flag - true if local dirs with WEB-INF/web.xml should be treated as wars
+    * @jmx.managed-attribute
+    */
+   public void setAcceptNonWarDirs(boolean flag)
+   {
+      this.acceptNonWarDirs = flag;
+   }
 
-  /**
-   * Set the flag indicating if local dirs with WEB-INF/web.xml should be
-   * treated as wars
-   * @param flag - true if local dirs with WEB-INF/web.xml should be treated as wars
-   * @jmx.managed-attribute
-   */
-  public void setAcceptNonWarDirs(boolean flag)
-  {
-    this.acceptNonWarDirs = flag;
-  }
+   /**
+    * Get the flag indicating if ejb-link errors should be ignored
+    * in favour of trying the jndi-name in jboss-web.xml
+    * @return the LenientEjbLink flag 
+    *    
+    * @jmx:managed-attribute
+    */
+   public boolean getLenientEjbLink()
+   {
+      return lenientEjbLink;
+   }
 
-  /**
-   * Get the flag indicating if ejb-link errors should be ignored
-   * in favour of trying the jndi-name in jboss-web.xml
-   * @return the LenientEjbLink flag 
-   *    
-   * @jmx:managed-attribute
-   */
-  public boolean getLenientEjbLink()
-  {
-    return lenientEjbLink;
-  }
+   /**
+    * Set the flag indicating if ejb-link errors should be ignored
+    * in favour of trying the jndi-name in jboss-web.xml
+    *    
+    * @jmx:managed-attribute
+    */
+   public void setLenientEjbLink(boolean flag)
+   {
+      lenientEjbLink = flag;
+   }
 
-  /**
-   * Set the flag indicating if ejb-link errors should be ignored
-   * in favour of trying the jndi-name in jboss-web.xml
-   *    
-   * @jmx:managed-attribute
-   */
-  public void setLenientEjbLink(boolean flag)
-  {
-    lenientEjbLink = flag;
-  }
+   /** Get the default security domain implementation to use if a war
+    * does not declare a security-domain.
+    *
+    * @return jndi name of the security domain binding to use.
+    * @jmx:managed-attribute
+    */
+   public String getDefaultSecurityDomain()
+   {
+      return defaultSecurityDomain;
+   }
 
-  /** Get the default security domain implementation to use if a war
-   * does not declare a security-domain.
-   *
-   * @return jndi name of the security domain binding to use.
-   * @jmx:managed-attribute
-   */
-  public String getDefaultSecurityDomain()
-  {
-    return defaultSecurityDomain;
-  }
+   /** Set the default security domain implementation to use if a war
+    * does not declare a security-domain.
+    *
+    * @param defaultSecurityDomain - jndi name of the security domain binding
+    * to use.
+    * @jmx:managed-attribute
+    */
+   public void setDefaultSecurityDomain(String defaultSecurityDomain)
+   {
+      this.defaultSecurityDomain = defaultSecurityDomain;
+   }
 
-  /** Set the default security domain implementation to use if a war
-   * does not declare a security-domain.
-   *
-   * @param defaultSecurityDomain - jndi name of the security domain binding
-   * to use.
-   * @jmx:managed-attribute
-   */
-  public void setDefaultSecurityDomain(String defaultSecurityDomain)
-  {
-    this.defaultSecurityDomain = defaultSecurityDomain;
-  }
+   @Inject
+   public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
+   {
+      this.persistenceUnitDependencyResolver = resolver;
+   }
+   
+   /** Get the session attribute number under which the caller Subject is stored
+    * @jmx:managed-attribute
+    */
+   public String getSubjectAttributeName()
+   {
+      return subjectAttributeName;
+   }
 
-  @Inject
-  public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
-  {
-    this.persistenceUnitDependencyResolver = resolver;
-  }
+   /** Set the session attribute number under which the caller Subject is stored
+    * @jmx:managed-attribute
+    */
+   public void setSubjectAttributeName(String subjectAttributeName)
+   {
+      this.subjectAttributeName = subjectAttributeName;
+   }
 
-  /** Get the session attribute number under which the caller Subject is stored
-   * @jmx:managed-attribute
-   */
-  public String getSubjectAttributeName()
-  {
-    return subjectAttributeName;
-  }
+   public void start() throws Exception
+   {
+      // TODO: remove dependency on jmx
+      this.server = MBeanServerLocator.locateJBoss();
+   }
 
-  /** Set the session attribute number under which the caller Subject is stored
-   * @jmx:managed-attribute
-   */
-  public void setSubjectAttributeName(String subjectAttributeName)
-  {
-    this.subjectAttributeName = subjectAttributeName;
-  }
+   public void stop() throws Exception
+   {
 
-  public void start() throws Exception
-  {
-    // TODO: remove dependency on jmx
-    this.server = MBeanServerLocator.locateJBoss();
-  }
+   }
 
-  public void stop() throws Exception
-  {
+   /**
+    * Get the AbstractWarDeployment bean for the deployment metadata. Subclasses
+    * override this method to provide a AbstractWarDeployment bean whose
+    * start/stop will control the deployment/undeployment of the web
+    * application.
+    * 
+    * @param unit - the deployment unit
+    * @param metaData - the input web application metadata
+    * @return the AbstractWarDeployment for the input WebMetaData
+    * @throws Exception - thrown on any failure
+    */
+   public abstract AbstractWarDeployment getDeployment(DeploymentUnit unit, JBossWebMetaData metaData) throws Exception;
 
-  }
+   /**
+    * Deploy a web app based on the WebMetaData. This calls
+    * {@link #getDeployment(VFSDeploymentUnit, WebMetaData)} to obtain an
+    * AbstractWarDeployment bean that is wrapped in a ServiceMetaData by
+    * deployWebModule.
+    * 
+    * This will set the WebMetaData.contextRoot if it has not been set based
+    * on the war deployment name.
+    * 
+    * @see #deployWebModule(VFSDeploymentUnit, WebMetaData, AbstractWarDeployment)
+    * @see #buildWebContext(VFSDeploymentUnit, String, String, WebMetaData)
+    * 
+    * @param unit - the war for the deployment
+    * @param metaData - the metadata for the deployment
+    */
+   @Override
+   public void deploy(DeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException
+   {
+      log.debug("Begin deploy, " + metaData);
 
-  /**
-   * Get the AbstractWarDeployment bean for the deployment metadata. Subclasses
-   * override this method to provide a AbstractWarDeployment bean whose
-   * start/stop will control the deployment/undeployment of the web
-   * application.
-   * 
-   * @param unit - the deployment unit
-   * @param metaData - the input web application metadata
-   * @return the AbstractWarDeployment for the input WebMetaData
-   * @throws Exception - thrown on any failure
-   */
-  public abstract AbstractWarDeployment getDeployment(DeploymentUnit unit, JBossWebMetaData metaData) throws Exception;
-
-  /**
-   * Deploy a web app based on the WebMetaData. This calls
-   * {@link #getDeployment(DeploymentUnit, WebMetaData)} to obtain an
-   * AbstractWarDeployment bean that is wrapped in a ServiceMetaData by
-   * deployWebModule.
-   * 
-   * This will set the WebMetaData.contextRoot if it has not been set based
-   * on the war deployment name.
-   * 
-   * @see #deployWebModule(DeploymentUnit, WebMetaData, AbstractWarDeployment)
-   * @see #buildWebContext(WebMetaData, DeploymentUnit, String, String)
-   * 
-   * @param unit - the war for the deployment
-   * @param metaData - the metadata for the deployment
-   */
-  @Override
-  public void deploy(DeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException
-  {
-    log.debug("Begin deploy, " + metaData);
-
-    // Merge any settings from the ear level
-    JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class);
-    if (earMetaData != null)
-    {
-      String path = unit.getRelativePath();
-      ModuleMetaData webModule = earMetaData.getModule(path);
-      if (webModule != null)
+      // Merge any settings from the ear level
+      JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class);
+      if (earMetaData != null)
       {
-        // Check for a context-root setting
-        String contextRoot = metaData.getContextRoot();
-        if (contextRoot == null)
-        {
-          WebModuleMetaData wmodule = (WebModuleMetaData)webModule.getValue();
-          contextRoot = wmodule.getContextRoot();
-          metaData.setContextRoot(contextRoot);
-        }
+         String path = unit.getRelativePath();
+         ModuleMetaData webModule = earMetaData.getModule(path);
+         if (webModule != null)
+         {
+            // Check for a context-root setting
+            String contextRoot = metaData.getContextRoot();
+            if (contextRoot == null)
+            {
+               WebModuleMetaData wmodule = (WebModuleMetaData)webModule.getValue();
+               contextRoot = wmodule.getContextRoot();
+               metaData.setContextRoot(contextRoot);
+            }
 
-        // Add any alt-dd setting
-        metaData.setAlternativeDD(webModule.getAlternativeDD());
+            // Add any alt-dd setting
+            metaData.setAlternativeDD(webModule.getAlternativeDD());
+         }
+
+         // Merge security domain/roles
+         if (metaData.getSecurityDomain() == null && earMetaData.getSecurityDomain() != null)
+            metaData.setSecurityDomain(earMetaData.getSecurityDomain());
+         // TODO
+         metaData.mergeSecurityRoles(earMetaData.getSecurityRoles());
       }
 
-      // Merge security domain/roles
-      if (metaData.getSecurityDomain() == null && earMetaData.getSecurityDomain() != null)
-        metaData.setSecurityDomain(earMetaData.getSecurityDomain());
-      // TODO
-      metaData.mergeSecurityRoles(earMetaData.getSecurityRoles());
-    }
-
-    try
-    {
-      /* Unpack wars to the tmp directory for now until tomcat can use the vfs directly. Since
-       * the vfs deals with the distinction between a true directory, the only way we can tell from
-       * this level of the api is to look for a url that ends in '/'. Here we assume that the name is
-       * the root url.
-       */
-      String warName = unit.getName();
-
-      /**
-       * Ignore the jacc policy service bean 
-       */
-      if (warName.startsWith("jboss:") && warName.contains("id="))
-        return;
-
-      if (unit instanceof VFSDeploymentUnit)
+      try
       {
-        VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
-        VirtualFile vfsRoot = vfsUnit.getRoot();
+         /* Unpack wars to the tmp directory for now until tomcat can use the vfs directly. Since
+          * the vfs deals with the distinction between a true directory, the only way we can tell from
+          * this level of the api is to look for a url that ends in '/'. Here we assume that the name is
+          * the root url.
+          */
+         String warName = unit.getName();
 
-        URL expWarUrl = vfsRoot.toURL();
+         /**
+          * Ignore the jacc policy service bean 
+          */
+         if (warName.startsWith("jboss:") && warName.contains("id="))
+            return;
 
-        // Hack for jar urls being exposed
-        if (warName.endsWith("/") == false || warName.endsWith("!/") == true)
-        {
-          if (warName.startsWith("jar:"))
-          {
-            if (warName.endsWith("!/"))
-              warName = warName.substring(4, warName.length() - 2);
-            else
-              warName = warName.substring(4, warName.length());
-          }
-          URL warURL = new URL(warName);
-          ServerConfig config = ServerConfigLocator.locate();
-          String prefix = warURL.getFile();
-          int lastSlash = prefix.lastIndexOf('/');
-          if (lastSlash > 0)
-            prefix = prefix.substring(lastSlash + 1);
-          int dotWar = prefix.lastIndexOf(".war");
-          if (dotWar > 0)
-            prefix = prefix.substring(0, dotWar);
+         if (unit instanceof VFSDeploymentUnit)
+         {
+        	 VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit;
+             URL expWarUrl = vfsUnit.getRoot().toURL();
+             if (warName.endsWith("/") == false
+                   || warName.endsWith("!/") == true) // Hack for jar urls being exposed
+             {
+                if (warName.startsWith("jar:"))
+                {
+                   if (warName.endsWith("!/"))
+                      warName = warName.substring(4, warName.length() - 2);
+                   else
+                      warName = warName.substring(4, warName.length());
+                }
+                URL warURL = new URL(warName);
+                ServerConfig config = ServerConfigLocator.locate();
+                String prefix = warURL.getFile();
+                int lastSlash = prefix.lastIndexOf('/');
+                if (lastSlash > 0)
+                   prefix = prefix.substring(lastSlash + 1);
+                int dotWar = prefix.lastIndexOf(".war");
+                if (dotWar > 0)
+                   prefix = prefix.substring(0, dotWar);
 
-          File expWarFile = File.createTempFile(prefix, "-exp.war", config.getServerTempDeployDir());
-          expWarFile.delete();
-          if (expWarFile.mkdir() == false)
-            throw new DeploymentException("Was unable to mkdir: " + expWarFile);
-          
-          log.debug("Unpacking war to: " + expWarFile);
-          VirtualFile root = vfsRoot;
-          InputStream is = root.openStream();
-          try
-          {
-            JarUtils.unjar(is, expWarFile);
-          }
-          finally
-          {
-            is.close();
-          }
-          expWarUrl = expWarFile.toURL();
-
-          // Map
-          String warPathName = vfsRoot.getPathName();
-          if (warPathName.endsWith("/") == false)
-            warPathName += "/";
-          
-          List<VirtualFile> classpathVFs = vfsUnit.getClassPath();
-          if (classpathVFs != null)
-          {
-            ArrayList<URL> classpath = new ArrayList<URL>();
-            for (VirtualFile vf : classpathVFs)
-            {
-              try
-              {
-                String path = vf.getPathName();
-                if (path.startsWith(warPathName))
+                File expWarFile = File.createTempFile(prefix, "-exp.war", config.getServerTempDeployDir());
+                expWarFile.delete();
+                if (expWarFile.mkdir() == false)
+                   throw new DeploymentException("Was unable to mkdir: " + expWarFile);
+                log.debug("Unpacking war to: " + expWarFile);
+                VirtualFile root = vfsUnit.getRoot();
+                InputStream is = root.openStream();
+                try
                 {
-                  path = path.substring(warPathName.length());
-                  URL pathURL = new URL(expWarUrl, path);
-                  classpath.add(pathURL);
+                   JarUtils.unjar(is, expWarFile);
                 }
-                else
+                finally
                 {
-                  log.debug("Ignoring path element: " + vf);
+                   is.close();
                 }
-              }
-              catch (Exception e)
-              {
-                log.debug("Ignoring path element: " + vf, e);
-              }
-            }
-            unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath);
-          }
+                expWarUrl = expWarFile.toURL();
 
-          // Indicate that an expanded URL exists
-          unit.addAttachment("org.jboss.web.expandedWarURL", expWarUrl, URL.class);
-        }
+                // Map
+                VirtualFile warVF = vfsUnit.getRoot();
+                String warPathName = warVF.getPathName();
+                if (warPathName.endsWith("/") == false)
+                   warPathName += "/";
+                List<VirtualFile> classpathVFs = vfsUnit.getClassPath();
+                if (classpathVFs != null)
+                {
+                   ArrayList<URL> classpath = new ArrayList<URL>();
+                   for (VirtualFile vf : classpathVFs)
+                   {
+                      try
+                      {
+                         String path = vf.getPathName();
+                         if (path.startsWith(warPathName))
+                         {
+                            path = path.substring(warPathName.length());
+                            URL pathURL = new URL(expWarUrl, path);
+                            classpath.add(pathURL);
+                         }
+                         else
+                         {
+                            log.debug("Ignoring path element: " + vf);
+                         }
+                      }
+                      catch (Exception e)
+                      {
+                         log.debug("Ignoring path element: " + vf, e);
+                      }
+                   }
+                   unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath);
+                }
 
-        // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file
-        String altDDPath = metaData.getAlternativeDD();
-        if (altDDPath != null)
-        {
-          // First see if this is already a war local dd
-          VirtualFile altDD = vfsUnit.getMetaDataFile(altDDPath);
-          if (altDD == null)
-          {
-            // Pass absolute paths through
-            File file = new File(altDDPath);
-            if (!file.exists() || !file.isAbsolute())
-            {
-              // Should be an relative to the top deployment
-              VFSDeploymentUnit topUnit = vfsUnit.getTopLevel();
-              if (topUnit == unit)
-                throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path");
-              
-              altDD = topUnit.getFile(altDDPath);
-              if (altDD == null)
-                throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path");
-              
-              File webInf = new File(expWarUrl.toURI());
-              File altDDFile = new File(webInf, "WEB-INF/" + altDD.getName());
-              log.debug("Copying the altDD to: " + altDDFile);
-              Files.copy(altDD.toURL(), altDDFile);
-              metaData.setAlternativeDD(altDDFile.getAbsolutePath());
-            }
-          }
-        }
-      }
+                // Indicate that an expanded URL exists
+                unit.addAttachment("org.jboss.web.expandedWarURL", expWarUrl, URL.class);
+             }
 
-      ClassLoadingMetaData classLoading = metaData.getClassLoading();
-      if (classLoading == null)
-        classLoading = new ClassLoadingMetaData();
-      
-      // Pass in the java2ClassLoadingCompliance if it was not set at the war level
-      if (classLoading.wasJava2ClassLoadingComplianceSet() == false)
-        classLoading.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
-      
-      metaData.setClassLoading(classLoading);
+             // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file
+             String altDDPath = metaData.getAlternativeDD();
+             if (altDDPath != null)
+             {
+                // First see if this is already a war local dd
+                VirtualFile altDD = vfsUnit.getMetaDataFile(altDDPath);
+                if (altDD == null)
+                {
+                   // Pass absolute paths through
+                   File file = new File(altDDPath);
+                   if (!file.exists() || !file.isAbsolute())
+                   {
+                      // Should be an relative to the top deployment
+                      VFSDeploymentUnit topUnit = vfsUnit.getTopLevel();
+                      if (topUnit == unit)
+                         throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path");
+                      altDD = topUnit.getFile(altDDPath);
+                      if (altDD == null)
+                         throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path");
+                      File webInf = new File(expWarUrl.toURI());
+                      File altDDFile = new File(webInf, "WEB-INF/" + altDD.getName());
+                      log.debug("Copying the altDD to: " + altDDFile);
+                      Files.copy(altDD.toURL(), altDDFile);
+                      metaData.setAlternativeDD(altDDFile.getAbsolutePath());
+                   }
+                }
+             }
+         }
 
-      // Build the context root if its not been set or is specified at the ear
-      String webContext = metaData.getContextRoot();
-      webContext = buildWebContext(unit, webContext, warName, metaData);
-      metaData.setContextRoot(webContext);
+         ClassLoadingMetaData classLoading = metaData.getClassLoading();
+         if (classLoading == null)
+            classLoading = new ClassLoadingMetaData();
+         // pass in the java2ClassLoadingCompliance if it was not set at the war level
+         if (classLoading.wasJava2ClassLoadingComplianceSet() == false)
+            classLoading.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
+         metaData.setClassLoading(classLoading);
 
-      AbstractWarDeployment deployment = getDeployment(unit, metaData);
-      deployment.setMainDeployer(mainDeployer);
-      
-      // TODO: until deployment is a MC bean
-      deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver);
-      deployWebModule(unit, metaData, deployment);
-    }
-    catch (Exception e)
-    {
-      throw new DeploymentException("Failed to create web module", e);
-    }
-  }
+         // Build the context root if its not been set or is specified at the ear
+         String webContext = metaData.getContextRoot();
+         webContext = buildWebContext(webContext, warName, metaData, unit);
+         metaData.setContextRoot(webContext);
 
-  /**
-   * Cleanup war deployer specifics.
-   */
-  @Override
-  public void undeploy(DeploymentUnit unit, JBossWebMetaData metaData)
-  {
-    try
-    {
-      // Delete any expanded war
-      URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
-      if (warURL != null)
+         AbstractWarDeployment deployment = getDeployment(unit, metaData);
+         deployment.setMainDeployer(mainDeployer);
+         // TODO: until deployment is a MC bean
+         deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver);
+         deployWebModule(unit, metaData, deployment);
+      }
+      catch (Exception e)
       {
-        File war = new File(warURL.toURI());
-        Files.delete(war);
+         throw new DeploymentException("Failed to create web module", e);
       }
-    }
-    catch (Exception e)
-    {
-      log.debug("Failed to remove expanded war", e);
-    }
-  }
+   }
 
-  public void addDeployedApp(String warURL, WebApplication webApp)
-  {
-    deploymentMap.put(warURL, webApp);
-  }
+   /**
+    * Cleanup war deployer specifics.
+    */
+   @Override
+   public void undeploy(DeploymentUnit unit, JBossWebMetaData metaData)
+   {
+      try
+      {
+         // Delete any expanded war
+         URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
+         if (warURL != null)
+         {
+            File war = new File(warURL.toURI());
+            Files.delete(war);
+         }
+      }
+      catch (Exception e)
+      {
+         log.debug("Failed to remove expanded war", e);
+      }
+      /* Clear class loader refs
+       metaData.setContextLoader(null);
+       metaData.setResourceClassLoader(null);
+       metaData.setENCLoader(null);
+       */
+   }
 
-  /** Get the WebApplication object for a deployed war.
-   @param warUrl the war url string as originally passed to deploy().
-   @return The WebApplication created during the deploy step if the
-   warUrl is valid, null if no such deployment exists.
-   */
-  public WebApplication getDeployedApp(String warUrl)
-  {
-    WebApplication appInfo = (WebApplication)deploymentMap.get(warUrl);
-    return appInfo;
-  }
+   public void addDeployedApp(String warURL, WebApplication webApp)
+   {
+      deploymentMap.put(warURL, webApp);
+   }
 
-  public WebApplication removeDeployedApp(String warURL)
-  {
-    WebApplication appInfo = (WebApplication)deploymentMap.remove(warURL);
-    return appInfo;
-  }
+   /** Get the WebApplication object for a deployed war.
+    @param warUrl the war url string as originally passed to deploy().
+    @return The WebApplication created during the deploy step if the
+    warUrl is valid, null if no such deployment exists.
+    */
+   public WebApplication getDeployedApp(String warUrl)
+   {
+      WebApplication appInfo = (WebApplication)deploymentMap.get(warUrl);
+      return appInfo;
+   }
 
-  /** Returns the applications deployed by the web container subclasses.
-   @jmx:managed-attribute
-   @return An Iterator of WebApplication objects for the deployed wars.
-   */
-  public Iterator getDeployedApplications()
-  {
-    return deploymentMap.values().iterator();
-  }
+   public WebApplication removeDeployedApp(String warURL)
+   {
+      WebApplication appInfo = (WebApplication)deploymentMap.remove(warURL);
+      return appInfo;
+   }
 
-  /** A utility method that uses reflection to access a URL[] getURLs method
-   * so that non-URLClassLoader class loaders that support this method can
-   * provide info.
-   */
-  public static URL[] getClassLoaderURLs(ClassLoader cl)
-  {
-    URL[] urls = {};
-    try
-    {
-      Class returnType = urls.getClass();
-      Class[] parameterTypes = {};
-      Method getURLs = cl.getClass().getMethod("getURLs", parameterTypes);
-      if (returnType.isAssignableFrom(getURLs.getReturnType()))
+   /** Returns the applications deployed by the web container subclasses.
+    @jmx:managed-attribute
+    @return An Iterator of WebApplication objects for the deployed wars.
+    */
+   public Iterator getDeployedApplications()
+   {
+      return deploymentMap.values().iterator();
+   }
+
+   /** A utility method that uses reflection to access a URL[] getURLs method
+    * so that non-URLClassLoader class loaders that support this method can
+    * provide info.
+    */
+   public static URL[] getClassLoaderURLs(ClassLoader cl)
+   {
+      URL[] urls = {};
+      try
       {
-        Object[] args = {};
-        urls = (URL[])getURLs.invoke(cl, args);
+         Class returnType = urls.getClass();
+         Class[] parameterTypes = {};
+         Method getURLs = cl.getClass().getMethod("getURLs", parameterTypes);
+         if (returnType.isAssignableFrom(getURLs.getReturnType()))
+         {
+            Object[] args = {};
+            urls = (URL[])getURLs.invoke(cl, args);
+         }
+         if (urls == null || urls.length == 0)
+         {
+            getURLs = cl.getClass().getMethod("getAllURLs", parameterTypes);
+            if (returnType.isAssignableFrom(getURLs.getReturnType()))
+            {
+               Object[] args = {};
+               urls = (URL[])getURLs.invoke(cl, args);
+            }
+         }
       }
-      if (urls == null || urls.length == 0)
+      catch (Exception ignore)
       {
-        getURLs = cl.getClass().getMethod("getAllURLs", parameterTypes);
-        if (returnType.isAssignableFrom(getURLs.getReturnType()))
-        {
-          Object[] args = {};
-          urls = (URL[])getURLs.invoke(cl, args);
-        }
       }
-    }
-    catch (Exception ignore)
-    {
-    }
-    return urls;
-  }
+      return urls;
+   }
 
-  /** This method creates a context-root string from either the
-   WEB-INF/jboss-web.xml context-root element is one exists, or the
-   filename portion of the warURL. It is called if the deployment
-   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(DeploymentUnit unit, String ctxPath, String warName, JBossWebMetaData metaData)
-  {
-    // Build a war root context from the war name if one was not specified
-    String webContext = ctxPath;
+   /** This method creates a context-root string from either the
+    WEB-INF/jboss-web.xml context-root element is one exists, or the
+    filename portion of the warURL. It is called if the deployment
+    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, JBossWebMetaData metaData, DeploymentUnit unit)
+   {
+      // Build a war root context from the war name if one was not specified
+      String webContext = ctxPath;
 
-    // Build the context from the deployment name
-    if (webContext == null)
-    {
-      // Build the context from the war name, strip the .war suffix
-      webContext = warName;
-      webContext = webContext.replace('\\', '/');
-      if (webContext.endsWith("/"))
-        webContext = webContext.substring(0, webContext.length() - 1);
-      int prefix = webContext.lastIndexOf('/');
-      if (prefix > 0)
-        webContext = webContext.substring(prefix + 1);
-      int suffix = webContext.lastIndexOf(".war");
-      if (suffix > 0)
-        webContext = webContext.substring(0, suffix);
-      // Strip any '<int-value>.' prefix
-      int index = 0;
-      for (; index < webContext.length(); index++)
+      // Build the context from the deployment name
+      if (webContext == null)
       {
-        char c = webContext.charAt(index);
-        if (Character.isDigit(c) == false && c != '.')
-          break;
+         // Build the context from the war name, strip the .war suffix
+         webContext = warName;
+         webContext = webContext.replace('\\', '/');
+         if (webContext.endsWith("/"))
+            webContext = webContext.substring(0, webContext.length() - 1);
+         int prefix = webContext.lastIndexOf('/');
+         if (prefix > 0)
+            webContext = webContext.substring(prefix + 1);
+         int suffix = webContext.lastIndexOf(".war");
+         if (suffix > 0)
+            webContext = webContext.substring(0, suffix);
+         // Strip any '<int-value>.' prefix
+         int index = 0;
+         for (; index < webContext.length(); index++)
+         {
+            char c = webContext.charAt(index);
+            if (Character.isDigit(c) == false && c != '.')
+               break;
+         }
+         webContext = webContext.substring(index);
       }
-      webContext = webContext.substring(index);
-    }
 
-    // Servlet containers are anal about the web context starting with '/'
-    if (webContext.length() > 0 && webContext.charAt(0) != '/')
-      webContext = "/" + webContext;
-    
-    // And also the default root context must be an empty string, not '/'
-    else if (webContext.equals("/"))
-      webContext = "";
-    
-    return webContext;
-  }
+      // Servlet containers are anal about the web context starting with '/'
+      if (webContext.length() > 0 && webContext.charAt(0) != '/')
+         webContext = "/" + webContext;
+      // And also the default root context must be an empty string, not '/'
+      else if (webContext.equals("/"))
+         webContext = "";
+      return webContext;
+   }
 
-  /**
-   * TODO: The use of an MBeanServer needs to be removed
-   * @return
-   */
-  @Deprecated
-  protected MBeanServer getServer()
-  {
-    return server;
-  }
+   /**
+    * TODO: The use of an MBeanServer needs to be removed
+    * @return
+    */
+   @Deprecated
+   protected MBeanServer getServer()
+   {
+      return server;
+   }
 
-  public MainDeployerStructure getMainDeployer()
-  {
-    return mainDeployer;
-  }
+   public MainDeployerStructure getMainDeployer()
+   {
+      return mainDeployer;
+   }
 
-  public void setMainDeployer(MainDeployerStructure mainDeployer)
-  {
-    this.mainDeployer = mainDeployer;
-  }
+   public void setMainDeployer(MainDeployerStructure mainDeployer)
+   {
+      this.mainDeployer = mainDeployer;
+   }
 
-  /**
-   * Get the object name of the ServiceMetaData instance associated with
-   * the WebMetaData. This uses the pattern:
-   * "jboss.web.deployment:war="+metaData.getContextRoot()
-   * if there are no virtual hosts, otherwise
-   * "jboss.web.deployment:war="+metaData.getVirtualHosts()[0]+metaData.getContextRoot()
-   * @param metaData - the web app metaData
-   * @return the war object name
-   */
-  protected String getObjectName(JBossWebMetaData metaData)
-  {
-    // Obtain the war virtual host and context root to define a unique war name
-    String virtualHost = "";
-    List<String> hosts = metaData.getVirtualHosts();
-    if (hosts != null && hosts.size() > 0)
-    {
-      virtualHost = hosts.get(0);
-    }
-    String ctxPath = metaData.getContextRoot();
-    
-    // The ctx path value cannot be empty in the object name
-    if (ctxPath == null || ctxPath.length() == 0)
-      ctxPath = "/";
-    
-    String objectName = "jboss.web.deployment:war=" + virtualHost + ctxPath;
-    return objectName;
-  }
+   /**
+    * Get the object name of the ServiceMetaData instance associated with
+    * the WebMetaData. This uses the pattern:
+    * "jboss.web.deployment:war="+metaData.getContextRoot()
+    * if there are no virtual hosts, otherwise
+    * "jboss.web.deployment:war="+metaData.getVirtualHosts()[0]+metaData.getContextRoot()
+    * @param metaData - the web app metaData
+    * @return the war object name
+    */
+   protected String getObjectName(JBossWebMetaData metaData)
+   {
+      // Obtain the war virtual host and context root to define a unique war name
+      String virtualHost = "";
+      List<String> hosts = metaData.getVirtualHosts();
+      if(hosts != null && hosts.size() > 0)
+      {
+         virtualHost = hosts.get(0);
+      }
+      String ctxPath = metaData.getContextRoot();
+      // The ctx path value cannot be empty in the object name
+      if (ctxPath == null || ctxPath.length() == 0)
+         ctxPath = "/";
+      String objectName = "jboss.web.deployment:war=" + virtualHost + ctxPath;
+      return objectName;
+   }
 
-  /**
-   * Called by deploy first to create a ServiceMetaData instance that wraps the
-   * AbstractWarDeployment bean and then attach it to the deployment unit. The
-   * presence of the ServiceMetaData attachment makes the deployment unit
-   * "relevant" to the deployers that handle mbean services.
-   * 
-   * @param unit - the deployment unit
-   * @param metaData - the web app metadata passed to deploy
-   * @param deployment - the web app deployment bean created by getDeployment
-   * @throws Exception
-   */
-  protected void deployWebModule(DeploymentUnit unit, JBossWebMetaData metaData, AbstractWarDeployment deployment) throws Exception
-  {
-    log.debug("deployWebModule: " + unit.getName());
-    try
-    {
-      ServiceMetaData webModule = new ServiceMetaData();
-      String name = getObjectName(metaData);
-      ObjectName objectName = new ObjectName(name);
-      webModule.setObjectName(objectName);
-      webModule.setCode(WebModule.class.getName());
-      
-      // WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment)
-      ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
-      constructor.setSignature(new String[] { DeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() });
-      constructor.setParameters(new Object[] { unit, this, deployment });
-      webModule.setConstructor(constructor);
+   /**
+    * Called by deploy first to create a ServiceMetaData instance that wraps the
+    * AbstractWarDeployment bean and then attach it to the deployment unit. The
+    * presence of the ServiceMetaData attachment makes the deployment unit
+    * "relevant" to the deployers that handle mbean services.
+    * 
+    * @param unit - the deployment unit
+    * @param metaData - the web app metadata passed to deploy
+    * @param deployment - the web app deployment bean created by getDeployment
+    * @throws Exception
+    */
+   protected void deployWebModule(DeploymentUnit unit, JBossWebMetaData metaData, AbstractWarDeployment deployment) throws Exception
+   {
+      log.debug("deployWebModule: " + unit.getName());
+      try
+      {
+         ServiceMetaData webModule = new ServiceMetaData();
+         String name = getObjectName(metaData);
+         ObjectName objectName = new ObjectName(name);
+         webModule.setObjectName(objectName);
+         webModule.setCode(WebModule.class.getName());
+         // WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment)
+         ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
+         constructor.setSignature(new String[] { VFSDeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() });
+         constructor.setParameters(new Object[] { unit, this, deployment });
+         webModule.setConstructor(constructor);
 
-      List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>();
+         List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>();
 
-      ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
-      attr.setName("SecurityManagement");
-      ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(deployment.getSecurityManagementName());
-      attr.setValue(injectionValue);
-      attrs.add(attr);
+         ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
+         attr.setName("SecurityManagement");
+         ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(deployment.getSecurityManagementName());
+         attr.setValue(injectionValue);
+         attrs.add(attr);
+         
+         ServiceAttributeMetaData attrPR = new ServiceAttributeMetaData();
+         attrPR.setName("PolicyRegistration");
+         ServiceInjectionValueMetaData injectionValuePR = new ServiceInjectionValueMetaData(deployment.getPolicyRegistrationName());
+         attrPR.setValue(injectionValuePR);
+         attrs.add(attrPR);
+         
+         ServiceAttributeMetaData attrKernel = new ServiceAttributeMetaData();
+         attrKernel.setName("Kernel");
+         ServiceInjectionValueMetaData injectionValueKernel = new ServiceInjectionValueMetaData(KernelConstants.KERNEL_NAME);
+         attrKernel.setValue(injectionValueKernel);
+         attrs.add(attrKernel);
 
-      ServiceAttributeMetaData attrPR = new ServiceAttributeMetaData();
-      attrPR.setName("PolicyRegistration");
-      ServiceInjectionValueMetaData injectionValuePR = new ServiceInjectionValueMetaData(deployment.getPolicyRegistrationName());
-      attrPR.setValue(injectionValuePR);
-      attrs.add(attrPR);
+         webModule.setAttributes(attrs);
 
-      ServiceAttributeMetaData attrKernel = new ServiceAttributeMetaData();
-      attrKernel.setName("Kernel");
-      ServiceInjectionValueMetaData injectionValueKernel = new ServiceInjectionValueMetaData(KernelConstants.KERNEL_NAME);
-      attrKernel.setValue(injectionValueKernel);
-      attrs.add(attrKernel);
+         // Dependencies...Still have old jmx names here
+         Collection<String> depends = metaData.getDepends();
+         List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
+         if (depends != null && depends.isEmpty() == false)
+         {
+            if (log.isTraceEnabled())
+               log.trace(name + " has dependencies: " + depends);
 
-      webModule.setAttributes(attrs);
+            for (String iDependOn : depends)
+            {
+               ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
+               sdmd.setIDependOn(iDependOn);
+               dependencies.add(sdmd);
+            }
+         }
+         webModule.setDependencies(dependencies);
 
-      // Dependencies...Still have old jmx names here
-      Collection<String> depends = metaData.getDepends();
-      List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
-      if (depends != null && depends.isEmpty() == false)
-      {
-        if (log.isTraceEnabled())
-          log.trace(name + " has dependencies: " + depends);
+         // Here's where a bit of magic happens. By attaching the ServiceMetaData
+         // to the deployment, we now make the deployment "relevant" to
+         // deployers that use ServiceMetaData as an input (e.g. the
+         // org.jboss.system.deployers.ServiceDeployer).  Those deployers
+         // can now take over deploying the web module.
 
-        for (String iDependOn : depends)
-        {
-          ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
-          sdmd.setIDependOn(iDependOn);
-          dependencies.add(sdmd);
-        }
+         unit.addAttachment("WarServiceMetaData", webModule, ServiceMetaData.class);
       }
-      webModule.setDependencies(dependencies);
-
-      // Here's where a bit of magic happens. By attaching the ServiceMetaData
-      // to the deployment, we now make the deployment "relevant" to
-      // deployers that use ServiceMetaData as an input (e.g. the
-      // org.jboss.system.deployers.ServiceDeployer). Those deployers
-      // can now take over deploying the web module.
-
-      unit.addAttachment("WarServiceMetaData", webModule, ServiceMetaData.class);
-    }
-    catch (Exception e)
-    {
-      throw DeploymentException.rethrowAsDeploymentException("Error creating rar deployment " + unit.getName(), e);
-    }
-  }
+      catch (Exception e)
+      {
+         throw DeploymentException.rethrowAsDeploymentException("Error creating rar deployment " + unit.getName(), e);
+      }
+   }
 }

Modified: branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
===================================================================
--- branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java	2009-02-02 09:30:08 UTC (rev 83765)
+++ branches/tdiesler/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java	2009-02-02 09:54:27 UTC (rev 83766)
@@ -36,7 +36,6 @@
 import javax.naming.NamingException;
 
 import org.jboss.beans.metadata.api.annotations.Inject;
-import org.jboss.bootstrap.spi.ServerConfig;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
@@ -127,22 +126,22 @@
    /**
     * The default security-domain name to use
     */
-   protected String defaultSecurityDomain;
-
+   protected String defaultSecurityDomain; 
+   
    /** The Security PolicyRegistration Name **/
    protected String policyRegistrationName;
-
+   
    /** The Security PolicyRegistration **/
    protected PolicyRegistration policyRegistration;
 
    /** The security management name */
    protected String securityManagementName;
-
+   
    /** The security management */
    protected ISecurityManagement securityManagement;
-
+   
    private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
-
+   
    public AbstractWarDeployment()
    {
       log = Logger.getLogger(getClass());
@@ -167,16 +166,16 @@
     */
    public static String shortWarUrlFromServerHome(String warUrl)
    {
-      String serverHomeUrl = System.getProperty(ServerConfig.SERVER_HOME_URL);
+       String serverHomeUrl =  System.getProperty(org.jboss.bootstrap.spi.ServerConfig.SERVER_HOME_URL);
 
-      if (warUrl == null || serverHomeUrl == null)
-         return warUrl;
+       if (warUrl == null || serverHomeUrl == null)
+           return warUrl;
 
-      if (warUrl.startsWith(serverHomeUrl))
+       if (warUrl.startsWith(serverHomeUrl))
          return ".../" + warUrl.substring(serverHomeUrl.length());
-      else
+       else
          return warUrl;
-   }
+   } 
 
    /**
     * Initialize the deployment using an instance specific configuration object.
@@ -280,8 +279,8 @@
     */
    public String getDefaultSecurityDomain()
    {
-      if (defaultSecurityDomain == null)
-         throw new IllegalStateException("Default Security Domain is null");
+	  if(defaultSecurityDomain == null)
+		  throw new IllegalStateException("Default Security Domain is null");
       return defaultSecurityDomain;
    }
 
@@ -295,19 +294,19 @@
    public void setDefaultSecurityDomain(String defaultSecurityDomain)
    {
       this.defaultSecurityDomain = defaultSecurityDomain;
-   }
+   } 
 
    protected PersistenceUnitDependencyResolver getPersistenceUnitDependencyResolver()
    {
       return persistenceUnitDependencyResolver;
    }
-
+   
    @Inject
    public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
    {
       this.persistenceUnitDependencyResolver = resolver;
    }
-
+   
    /**
     * Get the Policy Registration Name
     * @return
@@ -362,7 +361,7 @@
    public void setSecurityManagementName(String securityManagement)
    {
       this.securityManagementName = securityManagement;
-   }
+   } 
 
    /**
     * Get the securityManagement.
@@ -416,7 +415,8 @@
     * be null if war was is not being deployed as part of an enterprise
     * application. It also contains the URL of the web application war.
     */
-   public synchronized WebApplication start(DeploymentUnit unit, JBossWebMetaData metaData) throws Exception
+   public synchronized WebApplication start(VFSDeploymentUnit unit, JBossWebMetaData metaData)
+      throws Exception
    {
       Thread thread = Thread.currentThread();
       ClassLoader appClassLoader = thread.getContextClassLoader();
@@ -425,39 +425,39 @@
       {
          // Create a classloader for the war to ensure a unique ENC
          // TODO: this should be handled by the WarClassLoaderDeployer
+         /*
+         VirtualFile root = unit.getRoot();
+         URL[] empty = {root.toURL()};
+         URLClassLoader warLoader = URLClassLoader.newInstance(empty, unit.getClassLoader());
+         */
          ClassLoader warLoader = unit.getClassLoader();
          thread.setContextClassLoader(warLoader);
          String webContext = metaData.getContextRoot();
-
+   
          // Get the war URL
+         // FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
          URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
-         if (warURL == null && unit instanceof VFSDeploymentUnit)
-            warURL = ((VFSDeploymentUnit)unit).getRoot().toURL();
-
-         // For in-memory WebMetaData deployments we use the deployment name as the warURL
-         // The WS Endpoint API uses this approach
          if (warURL == null)
-            warURL = new URL(unit.getName());
+            warURL = unit.getRoot().toURL();
 
          // Strip any jar: url syntax. This should be be handled by the vfs
-         String warURLStr = warURL.toString();
-         if (warURLStr.startsWith("jar:"))
-            warURLStr = warURLStr.substring(4, warURLStr.length() - 2);
-
+         String warURLString = warURL.toString();
+         if( warURLString.startsWith("jar:") )
+            warURLString = warURLString.substring(4, warURLString.length()-2);
+         
          log.debug("webContext: " + webContext);
-         log.debug("warURL: " + warURLStr);
-
+         log.debug("warURL: " + warURLString);
+   
          // Register the permissions with the JACC layer
          String contextID = metaData.getJaccContextID();
-         if (contextID == null)
+         if( contextID == null )
             contextID = unit.getSimpleName();
-
-         metaData.setJaccContextID(contextID);
-
+         metaData.setJaccContextID(contextID);  
+   
          webApp = new WebApplication(metaData);
          webApp.setClassLoader(warLoader);
          webApp.setDeploymentUnit(unit);
-         performDeploy(webApp, warURLStr);
+         performDeploy(webApp, warURLString);
       }
       finally
       {
@@ -472,11 +472,12 @@
     * performUndeploy()} method to perform the container specific undeployment
     * steps and unregisters the the warUrl from the deployment map.
     */
-   public synchronized void stop(DeploymentUnit di, WebApplication webApp) throws Exception
+   public synchronized void stop(DeploymentUnit di, WebApplication webApp)
+      throws Exception
    {
       URL warURL = webApp.getURL();
       String warUrl = warURL.toString();
-      performUndeploy(webApp, warUrl);
+      performUndeploy(webApp, warUrl); 
    }
 
    /**
@@ -489,7 +490,6 @@
     * @param warUrl The string for the URL of the web application war.
     */
    protected abstract void performDeploy(WebApplication webApp, String warUrl) throws Exception;
-
    /**
     * Called as part of the stop() method template to ask the subclass for
     * perform the web container specific undeployment steps.
@@ -498,7 +498,8 @@
     * application/module/web application.xml descriptor and virtual-host.
     * @param warUrl The string for the URL of the web application war.
     */
-   protected abstract void performUndeploy(WebApplication webApp, String warUrl) throws Exception;
+   protected abstract void performUndeploy(WebApplication webApp, String warUrl)
+      throws Exception;
 
    /**
     * This method is invoked from within subclass performDeploy() method
@@ -507,10 +508,11 @@
     * @param metaData the WebMetaData from the WebApplication object passed to
     * the performDeploy method.
     */
-   protected void processEnc(ClassLoader loader, WebApplication webApp) throws Exception
+   protected void processEnc(ClassLoader loader, WebApplication webApp)
+      throws Exception
    {
-      if (loader == null)
-         throw new IllegalArgumentException("Classloader passed to process ENC refs is null");
+	  if(loader == null)
+		  throw new IllegalArgumentException("Classloader passed to process ENC refs is null");
       log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin");
       InitialContext iniCtx = new InitialContext();
       Context envCtx = null;
@@ -529,15 +531,15 @@
          }
          // TODO: The enc should be an input?
          currentThread.setContextClassLoader(loader);
-         // webApp.setENCLoader(loader);
-         envCtx = (Context)iniCtx.lookup("java:comp");
+         //webApp.setENCLoader(loader);
+         envCtx = (Context) iniCtx.lookup("java:comp");
 
          // TODO: inject the ORB
          ORB orb = null;
          try
          {
             ObjectName ORB_NAME = new ObjectName("jboss:service=CorbaORB");
-            orb = (ORB)server.getAttribute(ORB_NAME, "ORB");
+            orb = (ORB) server.getAttribute(ORB_NAME, "ORB");
             // Bind the orb
             if (orb != null)
             {
@@ -567,9 +569,10 @@
       log.debug("AbstractWebContainer.parseWebAppDescriptors, End");
    }
 
-   protected void processEncReferences(WebApplication webApp, Context envCtx) throws ClassNotFoundException, NamingException
+   protected void processEncReferences(WebApplication webApp, Context envCtx)
+           throws ClassNotFoundException, NamingException
    {
-      DeploymentUnit unit = webApp.getDeploymentUnit();
+      VFSDeploymentUnit unit = webApp.getDeploymentUnit();
       JBossWebMetaData metaData = webApp.getMetaData();
       EnvironmentEntriesMetaData envEntries = metaData.getEnvironmentEntries();
       log.debug("addEnvEntries");
@@ -594,33 +597,32 @@
       linkServiceRefs(unit, serviceRefs, envCtx);
    }
 
-   private void linkServiceRefs(DeploymentUnit unit, ServiceReferencesMetaData serviceRefs, Context envCtx) throws NamingException
+   private void linkServiceRefs(VFSDeploymentUnit unit, ServiceReferencesMetaData serviceRefs, Context envCtx) throws NamingException
    {
       ClassLoader loader = unit.getClassLoader();
-      if (unit instanceof VFSDeploymentUnit)
+      UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot());
+      for(ServiceReferenceMetaData sref : serviceRefs)
       {
-         VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
-         UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(vfsUnit.getRoot());
-         for (ServiceReferenceMetaData sref : serviceRefs)
-         {
-            String refName = sref.getServiceRefName();
-            new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
-         }
+         String refName = sref.getServiceRefName();
+         new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
       }
    }
 
-   protected void addEnvEntries(EnvironmentEntriesMetaData envEntries, Context envCtx) throws ClassNotFoundException, NamingException
+   protected void addEnvEntries(EnvironmentEntriesMetaData envEntries, Context envCtx)
+      throws ClassNotFoundException, NamingException
    {
       for (EnvironmentEntryMetaData entry : envEntries)
       {
-         log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue());
+         log.debug("Binding env-entry: " + entry.getName() + " of type: " +
+            entry.getType() + " to value:" + entry.getValue());
          bindEnvEntry(envCtx, entry);
       }
    }
 
-   protected void linkResourceEnvRefs(ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx) throws NamingException
+   protected void linkResourceEnvRefs(ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx)
+      throws NamingException
    {
-      for (ResourceEnvironmentReferenceMetaData ref : resourceEnvRefs)
+      for(ResourceEnvironmentReferenceMetaData ref : resourceEnvRefs)
       {
          String resourceName = ref.getJndiName();
          String refName = ref.getResourceEnvRefName();
@@ -644,14 +646,16 @@
          }
          else
          {
-            throw new NamingException("resource-env-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-env-ref.");
+            throw new NamingException("resource-env-ref: " + refName
+               + " has no valid JNDI binding. Check the jboss-web/resource-env-ref.");
          }
       }
    }
 
-   protected void linkResourceRefs(ResourceReferencesMetaData resourceRefs, Context envCtx) throws NamingException
+   protected void linkResourceRefs(ResourceReferencesMetaData resourceRefs, Context envCtx)
+      throws NamingException
    {
-      for (ResourceReferenceMetaData ref : resourceRefs)
+      for(ResourceReferenceMetaData ref : resourceRefs)
       {
          String jndiName = ref.getJndiName();
          String refName = ref.getResourceName();
@@ -685,14 +689,16 @@
          }
          else
          {
-            throw new NamingException("resource-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-ref.");
+            throw new NamingException("resource-ref: " + refName
+               + " has no valid JNDI binding. Check the jboss-web/resource-ref.");
          }
       }
    }
 
-   protected void linkMessageDestinationRefs(DeploymentUnit unit, MessageDestinationReferencesMetaData msgRefs, Context envCtx) throws NamingException
+   protected void linkMessageDestinationRefs(DeploymentUnit unit, MessageDestinationReferencesMetaData msgRefs, Context envCtx)
+      throws NamingException
    {
-      for (MessageDestinationReferenceMetaData ref : msgRefs)
+      for(MessageDestinationReferenceMetaData ref : msgRefs)
       {
          String refName = ref.getName();
          String jndiName = ref.getJndiName();
@@ -703,8 +709,8 @@
             {
                MessageDestinationMetaData messageDestination = EjbUtil50.findMessageDestination(mainDeployer, unit, link);
                if (messageDestination == null)
-                  throw new NamingException("message-destination-ref '" + refName + "' message-destination-link '" + link
-                        + "' not found and no jndi-name in jboss-web.xml");
+                  throw new NamingException("message-destination-ref '" + refName +
+                     "' message-destination-link '" + link + "' not found and no jndi-name in jboss-web.xml");
                else
                {
                   String linkJNDIName = messageDestination.getJndiName();
@@ -715,33 +721,37 @@
                }
             }
             else
-               log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss-web.xml");
+               log.warn("message-destination-ref '" + refName +
+                  "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss-web.xml");
          }
          else if (jndiName == null)
-            throw new NamingException("message-destination-ref '" + refName + "' has no message-destination-link in web.xml and no jndi-name in jboss-web.xml");
+            throw new NamingException("message-destination-ref '" + refName +
+               "' has no message-destination-link in web.xml and no jndi-name in jboss-web.xml");
          Util.bind(envCtx, refName, new LinkRef(jndiName));
       }
    }
 
-   protected void linkEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, Context envCtx) throws NamingException
+   protected void linkEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, Context envCtx)
+      throws NamingException
    {
-      for (EJBReferenceMetaData ejb : ejbRefs)
+      for(EJBReferenceMetaData ejb : ejbRefs)
       {
          String name = ejb.getName();
          String linkName = ejb.getLink();
          String jndiName = null;
-
-         // use ejb-link if it is specified
+         
+         //use ejb-link if it is specified
          if (linkName != null)
          {
             jndiName = EjbUtil50.findEjbLink(mainDeployer, unit, linkName);
-
-            // if flag does not allow misconfigured ejb-links, it is an error
+             
+            //if flag does not allow misconfigured ejb-links, it is an error
             if ((jndiName == null) && !(getLenientEjbLink()))
                throw new NamingException("ejb-ref: " + name + ", no ejb-link match");
          }
 
-         // fall through to the jndiName
+         
+         //fall through to the jndiName
          if (jndiName == null)
          {
             jndiName = ejb.getJndiName();
@@ -754,24 +764,26 @@
       }
    }
 
-   protected void linkEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx) throws NamingException
+   protected void linkEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx)
+      throws NamingException
    {
-      for (EJBLocalReferenceMetaData ejb : ejbLocalRefs)
+      for(EJBLocalReferenceMetaData ejb : ejbLocalRefs)
       {
          String name = ejb.getName();
          String linkName = ejb.getLink();
          String jndiName = null;
 
-         // use the ejb-link field if it is specified
+         //use the ejb-link field if it is specified
          if (linkName != null)
          {
             jndiName = EjbUtil50.findLocalEjbLink(mainDeployer, unit, linkName);
-
-            // if flag does not allow misconfigured ejb-links, it is an error
+             
+            //if flag does not allow misconfigured ejb-links, it is an error    
             if ((jndiName == null) && !(getLenientEjbLink()))
                throw new NamingException("ejb-ref: " + name + ", no ejb-link match");
          }
 
+
          if (jndiName == null)
          {
             jndiName = ejb.getJndiName();
@@ -780,11 +792,13 @@
                String msg = null;
                if (linkName == null)
                {
-                  msg = "ejb-local-ref: '" + name + "', no ejb-link in web.xml and " + "no local-jndi-name in jboss-web.xml";
+                  msg = "ejb-local-ref: '" + name + "', no ejb-link in web.xml and "
+                     + "no local-jndi-name in jboss-web.xml";
                }
                else
                {
-                  msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '" + linkName + "' failed to resolve to an ejb with a LocalHome";
+                  msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '"
+                     + linkName + "' failed to resolve to an ejb with a LocalHome";
                }
                throw new NamingException(msg);
             }
@@ -804,22 +818,23 @@
     * element. If there was no security-domain element then the bindings are to
     * NullSecurityManager instance which simply allows all access.
     */
-   protected void linkSecurityDomain(String securityDomain, Context envCtx) throws NamingException
+   protected void linkSecurityDomain(String securityDomain, Context envCtx)
+      throws NamingException
    {
       if (securityDomain == null)
       {
          securityDomain = getDefaultSecurityDomain();
          log.debug("No security-domain given, using default: " + securityDomain);
       }
-
-      // JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix
-      if (securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false)
+      
+      //JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix
+      if(securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false)
          securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain;
-
+      
       log.debug("Linking security/securityMgr to JNDI name: " + securityDomain);
       Util.bind(envCtx, "security/securityMgr", new LinkRef(securityDomain));
-      Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain + "/realmMapping"));
-      Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain + "/authorizationMgr"));
+      Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain+"/realmMapping"));
+      Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain+"/authorizationMgr"));
       Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain));
       Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject"));
    }
@@ -833,7 +848,11 @@
     */
    public String[] getStandardCompileClasspath(ClassLoader loader)
    {
-      String[] jspResources = { "javax/servlet/resources/web-app_2_3.dtd", "org/apache/jasper/resources/jsp12.dtd", "javax/ejb/EJBHome.class" };
+      String[] jspResources = {
+         "javax/servlet/resources/web-app_2_3.dtd",
+         "org/apache/jasper/resources/jsp12.dtd",
+         "javax/ejb/EJBHome.class"
+      };
       ArrayList tmp = new ArrayList();
       for (int j = 0; j < jspResources.length; j++)
       {
@@ -878,7 +897,8 @@
       }
       try
       {
-         URL[] globalUrls = (URL[])server.getAttribute(LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY, "URLs");
+         URL[] globalUrls = (URL[]) server.getAttribute(LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY,
+            "URLs");
          addURLs(tmp, globalUrls);
       }
       catch (Exception e)
@@ -898,9 +918,10 @@
          URL url = urls[u];
          urlSet.add(url.toExternalForm());
       }
-   }
+   } 
 
-   public static void bindEnvEntry(Context ctx, EnvironmentEntryMetaData entry) throws ClassNotFoundException, NamingException
+   public static void bindEnvEntry(Context ctx, EnvironmentEntryMetaData entry)
+      throws ClassNotFoundException, NamingException
    {
       ClassLoader loader = EnvironmentEntryMetaData.class.getClassLoader();
       Class type = loader.loadClass(entry.getType());
@@ -934,7 +955,7 @@
          String input = entry.getValue();
          if (input == null || input.length() == 0)
          {
-            value = new Character((char)0);
+            value = new Character((char) 0);
          }
          else
          {
@@ -957,3 +978,4 @@
       }
    }
 }
+

Modified: branches/tdiesler/server/src/main/org/jboss/web/deployers/WebModule.java
===================================================================
--- branches/tdiesler/server/src/main/org/jboss/web/deployers/WebModule.java	2009-02-02 09:30:08 UTC (rev 83765)
+++ branches/tdiesler/server/src/main/org/jboss/web/deployers/WebModule.java	2009-02-02 09:54:27 UTC (rev 83766)
@@ -21,7 +21,6 @@
  */
 package org.jboss.web.deployers;
 
-import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.deployment.DeploymentException;
 import org.jboss.kernel.Kernel;
@@ -50,18 +49,18 @@
 {
    private static Logger log = Logger.getLogger(WebModule.class);
 
-   private DeploymentUnit unit;
+   private VFSDeploymentUnit di;
    private AbstractWarDeployer container;
    private AbstractWarDeployment deployment; 
 
    private ISecurityManagement securityManagement;
    
-   public WebModule(DeploymentUnit unit, AbstractWarDeployer container, AbstractWarDeployment deployment)
+   public WebModule(VFSDeploymentUnit di, AbstractWarDeployer container, AbstractWarDeployment deployment)
    {
-      this.unit = unit;
+      this.di = di;
       this.container = container;
       this.deployment = deployment;
-      this.deployment.setDeploymentUnit(unit);
+      this.deployment.setDeploymentUnit(di);
    }
 
    public void setKernel(Kernel kernel)
@@ -104,7 +103,7 @@
 
    public void destroy()
    {
-      this.unit = null;
+      this.di = null;
       this.container = null;
       this.deployment = null;      
    }
@@ -115,10 +114,10 @@
       throws Exception
    {
       // Get the war URL
-      JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); 
-      WebApplication webApp = deployment.start(unit, metaData);
-      String depName = unit.getName();
-      container.addDeployedApp(depName, webApp);
+      JBossWebMetaData metaData = di.getAttachment(JBossWebMetaData.class); 
+      WebApplication webApp = deployment.start(di, metaData);
+      String warURL = di.getName();
+      container.addDeployedApp(warURL, webApp);
    }
 
    /** Invokes the deployer stop
@@ -126,17 +125,17 @@
    public synchronized void stopModule()
       throws DeploymentException
    {
-      String depName = unit.getName();
+      String warURL = di.getName();
       try
       {
-         WebApplication webApp = container.removeDeployedApp(depName);
+         WebApplication webApp = container.removeDeployedApp(warURL);
          if( deployment != null && webApp != null )
          {
-            deployment.stop(unit, webApp);
+            deployment.stop(di, webApp);
          }
          else
          {
-            log.debug("Failed to find deployer/deployment for war: "+depName);
+            log.debug("Failed to find deployer/deployment for war: "+warURL);
          }
       }
       catch (Exception e)

Modified: branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
===================================================================
--- branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java	2009-02-02 09:30:08 UTC (rev 83765)
+++ branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java	2009-02-02 09:54:27 UTC (rev 83766)
@@ -45,7 +45,6 @@
 import javax.servlet.Servlet;
 
 import org.apache.InstanceManager;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.deployment.MappedReferenceMetaDataResolverDeployer;
 import org.jboss.deployment.dependency.ContainerDependencyMetaData;
@@ -128,7 +127,7 @@
 
    protected DependencyPolicy dependencyPolicy = new JBoss5DependencyPolicy(this);
    protected Collection<InjectionHandler<Environment>> handlers;
-   protected DeploymentUnit unit;
+   protected VFSDeploymentUnit unit;
    protected ClassLoader webLoader;
    protected WebApplication appInfo;
    protected JBossWebMetaData webDD;
@@ -184,7 +183,7 @@
        dynamicClassLoaders.add("org.apache.jasper.servlet.JasperLoader");
    }
    
-   public TomcatInjectionContainer(WebApplication appInfo, DeploymentUnit unit, org.apache.catalina.Context catalinaContext, PersistenceUnitDependencyResolver resolver)
+   public TomcatInjectionContainer(WebApplication appInfo, VFSDeploymentUnit unit, org.apache.catalina.Context catalinaContext, PersistenceUnitDependencyResolver resolver)
    {
       super(new SimpleJavaEEModule(appInfo.getName()));
       
@@ -568,10 +567,7 @@
 
    public VirtualFile getRootFile()
    {
-      if (unit instanceof VFSDeploymentUnit)
-         return ((VFSDeploymentUnit)unit).getRoot();
-      else
-         return null;
+      return unit.getRoot();
    }
 
    public String getIdentifier()

Modified: branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java
===================================================================
--- branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java	2009-02-02 09:30:08 UTC (rev 83765)
+++ branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/JBossContextConfig.java	2009-02-02 09:54:27 UTC (rev 83766)
@@ -99,7 +99,7 @@
    private static Logger log = Logger.getLogger(JBossContextConfig.class);
 
    private boolean runDestroy = false;
-
+   
    /**
     * <p>
     * Creates a new instance of {@code JBossContextConfig}.
@@ -145,7 +145,7 @@
    {
       if (context instanceof StandardContext)
       {
-         ((StandardContext)context).setReplaceWelcomeFiles(true);
+         ((StandardContext) context).setReplaceWelcomeFiles(true);
       }
 
       // Metadata complete
@@ -161,7 +161,7 @@
       else
          context.setPublicId(org.apache.catalina.startup.Constants.WebDtdPublicId_22);
 
-      // processContextParameters() provides a merged view of the context params
+      // processContextParameters() provides a merged view of the context params 
 
       // Display name
       DescriptionGroupMetaData dg = metaData.getDescriptionGroup();
@@ -459,8 +459,8 @@
          Iterator iter = keys != null ? keys.iterator() : null;
          while (iter != null && iter.hasNext())
          {
-            String key = (String)iter.next();
-            String authenticatorStr = (String)authProps.get(key);
+            String key = (String) iter.next();
+            String authenticatorStr = (String) authProps.get(key);
             Class authClass = tcl.loadClass(authenticatorStr);
             authenticators.put(key, authClass.newInstance());
          }
@@ -480,9 +480,9 @@
     */
    private Properties getAuthenticatorsFromJndi() throws NamingException
    {
-      return (Properties)new InitialContext().lookup("TomcatAuthenticators");
+      return (Properties) new InitialContext().lookup("TomcatAuthenticators");
    }
-
+   
    /**
     * Process the context parameters. Let a user application
     * override the sharedMetaData values.
@@ -491,9 +491,9 @@
    {
       JBossWebMetaData local = metaDataLocal.get();
       JBossWebMetaData shared = metaDataShared.get();
-
+      
       Map<String, String> overrideParams = new HashMap<String, String>();
-
+      
       List<ParamValueMetaData> params = local.getContextParams();
       if (params != null)
       {
@@ -507,54 +507,57 @@
       {
          for (ParamValueMetaData param : params)
          {
-            if (overrideParams.get(param.getParamName()) == null)
+            if(overrideParams.get(param.getParamName()) == null)
             {
                overrideParams.put(param.getParamName(), param.getParamValue());
             }
          }
-      }
-
-      for (String key : overrideParams.keySet())
+      }      
+      
+      for(String key : overrideParams.keySet())
       {
          context.addParameter(key, overrideParams.get(key));
       }
-
+      
    }
 
    /**
     * Process a "init" event for this Context.
     */
-   protected void init()
-   {
+   protected void init() {
+      
+      if (TomcatService.OLD_CODE) {
+         super.init();
+         return;
+      }
+      
       context.setConfigured(false);
       ok = true;
-
-      if (!context.getOverride())
-      {
-         processContextConfig("context.xml", false);
-         processContextConfig(getHostConfigPath(org.apache.catalina.startup.Constants.HostContextXml), false);
+      
+      if (!context.getOverride()) {
+          processContextConfig("context.xml", false);
+          processContextConfig(getHostConfigPath(org.apache.catalina.startup.Constants.HostContextXml), false);
       }
       // This should come from the deployment unit
       processContextConfig(context.getConfigFile(), true);
-
+      
    }
-
+   
+   
    protected void processContextConfig(String resourceName, boolean local)
    {
       ContextMetaData contextMetaData = null;
-      try
-      {
+      try {
          SchemaBinding schema = JBossXBBuilder.build(ContextMetaData.class);
          Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
          u.setSchemaValidation(false);
          u.setValidation(false);
          u.setEntityResolver(new JBossEntityResolver());
          InputStream is = null;
-         try
-         {
-            if (local && deploymentUnitLocal instanceof VFSDeploymentUnit)
+         try {
+            if (local)
             {
-               VirtualFile vf = ((VFSDeploymentUnit)deploymentUnitLocal.get()).getFile(resourceName);
+               VirtualFile vf = ((VFSDeploymentUnit) deploymentUnitLocal.get()).getFile(resourceName);
                if (vf != null)
                   is = vf.openStream();
             }
@@ -562,46 +565,34 @@
             {
                is = getClass().getClassLoader().getResourceAsStream(resourceName);
             }
-            if (is == null)
-            {
+            if (is == null) {
                return;
             }
             contextMetaData = ContextMetaData.class.cast(u.unmarshal(is, schema));
-         }
-         finally
-         {
-            if (is != null)
-            {
-               try
-               {
+         } finally {
+            if (is != null) {
+               try {
                   is.close();
-               }
-               catch (IOException e)
-               {
+               } catch (IOException e) {
                   // Ignore
                }
             }
          }
-      }
-      catch (Exception e)
-      {
+      } catch (Exception e) {
          log.error("XML error parsing: " + resourceName, e);
          ok = false;
          return;
       }
-
-      try
-      {
+      
+      try {
          if (contextMetaData != null)
          {
-
-            if (contextMetaData.getAttributes() != null)
-            {
+            
+            if (contextMetaData.getAttributes() != null) {
                Iterator<QName> names = contextMetaData.getAttributes().keySet().iterator();
-               while (names.hasNext())
-               {
+               while (names.hasNext()) {
                   QName name = names.next();
-                  String value = (String)contextMetaData.getAttributes().get(name);
+                  String value = (String) contextMetaData.getAttributes().get(name);
                   // FIXME: This should be done by XB
                   value = StringPropertyReplacer.replaceProperties(value);
                   IntrospectionUtils.setProperty(context, name.getLocalPart(), value);
@@ -611,59 +602,53 @@
             TomcatService.addLifecycleListeners(context, contextMetaData.getListeners());
 
             // Context/Realm
-            if (contextMetaData.getRealm() != null)
-            {
-               context.setRealm((org.apache.catalina.Realm)TomcatService.getInstance(contextMetaData.getRealm(), null));
+            if (contextMetaData.getRealm() != null) {
+               context.setRealm((org.apache.catalina.Realm) TomcatService.getInstance(contextMetaData.getRealm(), null));
             }
-
+            
             // Context/Valve
             TomcatService.addValves(context, contextMetaData.getValves());
-
+            
             // Context/InstanceListener
-            if (contextMetaData.getInstanceListeners() != null)
-            {
+            if (contextMetaData.getInstanceListeners() != null) {
                Iterator<String> listeners = contextMetaData.getInstanceListeners().iterator();
                while (listeners.hasNext())
                {
                   context.addInstanceListener(listeners.next());
                }
             }
-
+            
             // Context/Loader
-            if (contextMetaData.getLoader() != null)
-            {
+            if (contextMetaData.getLoader() != null) {
                // This probably won't work very well in JBoss
-               context.setLoader((org.apache.catalina.Loader)TomcatService.getInstance(contextMetaData.getLoader(), "org.apache.catalina.loader.WebappLoader"));
+               context.setLoader((org.apache.catalina.Loader) TomcatService.getInstance(contextMetaData.getLoader(), 
+                     "org.apache.catalina.loader.WebappLoader"));
             }
-
+            
             // Context/Manager
-            if (contextMetaData.getManager() != null)
-            {
-               context.setManager((org.apache.catalina.Manager)TomcatService.getInstance(contextMetaData.getManager(),
+            if (contextMetaData.getManager() != null) {
+               context.setManager((org.apache.catalina.Manager) TomcatService.getInstance(contextMetaData.getManager(), 
                      "org.apache.catalina.session.StandardManager"));
             }
-
+            
             // Context/Parameter
-            if (contextMetaData.getParameters() != null)
-            {
+            if (contextMetaData.getParameters() != null) {
                Iterator<ParameterMetaData> parameterMetaDatas = contextMetaData.getParameters().iterator();
                while (parameterMetaDatas.hasNext())
                {
                   ParameterMetaData parameterMetaData = parameterMetaDatas.next();
-                  context.addApplicationParameter((org.apache.catalina.deploy.ApplicationParameter)TomcatService.getInstance(parameterMetaData, null));
+                  context.addApplicationParameter((org.apache.catalina.deploy.ApplicationParameter) TomcatService.getInstance(parameterMetaData, null));
                }
             }
 
             // Context/Resources
-            if (contextMetaData.getResources() != null)
-            {
-               context.setResources((javax.naming.directory.DirContext)TomcatService.getInstance(contextMetaData.getResources(),
+            if (contextMetaData.getResources() != null) {
+               context.setResources((javax.naming.directory.DirContext) TomcatService.getInstance(contextMetaData.getResources(), 
                      "org.apache.naming.resources.FileDirContext"));
             }
-
+            
             // Context/SessionCookie
-            if (contextMetaData.getSessionCookie() != null)
-            {
+            if (contextMetaData.getSessionCookie() != null) {
                SessionCookie sessionCookie = new SessionCookie();
                sessionCookie.setComment(contextMetaData.getSessionCookie().getComment());
                sessionCookie.setDomain(contextMetaData.getSessionCookie().getDomain());
@@ -672,7 +657,7 @@
                sessionCookie.setSecure(contextMetaData.getSessionCookie().getSecure());
                context.setSessionCookie(sessionCookie);
             }
-
+            
          }
       }
       catch (Exception e)
@@ -680,15 +665,13 @@
          log.error("Error processing: " + resourceName, e);
          ok = false;
       }
-
+      
    }
-
-   protected void destroy()
-   {
-      if (runDestroy)
-      {
-         super.destroy();
-      }
+   
+   protected void destroy() {
+	   if (runDestroy) {
+		   super.destroy();
+	   }
    }
-
+   
 }

Modified: branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java	2009-02-02 09:30:08 UTC (rev 83765)
+++ branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java	2009-02-02 09:54:27 UTC (rev 83766)
@@ -22,7 +22,9 @@
 package org.jboss.web.tomcat.service.deployers;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLDecoder;
@@ -38,7 +40,6 @@
 
 import javax.management.Attribute;
 import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -50,7 +51,6 @@
 import org.apache.catalina.core.StandardContext;
 import org.apache.tomcat.util.modeler.Registry;
 import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.web.jboss.JBossWebMetaData;
@@ -89,7 +89,7 @@
 
    private DeployerConfig config;
 
-   private final String[] javaVMs = { " jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost" };
+   private final String[] javaVMs = {" jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost"};
 
    private final String serverName = "jboss";
 
@@ -112,7 +112,7 @@
    @Override
    public void init(Object containerConfig) throws Exception
    {
-      this.config = (DeployerConfig)containerConfig;
+      this.config = (DeployerConfig) containerConfig;
       super.setJava2ClassLoadingCompliance(config.isJava2ClassLoadingCompliance());
       super.setUnpackWars(config.isUnpackWars());
       super.setLenientEjbLink(config.isLenientEjbLink());
@@ -120,11 +120,10 @@
    }
 
    @Override
-   protected void performDeploy(WebApplication webApp, String warUrlStr) throws Exception
+   protected void performDeploy(WebApplication webApp, String warUrl) throws Exception
    {
       // Decode the URL as tomcat can't deal with paths with escape chars
-      warUrlStr = URLDecoder.decode(warUrlStr, "UTF-8");
-
+      warUrl = URLDecoder.decode(warUrl, "UTF-8");
       webApp.setDomain(config.getCatalinaDomain());
       JBossWebMetaData metaData = webApp.getMetaData();
       String hostName = null;
@@ -144,20 +143,18 @@
             hostName = hostNames.next().toString();
          }
       }
-
-      performDeployInternal(webApp, hostName, warUrlStr);
+      performDeployInternal(hostName, webApp, warUrl);
       while (hostNames.hasNext())
       {
          String additionalHostName = hostNames.next().toString();
-         performDeployInternal(webApp, additionalHostName, warUrlStr);
+         performDeployInternal(additionalHostName, webApp, warUrl);
       }
    }
 
-   protected void performDeployInternal(WebApplication webApp, String hostName, String warUrlStr) throws Exception
+   protected void performDeployInternal(String hostName, WebApplication webApp, String warUrl) throws Exception
    {
+
       JBossWebMetaData metaData = webApp.getMetaData();
-      DeploymentUnit unit = webApp.getDeploymentUnit();
-      
       String ctxPath = metaData.getContextRoot();
       if (ctxPath.equals("/") || ctxPath.equals("/ROOT") || ctxPath.equals(""))
       {
@@ -166,49 +163,105 @@
          metaData.setContextRoot(ctxPath);
       }
 
-      log.info("deploy, ctxPath=" + ctxPath);
+      log.info("deploy, ctxPath=" + ctxPath + ", vfsUrl=" + webApp.getDeploymentUnit().getFile("").getPathName());
 
+      URL url = new URL(warUrl);
+
       ClassLoader loader = Thread.currentThread().getContextClassLoader();
       metaData.setContextLoader(loader);
 
-      StandardContext context = (StandardContext)Class.forName(config.getContextClassName()).newInstance();
-      injectionContainer = new TomcatInjectionContainer(webApp, unit, context, getPersistenceUnitDependencyResolver());
+      StandardContext context = (StandardContext) Class.forName(config.getContextClassName()).newInstance();
 
-      Loader webLoader = unit.getAttachment(Loader.class);
+      injectionContainer = new TomcatInjectionContainer(webApp, webApp.getDeploymentUnit(), context,
+            getPersistenceUnitDependencyResolver());
+
+      Loader webLoader = webApp.getDeploymentUnit().getAttachment(Loader.class);
       if (webLoader == null)
-         webLoader = getWebLoader(unit, metaData, loader);
+         webLoader = getWebLoader(webApp.getDeploymentUnit(), metaData, loader, url);
 
-      URL warUrl = new URL(warUrlStr);
-
-      webApp.setName(ctxPath);
+      webApp.setName(url.getPath());
       webApp.setClassLoader(loader);
-      webApp.setURL(warUrl);
+      webApp.setURL(url);
 
-      ObjectName objectName = getObjectName(hostName, ctxPath);
+      String objectNameS = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//"
+            + ((hostName == null) ? "localhost" : hostName) + ctxPath + ",J2EEApplication=none,J2EEServer=none";
+
+      ObjectName objectName = new ObjectName(objectNameS);
+
       if (Registry.getRegistry(null, null).getMBeanServer().isRegistered(objectName))
-         throw new DeploymentException("Web mapping already exists for: " + objectName);
+         throw new DeploymentException("Web mapping already exists for deployment URL " + warUrl);
 
       Registry.getRegistry(null, null).registerComponent(context, objectName, config.getContextClassName());
 
-      context.setConfigFile(CONTEXT_CONFIG_FILE);
+      if (TomcatService.OLD_CODE)
+      {
+         String ctxConfig = null;
+         File warFile = new File(url.getFile());
+         if (warFile.isDirectory() == false)
+         {
+            // Using VFS access
+            VFSDirContext resources = new VFSDirContext();
+            resources.setVirtualFile(webApp.getDeploymentUnit().getFile(""));
+            context.setResources(resources);
+            // Find META-INF/context.xml
+            VirtualFile file = webApp.getDeploymentUnit().getFile(CONTEXT_CONFIG_FILE);
+            if (file != null)
+            {
+               // Copy the META-INF/context.xml from the VFS to the temp folder
+               InputStream is = file.openStream();
+               FileOutputStream fos = null;
+               try
+               {
+                  byte[] buffer = new byte[512];
+                  int bytes;
+                  // FIXME: use JBoss'temp folder instead
+                  File tempFile = File.createTempFile("context-", ".xml");
+                  tempFile.deleteOnExit();
+                  fos = new FileOutputStream(tempFile);
+                  while ((bytes = is.read(buffer)) > 0)
+                  {
+                     fos.write(buffer, 0, bytes);
+                  }
+                  ctxConfig = tempFile.getAbsolutePath();
+               }
+               finally
+               {
+                  is.close();
+                  if (fos != null)
+                  {
+                     fos.close();
+                  }
+               }
+            }
+         }
+         else
+         {
+            // Using direct filesystem access: no operation needed
+            // Find META-INF/context.xml
+            File webDD = new File(warFile, CONTEXT_CONFIG_FILE);
+            if (webDD.exists() == true)
+            {
+               ctxConfig = webDD.getAbsolutePath();
+            }
+         }
+
+         context.setConfigFile(ctxConfig);
+      }
+      else
+      {
+         context.setConfigFile(CONTEXT_CONFIG_FILE);
+      }
       context.setInstanceManager(injectionContainer);
+      context.setDocBase(url.getFile());
       context.setDefaultContextXml("context.xml");
       context.setDefaultWebXml("conf/web.xml");
       context.setPublicId(metaData.getPublicID());
-
-      String docbase = unit.getAttachment("org.jboss.web.explicitDocBase", String.class);
-      if (docbase == null)
-         docbase = warUrl.getFile();
-      
-      context.setDocBase(docbase);
-
       // If there is an alt-dd set it
       if (metaData.getAlternativeDD() != null)
       {
          log.debug("Setting altDDName to: " + metaData.getAlternativeDD());
          context.setAltDDName(metaData.getAlternativeDD());
       }
-
       context.setJavaVMs(javaVMs);
       context.setServer(serverName);
       context.setSaveConfig(false);
@@ -268,30 +321,31 @@
       // Set the session cookies flag according to metadata
       switch (metaData.getSessionCookies())
       {
-         case JBossWebMetaData.SESSION_COOKIES_ENABLED:
+         case JBossWebMetaData.SESSION_COOKIES_ENABLED :
             context.setCookies(true);
             log.debug("Enabling session cookies");
             break;
-         case JBossWebMetaData.SESSION_COOKIES_DISABLED:
+         case JBossWebMetaData.SESSION_COOKIES_DISABLED :
             context.setCookies(false);
             log.debug("Disabling session cookies");
             break;
-         default:
+         default :
             log.debug("Using session cookies default setting");
       }
 
       String metaDataSecurityDomain = metaData.getSecurityDomain();
       if (metaDataSecurityDomain != null)
          metaDataSecurityDomain = metaDataSecurityDomain.trim();
-
+      
       // Add a valve to establish security context
-      SecurityContextEstablishmentValve scevalve = new SecurityContextEstablishmentValve(metaDataSecurityDomain, SecurityUtil.unprefixSecurityDomain(config
-            .getDefaultSecurityDomain()), SecurityActions.loadClass(config.getSecurityContextClassName()), getSecurityManagement());
+      SecurityContextEstablishmentValve scevalve = new SecurityContextEstablishmentValve(metaDataSecurityDomain,
+            SecurityUtil.unprefixSecurityDomain(config.getDefaultSecurityDomain()), 
+            SecurityActions.loadClass(config.getSecurityContextClassName()), getSecurityManagement());
       context.addValve(scevalve);
 
       // Add a valve to estalish the JACC context before authorization valves
       Certificate[] certs = null;
-      CodeSource cs = new CodeSource(warUrl, certs);
+      CodeSource cs = new CodeSource(url, certs);
       JaccContextValve jaccValve = new JaccContextValve(metaData, cs);
       context.addValve(jaccValve);
 
@@ -316,7 +370,7 @@
       catch (Exception e)
       {
          context.destroy();
-         DeploymentException.rethrowAsDeploymentException("URL " + warUrlStr + " deployment failed", e);
+         DeploymentException.rethrowAsDeploymentException("URL " + warUrl + " deployment failed", e);
       }
       finally
       {
@@ -331,7 +385,7 @@
       if (context.getState() != 1)
       {
          context.destroy();
-         throw new DeploymentException("URL " + warUrlStr + " deployment failed");
+         throw new DeploymentException("URL " + warUrl + " deployment failed");
       }
 
       // Clustering
@@ -344,7 +398,7 @@
             AbstractJBossManager manager = null;
             String managerClassName = config.getManagerClass();
             Class managerClass = Thread.currentThread().getContextClassLoader().loadClass(managerClassName);
-            manager = (AbstractJBossManager)managerClass.newInstance();
+            manager = (AbstractJBossManager) managerClass.newInstance();
             String name = "//" + ((hostName == null) ? "localhost" : hostName) + ctxPath;
             manager.init(name, metaData);
 
@@ -355,7 +409,8 @@
          catch (ClusteringNotSupportedException e)
          {
             // JBAS-3513 Just log a WARN, not an ERROR
-            log.warn("Failed to setup clustering, clustering disabled. ClusteringNotSupportedException: " + e.getMessage());
+            log.warn("Failed to setup clustering, clustering disabled. ClusteringNotSupportedException: "
+                  + e.getMessage());
          }
          catch (NoClassDefFoundError ncdf)
          {
@@ -376,7 +431,7 @@
        */
       SecurityAssociationValve valve = new SecurityAssociationValve(metaData, config.getSecurityManagerService());
       valve.setSubjectAttributeName(config.getSubjectAttributeName());
-      server.invoke(objectName, "addValve", new Object[] { valve }, new String[] { "org.apache.catalina.Valve" });
+      server.invoke(objectName, "addValve", new Object[]{valve}, new String[]{"org.apache.catalina.Valve"});
 
       /*
        * TODO: Retrieve the state, and throw an exception in case of a failure Integer state = (Integer)
@@ -406,7 +461,7 @@
 
       protected JBossWebMetaData metaData;
 
-      protected DeploymentUnit unit;
+      protected VFSDeploymentUnit unit;
 
       public EncListener(ClassLoader loader, Loader webLoader, WebApplication webApp)
       {
@@ -443,13 +498,13 @@
                currentThread.setContextClassLoader(webLoader.getClassLoader());
                metaData.setENCLoader(webLoader.getClassLoader());
                InitialContext iniCtx = new InitialContext();
-               Context envCtx = (Context)iniCtx.lookup("java:comp");
+               Context envCtx = (Context) iniCtx.lookup("java:comp");
                // Add ORB/UserTransaction
                ORB orb = null;
                try
                {
                   ObjectName ORB_NAME = new ObjectName("jboss:service=CorbaORB");
-                  orb = (ORB)server.getAttribute(ORB_NAME, "ORB");
+                  orb = (ORB) server.getAttribute(ORB_NAME, "ORB");
                   // Bind the orb
                   if (orb != null)
                   {
@@ -463,8 +518,10 @@
                }
 
                // JTA links
-               envCtx.bind("TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry"));
-               log.debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry");
+               envCtx
+                     .bind("TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry"));
+               log
+                     .debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry");
                envCtx.bind("UserTransaction", new LinkRef("UserTransaction"));
                log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction");
                envCtx = envCtx.createSubcontext("env");
@@ -497,7 +554,8 @@
 
    }
 
-   public Loader getWebLoader(DeploymentUnit unit, JBossWebMetaData metaData, ClassLoader loader) throws MalformedURLException
+   public Loader getWebLoader(VFSDeploymentUnit unit, JBossWebMetaData metaData, ClassLoader loader, URL url)
+         throws MalformedURLException
    {
       Loader webLoader = null;
 
@@ -506,12 +564,12 @@
        * else scoped class loading does not see the war level overrides. The call to setWarURL adds these paths to the
        * deployment UCL.
        */
-      ArrayList<URL> classpath = (ArrayList<URL>)unit.getAttachment("org.jboss.web.expandedWarClasspath");
-      if (classpath == null && unit instanceof VFSDeploymentUnit)
+      ArrayList<URL> classpath = (ArrayList<URL>) unit.getAttachment("org.jboss.web.expandedWarClasspath");
+      if (classpath == null)
       {
          try
          {
-            VirtualFile classes = ((VFSDeploymentUnit)unit).getFile("WEB-INF/classes");
+            VirtualFile classes = unit.getFile("WEB-INF/classes");
             // Tomcat can't handle the vfs urls yet
             URL vfsURL = classes.toURL();
             String vfsurl = vfsURL.toString();
@@ -529,8 +587,14 @@
       WebCtxLoader jbossLoader = new WebCtxLoader(loader, injectionContainer);
       if (classpath != null)
          jbossLoader.setClasspath(classpath);
-
       webLoader = jbossLoader;
+      /*
+       * if (classLoading != null && classLoading.isJava2ClassLoadingCompliance()) { WebCtxLoader jbossLoader = new
+       * WebCtxLoader(loader, injectionContainer); if (classpath != null) jbossLoader.setClasspath(classpath); webLoader =
+       * jbossLoader; } else { String[] pkgs = config.getFilteredPackages(); WebAppLoader jbossLoader = new
+       * WebAppLoader(loader, pkgs, injectionContainer); jbossLoader.setDelegate(getJava2ClassLoadingCompliance()); if
+       * (classpath != null) jbossLoader.setClasspath(classpath); webLoader = jbossLoader; }
+       */
       return webLoader;
    }
 
@@ -544,17 +608,18 @@
     * undeployment steps.
     */
    @Override
-   protected void performUndeploy(WebApplication webApp, String warUrl) throws Exception
+   protected void performUndeploy(WebApplication warInfo, String warUrl) throws Exception
    {
-      if (webApp == null)
+      if (warInfo == null)
       {
          log.debug("performUndeploy, no WebApplication found for URL " + warUrl);
          return;
       }
 
-      log.info("undeploy, ctxPath=" + webApp.getMetaData().getContextRoot());
+      log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot() + ", vfsUrl="
+            + warInfo.getDeploymentUnit().getFile("").getPathName());
 
-      JBossWebMetaData metaData = webApp.getMetaData();
+      JBossWebMetaData metaData = warInfo.getMetaData();
       String hostName = null;
       // Get any jboss-web/virtual-hosts
       List<String> vhostNames = metaData.getVirtualHosts();
@@ -572,41 +637,37 @@
             hostName = hostNames.next().toString();
          }
       }
-      performUndeployInternal(webApp, hostName, warUrl);
+      performUndeployInternal(hostName, warUrl, warInfo);
       while (hostNames.hasNext())
       {
          String additionalHostName = hostNames.next().toString();
-         performUndeployInternal(webApp, additionalHostName, warUrl);
+         performUndeployInternal(additionalHostName, warUrl, warInfo);
       }
 
    }
 
-   protected void performUndeployInternal(WebApplication webApp, String hostName, String warUrl) throws Exception
+   protected void performUndeployInternal(String hostName, String warUrl, WebApplication warInfo) throws Exception
    {
-      JBossWebMetaData metaData = webApp.getMetaData();
+
+      JBossWebMetaData metaData = warInfo.getMetaData();
       String ctxPath = metaData.getContextRoot();
 
-      ObjectName objectName = getObjectName(hostName, ctxPath);
-
       // TODO: Need to remove the dependency on MBeanServer
       MBeanServer server = MBeanServerLocator.locateJBoss();
+      // If the server is gone, all apps were stopped already
+      if (server == null)
+         return;
 
-      // If the server is gone, all apps were stopped already
-      if (server != null)
+      ObjectName objectName = new ObjectName(config.getCatalinaDomain() + ":j2eeType=WebModule,name=//"
+            + ((hostName == null) ? "localhost" : hostName) + ctxPath + ",J2EEApplication=none,J2EEServer=none");
+
+      if (server.isRegistered(objectName))
       {
          // Contexts should be stopped by the host already
-         if (server.isRegistered(objectName))
-            server.invoke(objectName, "destroy", new Object[] {}, new String[] {});
+         server.invoke(objectName, "destroy", new Object[]{}, new String[]{});
       }
    }
 
-   private ObjectName getObjectName(String hostName, String ctxPath) throws MalformedObjectNameException
-   {
-      hostName = (hostName == null ? "localhost" : hostName);
-      String onamestr = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + hostName + ctxPath + ",J2EEApplication=none,J2EEServer=none";
-      return new ObjectName(onamestr);
-   }
-
    /**
     * Resolve the input virtual host names to the names of the configured Hosts
     * 
@@ -625,12 +686,12 @@
          Iterator iter = hosts.iterator();
          while (iter.hasNext())
          {
-            ObjectName host = (ObjectName)iter.next();
+            ObjectName host = (ObjectName) iter.next();
             String name = host.getKeyProperty("host");
             if (name != null)
             {
                vhostToHostNames.put(name, name);
-               String[] aliases = (String[])server.invoke(host, "findAliases", null, null);
+               String[] aliases = (String[]) server.invoke(host, "findAliases", null, null);
                int count = aliases != null ? aliases.length : 0;
                for (int n = 0; n < count; n++)
                {
@@ -646,7 +707,7 @@
       {
          for (String vhost : vhostNames)
          {
-            String host = (String)vhostToHostNames.get(vhost);
+            String host = (String) vhostToHostNames.get(vhost);
             if (host == null)
             {
                log.warn("Failed to map vhost: " + vhost);
@@ -673,9 +734,9 @@
       Iterator iter = engines.iterator();
       while (iter.hasNext())
       {
-         ObjectName engine = (ObjectName)iter.next();
+         ObjectName engine = (ObjectName) iter.next();
 
-         String defaultHost = (String)server.getAttribute(engine, "defaultHost");
+         String defaultHost = (String) server.getAttribute(engine, "defaultHost");
          if (defaultHost != null)
          {
             defaultHosts.add(defaultHost);

Modified: branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatService.java
===================================================================
--- branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatService.java	2009-02-02 09:30:08 UTC (rev 83765)
+++ branches/tdiesler/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatService.java	2009-02-02 09:54:27 UTC (rev 83766)
@@ -29,6 +29,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import javax.management.Attribute;
 import javax.management.MBeanServer;
 import javax.management.Notification;
 import javax.management.NotificationListener;
@@ -84,10 +85,10 @@
  */
 public class TomcatService extends ServiceMBeanSupport implements NotificationListener, TomcatServiceMBean
 {
-
+   
    /** The associated Tomcat deployer * */
    private TomcatDeployer tomcatDeployer;
-
+   
    // Use a flag because isInShutdown doesn't appear to be correct
    private boolean connectorsRunning = false;
 
@@ -103,6 +104,8 @@
       this.tomcatDeployer = tomcatDeployer;
    }
 
+   public static boolean OLD_CODE = false;
+   
    // In our lifecycle, we invoke the webserver lifecycle-related operations
    // in the TomcatDeployer
 
@@ -119,184 +122,194 @@
 
       log.debug("Starting tomcat deployer");
       MBeanServer server = super.getServer();
-      SecurityActions.setSystemProperty("catalina.ext.dirs", (SecurityActions.getSystemProperty("jboss.server.home.dir", null) + File.separator + "lib"));
+      SecurityActions.setSystemProperty("catalina.ext.dirs", 
+            (SecurityActions.getSystemProperty("jboss.server.home.dir", null) + File.separator + "lib"));
 
       String objectNameS = tomcatDeployer.getDomain() + ":type=server";
       ObjectName objectName = new ObjectName(objectNameS);
 
-      // Parse main server.xml
-      // FIXME: this could be done somewhere else
-      SchemaBinding schema = JBossXBBuilder.build(ServerMetaData.class);
-      Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
-      u.setSchemaValidation(false);
-      u.setValidation(false);
-      u.setEntityResolver(new JBossEntityResolver());
-      InputStream is = null;
-      ServerMetaData serverMetaData = null;
-      try
-      {
-         File configFile = new File(tomcatDeployer.getConfigFile());
-         if (configFile.exists())
-         {
-            is = new FileInputStream(configFile);
-         }
-         else
-         {
-            is = getClass().getClassLoader().getResourceAsStream(tomcatDeployer.getConfigFile());
-         }
-         if (is == null)
-         {
-            log.error("Could not read configured server.xml (will try default): " + tomcatDeployer.getConfigFile());
-            is = getClass().getClassLoader().getResourceAsStream("server.xml");
-         }
-         serverMetaData = ServerMetaData.class.cast(u.unmarshal(is, schema));
-      }
-      finally
-      {
-         if (is != null)
-         {
-            try
-            {
-               is.close();
-            }
-            catch (IOException e)
-            {
-               // Ignore
-            }
-         }
-      }
+      if (OLD_CODE) {
 
-      // FIXME: could try to do stuff with EngineConfig and HostConfig, although neither
-      // should be useful in JBoss
+         // Set the modeler Registry MBeanServer to the that of the tomcat service
+         Registry.getRegistry().setMBeanServer(server);
 
-      // Create the Catalina instance
-      Catalina catalina = new Catalina();
-      catalina.setCatalinaHome(System.getProperty("jboss.server.home.dir"));
-      catalina.setUseNaming(false);
-      catalina.setUseShutdownHook(false);
-      catalina.setAwait(false);
-      catalina.setRedirectStreams(false);
+         Registry.getRegistry().registerComponent(Class.forName("org.apache.catalina.startup.Catalina").newInstance(),
+               objectName, "org.apache.catalina.startup.Catalina");
 
-      // Set the modeler Registry MBeanServer to the that of the tomcat service
-      Registry.getRegistry(null, null).setMBeanServer(server);
-      // Register the Catalina instance
-      Registry.getRegistry(null, null).registerComponent(catalina, objectName, "org.apache.catalina.startup.Catalina");
+         server.setAttribute(objectName, new Attribute("catalinaHome", System.getProperty("jboss.server.home.dir")));
+         server.setAttribute(objectName, new Attribute("configFile", tomcatDeployer.getConfigFile()));
+         server.setAttribute(objectName, new Attribute("useNaming", new Boolean(false)));
+         server.setAttribute(objectName, new Attribute("useShutdownHook", new Boolean(false)));
+         server.setAttribute(objectName, new Attribute("await", new Boolean(false)));
+         server.setAttribute(objectName, new Attribute("redirectStreams", new Boolean(false)));
 
-      // Use the server.xml metadata to create a Server instance and assign it to the Catalina instance
-
-      // Server
-      org.apache.catalina.Server catalinaServer = (org.apache.catalina.Server)getInstance(serverMetaData, "org.apache.catalina.core.StandardServer");
-      addLifecycleListeners(catalinaServer, serverMetaData.getListeners());
-
-      // Server/Service
-      if (serverMetaData.getServices() == null)
-      {
-         throw new IllegalArgumentException("No services");
-      }
-      Iterator<ServiceMetaData> serviceMetaDatas = serverMetaData.getServices().iterator();
-      while (serviceMetaDatas.hasNext())
-      {
-         ServiceMetaData serviceMetaData = serviceMetaDatas.next();
-         org.apache.catalina.Service service = (org.apache.catalina.Service)getInstance(serviceMetaData, "org.apache.catalina.core.StandardService");
-         addLifecycleListeners(service, serviceMetaData.getListeners());
-         service.setName(serviceMetaData.getName());
-         service.setServer(catalinaServer);
-         catalinaServer.addService(service);
-
-         // Server/Service/Executor
-         // FIXME
-
-         // Server/Service/Connector
-         if (serviceMetaData.getConnectors() != null)
-         {
-            Iterator<ConnectorMetaData> connectorMetaDatas = serviceMetaData.getConnectors().iterator();
-            while (connectorMetaDatas.hasNext())
+      } else {
+      
+         // Parse main server.xml
+         // FIXME: this could be done somewhere else
+         SchemaBinding schema = JBossXBBuilder.build(ServerMetaData.class);
+         Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
+         u.setSchemaValidation(false);
+         u.setValidation(false);
+         u.setEntityResolver(new JBossEntityResolver());
+         InputStream is = null;
+         ServerMetaData serverMetaData = null;
+         try {
+            File configFile = new File(tomcatDeployer.getConfigFile());
+            if (configFile.exists())
             {
-               ConnectorMetaData connectorMetaData = connectorMetaDatas.next();
-               Connector connector = new Connector(connectorMetaData.getProtocol());
-               if (connectorMetaData.getAttributes() != null)
-               {
-                  Iterator<QName> names = connectorMetaData.getAttributes().keySet().iterator();
-                  while (names.hasNext())
-                  {
-                     QName name = names.next();
-                     String value = (String)connectorMetaData.getAttributes().get(name);
-                     // FIXME: This should be done by XB
-                     value = StringPropertyReplacer.replaceProperties(value);
-                     IntrospectionUtils.setProperty(connector, name.getLocalPart(), value);
-                  }
+               is = new FileInputStream(configFile);
+            }
+            else
+            {
+               is = getClass().getClassLoader().getResourceAsStream(tomcatDeployer.getConfigFile());
+            }
+            if (is == null) {
+               log.error("Could not read configured server.xml (will try default): " + tomcatDeployer.getConfigFile());
+               is = getClass().getClassLoader().getResourceAsStream("server.xml");
+            }
+            serverMetaData = ServerMetaData.class.cast(u.unmarshal(is, schema));
+         } finally {
+            if (is != null) {
+               try {
+                  is.close();
+               } catch (IOException e) {
+                  // Ignore
                }
-               service.addConnector(connector);
             }
          }
-
-         // Server/Service/Engine
-         EngineMetaData engineMetaData = serviceMetaData.getEngine();
-         org.apache.catalina.Engine engine = (org.apache.catalina.Engine)getInstance(engineMetaData, "org.apache.catalina.core.StandardEngine");
-         addLifecycleListeners(engine, engineMetaData.getListeners());
-         engine.setName(engineMetaData.getName());
-         // FIXME: This should be done by XB
-         if (engineMetaData.getJvmRoute() != null)
+         
+         // FIXME: could try to do stuff with EngineConfig and HostConfig, although neither
+         //        should be useful in JBoss
+         
+         // Create the Catalina instance
+         Catalina catalina = new Catalina();
+         catalina.setCatalinaHome(System.getProperty("jboss.server.home.dir"));
+         catalina.setUseNaming(false);
+         catalina.setUseShutdownHook(false);
+         catalina.setAwait(false);
+         catalina.setRedirectStreams(false);
+         
+         // Set the modeler Registry MBeanServer to the that of the tomcat service
+         Registry.getRegistry(null, null).setMBeanServer(server);
+         // Register the Catalina instance
+         Registry.getRegistry(null, null).registerComponent(catalina, objectName, "org.apache.catalina.startup.Catalina");
+         
+         // Use the server.xml metadata to create a Server instance and assign it to the Catalina instance
+         
+         // Server
+         org.apache.catalina.Server catalinaServer = 
+            (org.apache.catalina.Server) getInstance(serverMetaData, "org.apache.catalina.core.StandardServer");
+         addLifecycleListeners(catalinaServer, serverMetaData.getListeners());
+         
+         // Server/Service
+         if (serverMetaData.getServices() == null)
          {
-            engine.setJvmRoute(StringPropertyReplacer.replaceProperties(engineMetaData.getJvmRoute()));
+            throw new IllegalArgumentException("No services");
          }
-         // engine.setJvmRoute(engineMetaData.getJvmRoute());
-         engine.setDefaultHost(engineMetaData.getDefaultHost());
-         service.setContainer(engine);
-
-         // Server/Service/Engine/Realm
-         if (engineMetaData.getRealm() != null)
+         Iterator<ServiceMetaData> serviceMetaDatas = serverMetaData.getServices().iterator();
+         while (serviceMetaDatas.hasNext())
          {
-            engine.setRealm((org.apache.catalina.Realm)getInstance(engineMetaData.getRealm(), null));
-         }
-
-         // Server/Service/Engine/Valve
-         addValves(engine, engineMetaData.getValves());
-
-         // Server/Service/Engine/Host
-         if (engineMetaData.getHosts() != null)
-         {
-            Iterator<HostMetaData> hostMetaDatas = engineMetaData.getHosts().iterator();
-            while (hostMetaDatas.hasNext())
+            ServiceMetaData serviceMetaData = serviceMetaDatas.next();
+            org.apache.catalina.Service service = 
+               (org.apache.catalina.Service) getInstance(serviceMetaData, "org.apache.catalina.core.StandardService");
+            addLifecycleListeners(service, serviceMetaData.getListeners());
+            service.setName(serviceMetaData.getName());
+            service.setServer(catalinaServer);
+            catalinaServer.addService(service);
+            
+            // Server/Service/Executor
+            // FIXME
+            
+            // Server/Service/Connector
+            if (serviceMetaData.getConnectors() != null)
             {
-               HostMetaData hostMetaData = hostMetaDatas.next();
-               org.apache.catalina.Host host = (org.apache.catalina.Host)getInstance(hostMetaData, "org.apache.catalina.core.StandardHost");
-               addLifecycleListeners(host, hostMetaData.getListeners());
-               host.setName(hostMetaData.getName());
-               // FIXME: not really needed, and could hurt extensibility; probably needed until JBW GA with a fix
-               host.setConfigClass("org.jboss.web.tomcat.service.deployers.JBossContextConfig");
-               engine.addChild(host);
-
-               // Server/Service/Engine/Host/Realm
-               if (hostMetaData.getRealm() != null)
+               Iterator<ConnectorMetaData> connectorMetaDatas = serviceMetaData.getConnectors().iterator();
+               while (connectorMetaDatas.hasNext())
                {
-                  host.setRealm((org.apache.catalina.Realm)getInstance(hostMetaData.getRealm(), null));
+                  ConnectorMetaData connectorMetaData = connectorMetaDatas.next();
+                  Connector connector = new Connector(connectorMetaData.getProtocol());
+                  if (connectorMetaData.getAttributes() != null)
+                  {
+                     Iterator<QName> names = connectorMetaData.getAttributes().keySet().iterator();
+                     while (names.hasNext())
+                     {
+                        QName name = names.next();
+                        String value = (String) connectorMetaData.getAttributes().get(name);
+                        // FIXME: This should be done by XB
+                        value = StringPropertyReplacer.replaceProperties(value);
+                        IntrospectionUtils.setProperty(connector, name.getLocalPart(), value);
+                     }
+                  }
+                  service.addConnector(connector);
                }
-
-               // Server/Service/Engine/Host/Valve
-               addValves(host, hostMetaData.getValves());
-
-               // Server/Service/Engine/Host/Alias
-               if (hostMetaData.getAliases() != null)
+            }
+            
+            // Server/Service/Engine
+            EngineMetaData engineMetaData = serviceMetaData.getEngine();
+            org.apache.catalina.Engine engine = 
+               (org.apache.catalina.Engine) getInstance(engineMetaData, "org.apache.catalina.core.StandardEngine");
+            addLifecycleListeners(engine, engineMetaData.getListeners());
+            engine.setName(engineMetaData.getName());
+            // FIXME: This should be done by XB
+            if (engineMetaData.getJvmRoute() != null) {
+               engine.setJvmRoute(StringPropertyReplacer.replaceProperties(engineMetaData.getJvmRoute()));
+            }
+            //engine.setJvmRoute(engineMetaData.getJvmRoute());
+            engine.setDefaultHost(engineMetaData.getDefaultHost());
+            service.setContainer(engine);
+            
+            // Server/Service/Engine/Realm
+            if (engineMetaData.getRealm() != null) {
+               engine.setRealm((org.apache.catalina.Realm) getInstance(engineMetaData.getRealm(), null));
+            }
+            
+            // Server/Service/Engine/Valve
+            addValves(engine, engineMetaData.getValves());
+            
+            // Server/Service/Engine/Host
+            if (engineMetaData.getHosts() != null)
+            {
+               Iterator<HostMetaData> hostMetaDatas = engineMetaData.getHosts().iterator();
+               while (hostMetaDatas.hasNext())
                {
-                  Iterator<String> aliases = hostMetaData.getAliases().iterator();
-                  while (aliases.hasNext())
-                  {
-                     host.addAlias(aliases.next());
+                  HostMetaData hostMetaData = hostMetaDatas.next();
+                  org.apache.catalina.Host host =
+                     (org.apache.catalina.Host) getInstance(hostMetaData, "org.apache.catalina.core.StandardHost");
+                  addLifecycleListeners(host, hostMetaData.getListeners());
+                  host.setName(hostMetaData.getName());
+                  // FIXME: not really needed, and could hurt extensibility; probably needed until JBW GA with a fix
+                  host.setConfigClass("org.jboss.web.tomcat.service.deployers.JBossContextConfig");
+                  engine.addChild(host);
+                  
+                  // Server/Service/Engine/Host/Realm
+                  if (hostMetaData.getRealm() != null) {
+                     host.setRealm((org.apache.catalina.Realm) getInstance(hostMetaData.getRealm(), null));
                   }
+                  
+                  // Server/Service/Engine/Host/Valve
+                  addValves(host, hostMetaData.getValves());
+                  
+                  // Server/Service/Engine/Host/Alias
+                  if (hostMetaData.getAliases() != null) {
+                     Iterator<String> aliases = hostMetaData.getAliases().iterator();
+                     while (aliases.hasNext()) {
+                        host.addAlias(aliases.next());
+                     }
+                  }
+                  
                }
-
             }
+            
          }
-
+         
+         // Set the resulting Server to the Catalina instance
+         catalina.setServer(catalinaServer);
       }
-
-      // Set the resulting Server to the Catalina instance
-      catalina.setServer(catalinaServer);
-
+      
       // Start Tomcat
-      server.invoke(objectName, "create", new Object[] {}, new String[] {});
-      server.invoke(objectName, "start", new Object[] {}, new String[] {});
+      server.invoke(objectName, "create", new Object[]{}, new String[]{});
+      server.invoke(objectName, "start", new Object[]{}, new String[]{});
 
       // Set up the authenticators in JNDI such that they can be configured for web apps
       InitialContext ic = new InitialContext();
@@ -328,7 +341,7 @@
       // we'll never receive Server.START_NOTIFICATION_TYPE, so check
       // with the Server and start the connectors immediately, if this is the case.
       // Otherwise register to receive the server start-up notification.
-      Boolean started = (Boolean)server.getAttribute(ServerImplMBean.OBJECT_NAME, "Started");
+      Boolean started = (Boolean) server.getAttribute(ServerImplMBean.OBJECT_NAME, "Started");
       if (started.booleanValue() == true)
       {
          log.debug("Server '" + ServerImplMBean.OBJECT_NAME + "' already started, starting connectors now");
@@ -351,22 +364,18 @@
    protected static Object getInstance(AnyXmlMetaData metaData, String defaultClassName) throws Exception
    {
       String className = metaData.getClassName();
-      if (className == null)
-      {
+      if (className == null) {
          className = defaultClassName;
       }
-      if (className == null)
-      {
+      if (className == null) {
          throw new IllegalArgumentException("No className specified for element");
       }
       Object instance = TomcatService.class.getClassLoader().loadClass(className).newInstance();
-      if (metaData.getAttributes() != null)
-      {
+      if (metaData.getAttributes() != null) {
          Iterator<QName> names = metaData.getAttributes().keySet().iterator();
-         while (names.hasNext())
-         {
+         while (names.hasNext()) {
             QName name = names.next();
-            String value = (String)metaData.getAttributes().get(name);
+            String value = (String) metaData.getAttributes().get(name);
             // FIXME: This should be done by XB
             value = StringPropertyReplacer.replaceProperties(value);
             IntrospectionUtils.setProperty(instance, name.getLocalPart(), value);
@@ -374,14 +383,13 @@
       }
       return instance;
    }
-
+   
    /**
     * Associate lifecycle listeners with the instance, if it implements Lifecycle.
     */
    protected static void addLifecycleListeners(Object instance, List<ListenerMetaData> list) throws Exception
    {
-      if (list == null)
-      {
+      if (list == null) {
          return;
       }
       org.apache.catalina.Lifecycle lifecycle = null;
@@ -391,24 +399,24 @@
       }
       else
       {
-         lifecycle = (org.apache.catalina.Lifecycle)instance;
+         lifecycle = (org.apache.catalina.Lifecycle) instance;
       }
       Iterator<ListenerMetaData> listenerMetaDatas = list.iterator();
       while (listenerMetaDatas.hasNext())
       {
          ListenerMetaData listenerMetaData = listenerMetaDatas.next();
-         lifecycle.addLifecycleListener((org.apache.catalina.LifecycleListener)getInstance(listenerMetaData, null));
+         lifecycle.addLifecycleListener((org.apache.catalina.LifecycleListener) getInstance(listenerMetaData, null));
       }
 
    }
-
+   
+   
    /**
     * Associate valves with the instance, if it implements Lifecycle.
     */
    protected static void addValves(Object instance, List<ValveMetaData> list) throws Exception
    {
-      if (list == null)
-      {
+      if (list == null) {
          return;
       }
       org.apache.catalina.Pipeline pipeline = null;
@@ -418,17 +426,18 @@
       }
       else
       {
-         pipeline = (org.apache.catalina.Pipeline)instance;
+         pipeline = (org.apache.catalina.Pipeline) instance;
       }
       Iterator<ValveMetaData> valveMetaDatas = list.iterator();
       while (valveMetaDatas.hasNext())
       {
          ValveMetaData valveMetaData = valveMetaDatas.next();
-         pipeline.addValve((org.apache.catalina.Valve)getInstance(valveMetaData, null));
+         pipeline.addValve((org.apache.catalina.Valve) getInstance(valveMetaData, null));
       }
 
    }
-
+   
+   
    @Override
    protected void stopService() throws Exception
    {
@@ -437,7 +446,7 @@
          throw new IllegalStateException("Must set TomcatDeployer before stopping");
 
       // Hot undeploy
-      Boolean inShutdown = (Boolean)server.getAttribute(ServerImplMBean.OBJECT_NAME, "InShutdown");
+      Boolean inShutdown = (Boolean) server.getAttribute(ServerImplMBean.OBJECT_NAME, "InShutdown");
       if (inShutdown.booleanValue() == false)
       {
          log.debug("Server '" + ServerImplMBean.OBJECT_NAME + "' already started, stopping connectors now");
@@ -449,9 +458,9 @@
       String objectNameS = tomcatDeployer.getDomain() + ":type=server";
       ObjectName objectName = new ObjectName(objectNameS);
 
-      server.invoke(objectName, "stop", new Object[] {}, new String[] {});
+      server.invoke(objectName, "stop", new Object[]{}, new String[]{});
 
-      server.invoke(objectName, "destroy", new Object[] {}, new String[] {});
+      server.invoke(objectName, "destroy", new Object[]{}, new String[]{});
 
       server.unregisterMBean(objectName);
 
@@ -462,7 +471,7 @@
       Iterator iterator = server2.queryMBeans(queryObjectName, null).iterator();
       while (iterator.hasNext())
       {
-         ObjectInstance oi = (ObjectInstance)iterator.next();
+         ObjectInstance oi = (ObjectInstance) iterator.next();
          ObjectName toRemove = oi.getObjectName();
          // Exception: Don't unregister the service right now
          if (!"WebServer".equals(toRemove.getKeyProperty("service")))
@@ -477,7 +486,7 @@
       iterator = server2.queryMBeans(queryObjectName, null).iterator();
       while (iterator.hasNext())
       {
-         ObjectInstance oi = (ObjectInstance)iterator.next();
+         ObjectInstance oi = (ObjectInstance) iterator.next();
          ObjectName name = oi.getObjectName();
          server2.unregisterMBean(name);
       }
@@ -613,7 +622,7 @@
       ObjectName service = new ObjectName(tomcatDeployer.getDomain() + ":type=Service,serviceName=jboss.web");
       Object[] args = {};
       String[] sig = {};
-      Connector[] connectors = (Connector[])server.invoke(service, "findConnectors", args, sig);
+      Connector[] connectors = (Connector[]) server.invoke(service, "findConnectors", args, sig);
       for (int n = 0; n < connectors.length; n++)
       {
          Lifecycle lc = connectors[n];
@@ -637,7 +646,7 @@
       ObjectName service = new ObjectName(tomcatDeployer.getDomain() + ":type=Service,serviceName=jboss.web");
       Object[] args = {};
       String[] sig = {};
-      Connector[] connectors = (Connector[])server.invoke(service, "findConnectors", args, sig);
+      Connector[] connectors = (Connector[]) server.invoke(service, "findConnectors", args, sig);
       for (int n = 0; n < connectors.length; n++)
       {
          connectors[n].pause();
@@ -764,7 +773,7 @@
       if (this.tomcatDeployer != null)
          this.tomcatDeployer.setSessionCookieForSSOAuth(sessionCookieForSSOAuth);
    }
-
+   
    /**
     * {@inheritDoc}
     * 
@@ -778,7 +787,7 @@
       KernelController kernelController = controllerContext == null ? null : controllerContext.getKernel().getController();
       JBossWebMicrocontainerBeanLocator.setKernelController(kernelController);
    }
-
+   
    /**
     * {@inheritDoc}
     * 




More information about the jboss-cvs-commits mailing list