[jboss-cvs] JBossAS SVN: r57669 - in trunk: build server/src/main/org/jboss/metadata server/src/main/org/jboss/web server/src/main/org/jboss/web/deployers tomcat tomcat/src/main/org/jboss/web/tomcat/tc6/deployers tomcat/src/resources

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Oct 14 02:13:42 EDT 2006


Author: scott.stark at jboss.org
Date: 2006-10-14 02:13:26 -0400 (Sat, 14 Oct 2006)
New Revision: 57669

Added:
   trunk/server/src/main/org/jboss/web/deployers/
   trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
   trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployerMBean.java
   trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
   trunk/server/src/main/org/jboss/web/deployers/WebModule.java
   trunk/server/src/main/org/jboss/web/deployers/WebModuleMBean.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/DeployerConfig.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployer.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployerMBean.java
   trunk/tomcat/src/resources/jboss-structure.xml
   trunk/tomcat/src/resources/war-deployers-all-beans.xml
Removed:
   trunk/tomcat/src/resources/jboss-service-all.xml
   trunk/tomcat/src/resources/jboss-service.xml
Modified:
   trunk/build/build-distr.xml
   trunk/build/build.xml
   trunk/server/src/main/org/jboss/metadata/WebMetaData.java
   trunk/server/src/main/org/jboss/web/AbstractWebContainer.java
   trunk/server/src/main/org/jboss/web/AbstractWebDeployer.java
   trunk/tomcat/build.xml
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java
   trunk/tomcat/src/resources/server.xml
   trunk/tomcat/src/resources/war-deployers-beans.xml
Log:
Initial port of the war deployer to the VDF

Modified: trunk/build/build-distr.xml
===================================================================
--- trunk/build/build-distr.xml	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/build/build-distr.xml	2006-10-14 06:13:26 UTC (rev 57669)
@@ -1264,15 +1264,13 @@
        file="${jboss.web.lib}/el-api.jar" />
 
     <!-- Copy the deployables -->
-    <mkdir dir="${install.server}/all/deploy/jbossweb-tomcat6.sar"/>
-    <copy todir="${install.server}/all/deploy/jbossweb-tomcat6.sar">
-      <fileset dir="${_module.output}/deploy/jbossweb-tomcat6.sar"
-               excludes="**/jboss-service.xml"/>
+    <mkdir dir="${install.server}/all/deployers/jbossweb-tomcat6.deployer"/>
+    <copy todir="${install.server}/all/deployers/jbossweb-tomcat6.deployer">
+      <fileset dir="${_module.output}/deploy/jbossweb-tomcat6.deployer" />
     </copy>
-    <copy tofile="${install.server}/all/deploy/jbossweb-tomcat6.sar/META-INF/jboss-service.xml"
-          file="${project.root}/${_module.name}/src/resources/jboss-service-all.xml"/>
-    <copy todir="${install.server}/all/deploy/jbossweb-tomcat6.sar/META-INF"
-      file="${project.root}/${_module.name}/src/resources/webserver-xmbean.xml"/>
+    <!-- Use the all war deployers descriptor -->
+    <copy tofile="${install.server}/all/deployers/jbossweb-tomcat6.deployer/META-INF/war-deployers-beans.xml"
+      file="${project.root}/${_module.name}/src/resources/war-deployers-all-beans.xml" overwrite="true"/>
 
     <!-- Copy the tc5 clustering service sar -->
     <copy todir="${install.server}/all/deploy">

Modified: trunk/build/build.xml
===================================================================
--- trunk/build/build.xml	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/build/build.xml	2006-10-14 06:13:26 UTC (rev 57669)
@@ -244,12 +244,14 @@
     <property name="install.all" value="${install.server}/all"/>
     <property name="install.all.lib" value="${install.all}/lib"/>
     <property name="install.all.deploy" value="${install.all}/deploy"/>
+    <property name="install.all.deployers" value="${install.all}/deployers"/>
     <property name="install.all.conf" value="${install.all}/conf"/>
     <property name="install.all.deploy.hasingleton" value="${install.all}/deploy-hasingleton"/>
 
     <property name="install.default" value="${install.server}/default"/>
     <property name="install.default.lib" value="${install.default}/lib"/>
     <property name="install.default.deploy" value="${install.default}/deploy"/>
+    <property name="install.default.deployers" value="${install.default}/deployers"/>
     <property name="install.default.conf" value="${install.default}/conf"/>
 
     <property name="install.minimal" value="${install.server}/minimal"/>
@@ -727,8 +729,9 @@
     </copy>
     <copy todir="${install.default.conf}"
           file="${project.root}/server/output/etc/conf/default/jndi.properties" overwrite="true"/>
-    <copy tofile="${install.default.deploy}/jbossweb-tomcat6.sar/META-INF/jboss-service.xml"
-          file="${project.root}/tomcat/src/resources/jboss-service.xml" overwrite="true"/>
+    <!-- Update to the non-clustered beans descriptor -->      
+     <copy tofile="${install.default.deployers}/jbossweb-tomcat6.deployer/META-INF/war-deployers-beans.xml"
+          file="${project.root}/tomcat/src/resources/war-deployers-beans.xml" overwrite="true"/>
 <!--
     <copy todir="${install.default.deploy}">
       <fileset dir="${install.all.deploy.hasingleton}">

Modified: trunk/server/src/main/org/jboss/metadata/WebMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/WebMetaData.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/server/src/main/org/jboss/metadata/WebMetaData.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -445,7 +445,7 @@
       dependencies.add(depends);
    }
 
-   public Collection getDependencies()
+   public Collection<String> getDependencies()
    {
       return dependencies;
    }

Modified: trunk/server/src/main/org/jboss/web/AbstractWebContainer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/AbstractWebContainer.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/server/src/main/org/jboss/web/AbstractWebContainer.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -62,7 +62,7 @@
 
  @see org.jboss.web.AbstractWebDeployer
 
- @jmx:mbean extends="org.jboss.deployment.SubDeployerMBean"
+ @deprecated see org.jboss.web.deployers.AbstractWarDeployer
 
  @author  Scott.Stark at jboss.org
  @author  Christoph.Jung at infor.de

Modified: trunk/server/src/main/org/jboss/web/AbstractWebDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/AbstractWebDeployer.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/server/src/main/org/jboss/web/AbstractWebDeployer.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -151,10 +151,9 @@
 @see org.jboss.security.SimplePrincipal;
 @see org.jboss.security.SecurityAssociation;
 
- at jmx.mbean
-   name="jboss.web:service=WebServer"
-   extends="org.jboss.deployment.SubDeployerMBean"
+ at deprecated see org.jboss.web.deployers.AbstractWarDeployment
 
+
 @author  Scott.Stark at jboss.org
 @version $Revision$
 */

Added: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -0,0 +1,496 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.deployers;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.deployers.plugins.deployers.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.web.WebApplication;
+
+/** A template pattern class for web container integration into JBoss. This class
+ should be subclasses by web container providers wishing to integrate their
+ container into a JBoss server.
+
+ @see org.jboss.web.AbstractWebDeployer
+
+ @jmx:mbean extends="org.jboss.deployment.SubDeployerMBean"
+
+ @author  Scott.Stark at jboss.org
+ @author  Christoph.Jung at infor.de
+ @author  Thomas.Diesler at arcor.de
+ @version $Revision: 55985 $
+ */
+public abstract class AbstractWarDeployer extends AbstractSimpleRealDeployer<WebMetaData>
+{
+   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";
+
+   /** The suffixes we accept, along with their relative order */
+   private static final String[] DEFAULT_ENHANCED_SUFFIXES = new String[] {
+         "500:.war"
+   };
+   
+   /** 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;
+
+   /** 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;
+
+   public AbstractWarDeployer()
+   {
+      super(WebMetaData.class);
+   }
+
+   
+   @Override
+   public int getRelativeOrder()
+   {
+      return COMPONENT_DEPLOYER+1;
+   }
+
+   /** 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 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 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;
+   }
+
+   /**
+    * 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;
+   }
+
+   /** 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;
+   }
+
+   /** Get the session attribute number under which the caller Subject is stored
+    * @jmx:managed-attribute
+    */ 
+   public String getSubjectAttributeName()
+   {
+      return subjectAttributeName;
+   }
+   /** 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 start() throws Exception
+   {
+      // TODO: remove dependency on jmx
+      this.server = MBeanServerLocator.locateJBoss();
+   }
+   public void stop() throws Exception
+   {
+      
+   }
+
+   public abstract AbstractWarDeployment getDeployment(DeploymentUnit unit, WebMetaData metaData)
+      throws Exception;
+
+   /**
+    * Deploy a web app based on the WebMetaData.
+    * @param unit - the war for the deployment
+    * @param metaData - the metadata for the deployment
+    */
+   @Override
+   public void deploy(DeploymentUnit unit, WebMetaData metaData)
+      throws DeploymentException
+   {
+      log.debug("Begin deploy");
+
+      try
+      {
+         /* TODO: This needs to be moved to a webservice deployer which updates the WebMetaData
+         // We need to unpack the WAR if it has webservices.xml, because we need
+         // to manipulate th web.xml before deploying to the web container 
+         boolean unpackWebservice = di.localCl.findResource("WEB-INF/webservices.xml") != null;
+         // With JSR-181 annotated JSE endpoints we need to do it as well even if there is no webservices.xml
+         // unpackWebservice |= server.isRegistered(ObjectNameFactory.create("jboss.ws:service=ServiceEndpointManager"));
+
+         // Make sure the war is unpacked if unpackWars is true
+         File warFile = new File(di.localUrl.getFile());
+         if (warFile.isDirectory() == false && (unpackWars || unpackWebservice))
+         {
+            // After findResource we cannot rename the WAR anymore, because
+            // some systems keep an open reference to the file :(  
+            String prefix = warFile.getCanonicalPath();
+            prefix = prefix.substring(0, prefix.lastIndexOf(".war"));
+            File expWarFile = new File(prefix + "-exp.war");
+            if( expWarFile.mkdir() == false )
+               throw new DeploymentException("Was unable to mkdir: "+expWarFile);
+            log.debug("Unpacking war to: "+expWarFile);
+            FileInputStream fis = new FileInputStream(warFile);
+            JarUtils.unjar(fis, expWarFile);
+            fis.close();
+            log.debug("Replaced war with unpacked contents");
+            if (warFile.delete() == false)
+               log.debug("Was unable to delete war file");
+            else
+               log.debug("Deleted war archive");
+            // Reset the localUrl to end in a '/'
+            di.localUrl = expWarFile.toURL();
+            // Reset the localCl to point to the file
+            URL[] localCl = new URL[]{di.localUrl};
+            di.localCl = new URLClassLoader(localCl);
+         }
+         */
+
+         metaData.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
+
+         // Build the context root if its not been set 
+         String webContext = metaData.getContextRoot();
+         String warName = unit.getName();
+         webContext = buildWebContext(webContext, warName, metaData);
+         metaData.setContextRoot(webContext);
+         
+         AbstractWarDeployment deployment = getDeployment(unit, metaData);
+         deployWebModule(unit, metaData, deployment);
+      }
+      catch(Exception e)
+      {
+         throw new DeploymentException("Failed to create web module", e);
+      }
+   }
+
+   /**
+    * Stop the associated web module 
+    */
+   @Override
+   public void undeploy(DeploymentUnit unit, WebMetaData metaData)
+   {
+      try
+      {
+         String name = getObjectName(metaData);
+         ObjectName objectName = new ObjectName(name);
+         // TODO: ...
+      }
+      catch(Exception e)
+      {
+         
+      }
+   }
+
+   public void addDeployedApp(String warURL,  WebApplication webApp)
+   {
+      deploymentMap.put(warURL, webApp);
+   }
+   /** 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 WebApplication removeDeployedApp(String warURL)
+   {
+      WebApplication appInfo = (WebApplication) deploymentMap.remove(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();
+   }
+
+   /** Use 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()) )
+         {
+            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);
+            }
+         }
+      }
+      catch(Exception ignore)
+      {
+      }
+      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.
+   */
+   protected String buildWebContext(String ctxPath, String warName, WebMetaData metaData)
+   {
+      // Build a war root context from the war name if one was not specified
+      String webContext = ctxPath;
+      if( webContext == null )
+         webContext = metaData.getContextRoot();
+      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 ++)
+          {
+             char c = webContext.charAt(index);
+             if( Character.isDigit(c) == false && c != '.' )
+                break;
+          }
+          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;
+   }
+
+   @Deprecated
+   protected MBeanServer getServer()
+   {
+      return server;
+   }
+
+   /**
+    * 
+    * @param unit
+    * @param cmd
+    * @return
+    */
+   protected String getObjectName(WebMetaData metaData)
+   {
+      String ctxPath = metaData.getContextRoot();
+      String objectName = "jboss.web.deployment:war="+ctxPath;
+      return objectName;
+   }
+
+   protected void deployWebModule(DeploymentUnit unit, WebMetaData metaData, AbstractWarDeployment deployment)
+      throws Exception
+   {
+      log.debug("deployWebModule");
+      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);
+         
+         // Dependencies...Still have old jmx names here
+         Collection<String> depends = metaData.getDependencies();
+         List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
+         for(String iDependOn : depends)
+         {
+            ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
+            sdmd.setIDependOn(iDependOn);
+         }
+         webModule.setDependencies(dependencies);
+
+         // TODO component
+         unit.addAttachment(ServiceMetaData.class, webModule);
+      }
+      catch (Exception e)
+      {
+         throw DeploymentException.rethrowAsDeploymentException("Error creating rar deployment " + unit.getName(), e);
+      }
+
+   }
+
+   private void addURLs(Set urlSet, URL[] urls)
+   {
+      for(int u = 0; u < urls.length; u ++)
+      {
+         URL url = urls[u];
+         urlSet.add(url.toExternalForm());
+      }
+   }
+}


Property changes on: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployerMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployerMBean.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployerMBean.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -0,0 +1,86 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.web.deployers;
+
+/**
+ * MBean interface.
+ * @see org.jboss.web.AbstractWebDeployer
+ */
+public interface AbstractWarDeployerMBean
+{
+
+   /**
+    * 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
+    */
+  boolean getJava2ClassLoadingCompliance() ;
+
+   /**
+    * 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
+    */
+  void setJava2ClassLoadingCompliance(boolean 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.
+    * @return true is war archives should be unpacked    */
+  boolean getUnpackWars() ;
+
+   /**
+    * 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.
+    * @param flag , true is war archives should be unpacked    */
+  void setUnpackWars(boolean 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
+    */
+  boolean getLenientEjbLink() ;
+
+   /**
+    * Set the flag indicating if ejb-link errors should be ignored in favour of trying the jndi-name in jboss-web.xml
+    */
+  void setLenientEjbLink(boolean 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.
+    */
+  java.lang.String getDefaultSecurityDomain() ;
+
+   /**
+    * 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.
+    */
+  void setDefaultSecurityDomain(java.lang.String defaultSecurityDomain) ;
+
+   /**
+    * Get the session attribute number under which the caller Subject is stored
+    */
+  java.lang.String getSubjectAttributeName() ;
+
+   /**
+    * Set the session attribute number under which the caller Subject is stored
+    */
+  void setSubjectAttributeName(java.lang.String subjectAttributeName) ;
+
+}

Added: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -0,0 +1,836 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.deployers;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.Policy;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.LinkRef;
+import javax.naming.NamingException;
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.EjbLocalRefMetaData;
+import org.jboss.metadata.EjbRefMetaData;
+import org.jboss.metadata.EnvEntryMetaData;
+import org.jboss.metadata.MessageDestinationMetaData;
+import org.jboss.metadata.MessageDestinationRefMetaData;
+import org.jboss.metadata.ResourceEnvRefMetaData;
+import org.jboss.metadata.ResourceRefMetaData;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.mx.loading.LoaderRepositoryFactory;
+import org.jboss.naming.NonSerializableFactory;
+import org.jboss.naming.Util;
+import org.jboss.security.AuthorizationManager;
+import org.jboss.security.authorization.PolicyRegistration;
+import org.jboss.web.WebApplication;
+import org.jboss.web.WebPermissionMapping;
+import org.jboss.web.AbstractWebContainer.WebDescriptorParser;
+import org.omg.CORBA.ORB;
+
+/** 
+The one thing to be aware of is the relationship between the thread context
+class loader and the JNDI ENC context. Any method that attempts to access
+the JNDI ENC context must have the ClassLoader in the WebApplication returned
+from the {@link #performDeploy(WebApplication, String, WebDescriptorParser) performDeploy} as its thread
+context ClassLoader or else the lookup for java:comp/env will fail with a
+name not found exception, or worse, it will receive some other web application
+ENC context. If your adapting a web container that is trying be compatible with
+both 1.1 and 1.2 Java VMs this is something you need to pay special attention
+to. For example, I have seen problems a request interceptor that was handling
+the authentication/authorization callouts in tomcat3.2.1 not having the same
+thread context ClassLoader as was used to dispatch the http service request.
+
+ at see #performDeploy(WebApplication webApp, String warUrl,
+        WebDescriptorParser webAppParser)
+ at see #performUndeploy(String, WebApplication)
+ at see #processEnc(...)
+ at see #linkSecurityDomain(String, Context)
+ at see org.jboss.security.RealmMapping;
+ at see org.jboss.security.SimplePrincipal;
+ at see org.jboss.security.SecurityAssociation;
+
+ at author  Scott.Stark at jboss.org
+ at version $Revision: 57455 $
+*/
+public abstract class AbstractWarDeployment
+{
+   public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
+   protected Logger log;
+
+   protected MBeanServer server;
+   /**
+    * The parent class loader first model flag
+    */
+   protected boolean java2ClassLoadingCompliance = false;
+   /**
+    * A flag indicating if war archives should be unpacked
+    */
+   protected boolean unpackWars = true;
+   /**
+    * 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;
+
+   public AbstractWarDeployment()
+   {
+      log = Logger.getLogger(getClass());
+   }
+
+   /**
+    * A utility method that takes a deployment unit name and strips it down to the base war
+    * name without the .war suffix.
+    * @param name - the DeploymentUnit name.
+    */
+   public static String shortNameFromDeploymentName(String name)
+   {
+      String shortName = name;
+      String[] parts = name.split("/|\\.");
+      if( parts.length > 1 )
+      {
+         // If it ends in .war, use the previous part
+         if( parts[parts.length-1].equals("war") )
+            shortName = parts[parts.length-2];
+         // else use the last part
+         else
+            shortName = parts[parts.length-1];
+      }
+      return shortName;
+   }
+   /**
+    * Utility method that builds a string url based on the ServerConfig.SERVER_HOME_URL system
+    * property and the input url. If the input url is under the SERVER_HOME_URL, the SERVER_HOME_URL
+    * prefix is replaced with ".../".
+    * @param warUrl
+    * @return the possibly shorted war url string.
+    */
+   public static String shortWarUrlFromServerHome(String warUrl)
+   {
+       String serverHomeUrl =  System.getProperty(org.jboss.system.server.ServerConfig.SERVER_HOME_URL);
+
+       if (warUrl == null || serverHomeUrl == null)
+           return warUrl;
+
+       if (warUrl.startsWith(serverHomeUrl))
+         return ".../" + warUrl.substring(serverHomeUrl.length());
+       else
+         return warUrl;
+   } 
+
+   /**
+    * Initialize the deployment using an instance specific configuration object.
+    * @param containerConfig
+    * @throws Exception
+    */
+   public abstract void init(Object containerConfig) throws Exception;
+
+   public MBeanServer getServer()
+   {
+      return server;
+   }
+
+   public void setServer(MBeanServer server)
+   {
+      this.server = server;
+   }
+
+   /**
+    * 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;
+   }
+
+   /**
+    * 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.
+    * @return true is war archives should be unpacked
+    * @jmx.managed-attribute
+    */
+   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.
+    * @param flag , true is war archives should be unpacked
+    * @jmx.managed-attribute
+    */
+   public void setUnpackWars(boolean flag)
+   {
+      this.unpackWars = flag;
+   }
+
+   /**
+    * Get the flag indicating if ejb-link errors should be ignored in favour of
+    * trying the jndi-name in jboss-web.xml
+    * @return a <code>boolean</code> value
+    * @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;
+   }
+
+   /**
+    * 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;
+   }
+
+   /**
+    * A template pattern implementation of the deploy() method. This method
+    * calls the {@link #performDeploy(WebApplication, String,
+      * WebDescriptorParser) performDeploy()} method to perform the container
+    * specific deployment steps and registers the returned WebApplication in the
+    * deployment map. The steps performed are:
+    *
+    * ClassLoader appClassLoader = thread.getContextClassLoader();
+    * URLClassLoader warLoader = URLClassLoader.newInstance(empty,
+    * appClassLoader); thread.setContextClassLoader(warLoader);
+    * WebDescriptorParser webAppParser = ...; WebMetaData metaData =
+    * di.metaData; // Create JACC permissions, contextID, etc. ...
+    * WebApplication warInfo = new WebApplication(metaData);
+    * performDeploy(warInfo, warUrl, webAppParser); deploymentMap.put(warUrl,
+    * warInfo); thread.setContextClassLoader(appClassLoader);
+    *
+    * The subclass performDeploy() implementation needs to invoke
+    * processEnc(loader, warInfo) to have the JNDI
+    * java:comp/env namespace setup before any web app component can access this
+    * namespace.
+    *
+    * Also, an MBean for each servlet deployed should be created and its JMX
+    * ObjectName placed into the DeploymentInfo.mbeans list so that the JSR77
+    * layer can create the approriate model view. The servlet MBean needs to
+    * provide access to the min, max and total time in milliseconds. Expose this
+    * information via MinServiceTime, MaxServiceTime and TotalServiceTime
+    * attributes to integrate seemlessly with the JSR77 factory layer.
+    * @param di The deployment info that contains the context-root element value
+    * from the J2EE application/module/web application.xml descriptor. This may
+    * 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 di, WebMetaData metaData)
+      throws Exception
+   {
+      Thread thread = Thread.currentThread();
+      ClassLoader appClassLoader = thread.getContextClassLoader();
+      WebApplication warInfo = null;
+      try
+      {
+         // Create a classloader for the war to ensure a unique ENC
+         URL[] empty = {};
+         URLClassLoader warLoader1 = URLClassLoader.newInstance(empty, di.getClassLoader());
+         URLClassLoader warLoader = warLoader1;
+         thread.setContextClassLoader(warLoader);
+         String webContext = metaData.getContextRoot();
+   
+         // Get the war URL
+         URL warURL = di.getDeploymentContext().getRoot().toURL();
+         // Strip any jar: url syntax. This should be be exposed by the vfs
+         String warURLString = warURL.toString();
+         if( warURLString.startsWith("jar:") )
+            warURLString = warURLString.substring(4, warURLString.length()-2);
+         log.debug("webContext: " + webContext);
+         log.debug("warURL: " + warURLString);
+   
+         /* TODO: this must come from the metadata deployers
+          inherit the security setup from jboss-app.xml
+         if (di.parent != null && di.parent.metaData instanceof J2eeApplicationMetaData)
+         {
+            J2eeApplicationMetaData appMetaData = (J2eeApplicationMetaData) di.parent.metaData;
+   
+            if (metaData.getSecurityDomain() == null)
+               metaData.setSecurityDomain(appMetaData.getSecurityDomain());
+   
+            metaData.mergeSecurityRoles(appMetaData.getSecurityRoles());
+         }
+         */
+   
+         // Register the permissions with the JACC layer
+         String contextID = metaData.getJaccContextID();
+         if( contextID == null )
+            contextID = shortNameFromDeploymentName(di.getName());
+         metaData.setJaccContextID(contextID);
+         PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+         PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
+         createPermissions(metaData, pc);
+         // Link this to the parent PC
+         DeploymentContext current = di.getDeploymentContext();
+         while (current.getParent() != null)
+            current = current.getParent();
+         PolicyConfiguration parentPC =
+            current.getTransientAttachments().getAttachment(PolicyConfiguration.class);
+         if (parentPC != null && parentPC != pc)
+            parentPC.linkConfiguration(pc);
+   
+         // Commit the policy configuration
+         pc.commit();
+         // Allow the policy to incorporate the policy configs
+         Policy.getPolicy().refresh();
+   
+         warInfo = new WebApplication(metaData);
+         warInfo.setClassLoader(warLoader);
+         performDeploy(warInfo, warURLString);
+      }
+      finally
+      {
+         thread.setContextClassLoader(appClassLoader);
+      }
+      return warInfo;
+   }
+
+   /**
+    * A template pattern implementation of the undeploy() method. This method
+    * calls the {@link #performUndeploy(String, WebApplication)
+    * 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
+   {
+      URL warURL = webApp.getURL();
+      String warUrl = warURL.toString();
+      performUndeploy(warUrl, webApp);
+      // Unregister the permissions with the JACC layer
+      WebMetaData metaData = webApp.getMetaData();
+      String contextID = metaData.getJaccContextID();
+      PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+      PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
+      pc.delete();
+      //Unregister any xacml policies
+      String prefixedSecurityDomain = webApp.getMetaData().getSecurityDomain();
+      if(prefixedSecurityDomain != null)
+      {
+         AuthorizationManager authzmgr = 
+             org.jboss.security.Util.getAuthorizationManager(prefixedSecurityDomain);
+         if(authzmgr instanceof PolicyRegistration)
+         {
+            PolicyRegistration xam = (PolicyRegistration)authzmgr;
+            xam.deRegisterPolicy(contextID);
+         } 
+      } 
+   }
+
+   /**
+    * This method is called by the start() method template and must be
+    * overriden by subclasses to perform the web container specific deployment
+    * steps.
+    * @param webApp The web application information context. This contains the
+    * metadata such as the context-root element value from the J2EE
+    * application/module/web application.xml descriptor and virtual-host.
+    * @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.
+    */
+   protected abstract void performUndeploy(String warUrl, WebApplication webApp)
+      throws Exception;
+
+   /**
+    * This method is invoked from within subclass performDeploy() method
+    * implementations when they invoke WebDescriptorParser.parseWebAppDescriptors().
+    * @param loader the ClassLoader for the web application. May not be null.
+    * @param metaData the WebMetaData from the WebApplication object passed to
+    * the performDeploy method.
+    */
+   protected void processEnc(ClassLoader loader, WebMetaData metaData)
+      throws Exception
+   {
+      log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin");
+      InitialContext iniCtx = new InitialContext();
+      Context envCtx = null;
+      Thread currentThread = Thread.currentThread();
+      ClassLoader currentLoader = currentThread.getContextClassLoader();
+      try
+      {
+         // Create a java:comp/env environment unique for the web application
+         log.debug("Creating ENC using ClassLoader: " + loader);
+         ClassLoader parent = loader.getParent();
+         while (parent != null)
+         {
+            log.debug(".." + parent);
+            parent = parent.getParent();
+         }
+         // TODO: The enc should be an input?
+         currentThread.setContextClassLoader(loader);
+         metaData.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");
+            // Bind the orb
+            if (orb != null)
+            {
+               NonSerializableFactory.rebind(envCtx, "ORB", orb);
+               log.debug("Bound java:comp/ORB");
+            }
+         }
+         catch (Throwable t)
+         {
+            log.debug("Unable to retrieve orb" + t.toString());
+         }
+
+         // TODO: injection, Add a link to the global transaction manager
+         envCtx.bind("UserTransaction", new LinkRef("UserTransaction"));
+         log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction");
+         envCtx = envCtx.createSubcontext("env");
+         processEncReferences(metaData, envCtx);
+      }
+      finally
+      {
+         currentThread.setContextClassLoader(currentLoader);
+      }
+
+      String securityDomain = metaData.getSecurityDomain();
+      log.debug("linkSecurityDomain");
+      linkSecurityDomain(securityDomain, envCtx);
+      log.debug("AbstractWebContainer.parseWebAppDescriptors, End");
+   }
+
+   protected void processEncReferences(WebMetaData metaData, Context envCtx)
+           throws ClassNotFoundException, NamingException
+   {
+      Iterator envEntries = metaData.getEnvironmentEntries();
+      log.debug("addEnvEntries");
+      addEnvEntries(envEntries, envCtx);
+      Iterator resourceEnvRefs = metaData.getResourceEnvReferences();
+      log.debug("linkResourceEnvRefs");
+      linkResourceEnvRefs(resourceEnvRefs, envCtx);
+      Iterator resourceRefs = metaData.getResourceReferences();
+      log.debug("linkResourceRefs");
+      linkResourceRefs(resourceRefs, envCtx);
+      log.debug("linkMessageDestinationRefs");
+      linkMessageDestinationRefs(metaData, envCtx);
+      Iterator ejbRefs = metaData.getEjbReferences();
+      log.debug("linkEjbRefs");
+      linkEjbRefs(ejbRefs, envCtx);
+      Iterator ejbLocalRefs = metaData.getEjbLocalReferences();
+      log.debug("linkEjbLocalRefs");
+      linkEjbLocalRefs(ejbLocalRefs, envCtx);
+      Iterator serviceRefs = metaData.getServiceReferences();
+      log.debug("linkServiceRefs");
+      //WebServiceClientHandler.setupServiceRefEnvironment(envCtx, serviceRefs);
+   }
+
+   protected void addEnvEntries(Iterator envEntries, Context envCtx)
+      throws ClassNotFoundException, NamingException
+   {
+      while (envEntries.hasNext())
+      {
+         EnvEntryMetaData entry = (EnvEntryMetaData) envEntries.next();
+         log.debug("Binding env-entry: " + entry.getName() + " of type: " +
+            entry.getType() + " to value:" + entry.getValue());
+         EnvEntryMetaData.bindEnvEntry(envCtx, entry);
+      }
+   }
+
+   protected void linkResourceEnvRefs(Iterator resourceEnvRefs, Context envCtx)
+      throws NamingException
+   {
+      while (resourceEnvRefs.hasNext())
+      {
+         ResourceEnvRefMetaData ref = (ResourceEnvRefMetaData) resourceEnvRefs.next();
+         String resourceName = ref.getJndiName();
+         String refName = ref.getRefName();
+         if (ref.getType().equals("java.net.URL"))
+         {
+            try
+            {
+               log.debug("Binding '" + refName + "' to URL: " + resourceName);
+               URL url = new URL(resourceName);
+               Util.bind(envCtx, refName, url);
+            }
+            catch (MalformedURLException e)
+            {
+               throw new NamingException("Malformed URL:" + e.getMessage());
+            }
+         }
+         else if (resourceName != null)
+         {
+            log.debug("Linking '" + refName + "' to JNDI name: " + resourceName);
+            Util.bind(envCtx, refName, new LinkRef(resourceName));
+         }
+         else
+         {
+            throw new NamingException("resource-env-ref: " + refName
+               + " has no valid JNDI binding. Check the jboss-web/resource-env-ref.");
+         }
+      }
+   }
+
+   protected void linkResourceRefs(Iterator resourceRefs, Context envCtx)
+      throws NamingException
+   {
+      while (resourceRefs.hasNext())
+      {
+         ResourceRefMetaData ref = (ResourceRefMetaData) resourceRefs.next();
+         String jndiName = ref.getJndiName();
+         String refName = ref.getRefName();
+         if (ref.getType().equals("java.net.URL"))
+         {
+            try
+            {
+               String resURL = ref.getResURL();
+               if (ref.getResURL() != null)
+               {
+                  log.debug("Binding '" + refName + "' to URL: " + resURL);
+                  URL url = new URL(resURL);
+                  Util.bind(envCtx, refName, url);
+               }
+               else
+               {
+                  log.debug("Linking '" + refName + "' to URL: " + resURL);
+                  LinkRef urlLink = new LinkRef(jndiName);
+                  Util.bind(envCtx, refName, urlLink);
+               }
+            }
+            catch (MalformedURLException e)
+            {
+               throw new NamingException("Malformed URL:" + e.getMessage());
+            }
+         }
+         else if (jndiName != null)
+         {
+            log.debug("Linking '" + refName + "' to JNDI name: " + jndiName);
+            Util.bind(envCtx, refName, new LinkRef(jndiName));
+         }
+         else
+         {
+            throw new NamingException("resource-ref: " + refName
+               + " has no valid JNDI binding. Check the jboss-web/resource-ref.");
+         }
+      }
+   }
+
+   protected void linkMessageDestinationRefs(WebMetaData metaData, Context envCtx)
+      throws NamingException
+   {
+      Iterator i = metaData.getMessageDestinationReferences();
+
+      while (i.hasNext())
+      {
+         MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData) i.next();
+
+         String refName = ref.getRefName();
+         String jndiName = ref.getJNDIName();
+         String link = ref.getLink();
+         if (link != null)
+         {
+            if (jndiName == null)
+            {
+               MessageDestinationMetaData messageDestination = null; //EjbUtil.findMessageDestination(server, di, 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");
+               else
+               {
+                  String linkJNDIName = messageDestination.getJNDIName();
+                  if (linkJNDIName == null)
+                     log.warn("message-destination '" + link + "' has no jndi-name in jboss-web.xml");
+                  else
+                     jndiName = linkJNDIName;
+               }
+            }
+            else
+               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");
+         Util.bind(envCtx, refName, new LinkRef(jndiName));
+      }
+   }
+
+   protected void linkEjbRefs(Iterator ejbRefs, Context envCtx)
+      throws NamingException
+   {
+      while (ejbRefs.hasNext())
+      {
+         EjbRefMetaData ejb = (EjbRefMetaData) ejbRefs.next();
+         String name = ejb.getName();
+         String linkName = ejb.getLink();
+         String jndiName = null;
+         
+         //use ejb-link if it is specified
+         if (linkName != null)
+         {
+            jndiName = null; // EjbUtil.findEjbLink(server, di, linkName);
+             
+            //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
+         if (jndiName == null)
+         {
+            jndiName = ejb.getJndiName();
+            if (jndiName == null)
+               throw new NamingException("ejb-ref: " + name + ", no ejb-link in web.xml and no jndi-name in jboss-web.xml");
+         }
+
+         log.debug("Linking ejb-ref: " + name + " to JNDI name: " + jndiName);
+         Util.bind(envCtx, name, new LinkRef(jndiName));
+      }
+   }
+
+   protected void linkEjbLocalRefs(Iterator ejbRefs, Context envCtx)
+      throws NamingException
+   {
+      while (ejbRefs.hasNext())
+      {
+         EjbLocalRefMetaData ejb = (EjbLocalRefMetaData) ejbRefs.next();
+         String name = ejb.getName();
+         String linkName = ejb.getLink();
+         String jndiName = null;
+
+         //use the ejb-link field if it is specified
+         if (linkName != null)
+         {
+            jndiName = null; // EjbUtil.findLocalEjbLink(server, di, linkName);
+             
+            //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();
+            if (jndiName == null)
+            {
+               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";
+               }
+               else
+               {
+                  msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '"
+                     + linkName + "' failed to resolve to an ejb with a LocalHome";
+               }
+               throw new NamingException(msg);
+            }
+         }
+
+         log.debug("Linking ejb-local-ref: " + name + " to JNDI name: " + jndiName);
+         Util.bind(envCtx, name, new LinkRef(jndiName));
+      }
+   }
+
+   /**
+    * This creates a java:comp/env/security context that contains a securityMgr
+    * binding pointing to an AuthenticationManager implementation and a
+    * realmMapping binding pointing to a RealmMapping implementation. If the
+    * jboss-web.xml descriptor contained a security-domain element then the
+    * bindings are LinkRefs to the jndi name specified by the security-domain
+    * 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
+   {
+      if (securityDomain == null)
+      {
+         securityDomain = getDefaultSecurityDomain();
+         log.debug("No security-domain given, using default: " + 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/security-domain", new LinkRef(securityDomain));
+      Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject"));
+   }
+
+   /**
+    * A utility method that searches the given loader for the resources:
+    * "javax/servlet/resources/web-app_2_3.dtd", "org/apache/jasper/resources/jsp12.dtd",
+    * and "javax/ejb/EJBHome.class" and returns an array of URL strings. Any
+    * jar: urls are reduced to the underlying <url> portion of the
+    * 'jar:<url>!/{entry}' construct.
+    */
+   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"
+      };
+      ArrayList tmp = new ArrayList();
+      for (int j = 0; j < jspResources.length; j++)
+      {
+         URL rsrcURL = loader.getResource(jspResources[j]);
+         if (rsrcURL != null)
+         {
+            String url = rsrcURL.toExternalForm();
+            if (rsrcURL.getProtocol().equals("jar"))
+            {
+               // Parse the jar:<url>!/{entry} URL
+               url = url.substring(4);
+               int seperator = url.indexOf('!');
+               url = url.substring(0, seperator);
+            }
+            tmp.add(url);
+         }
+         else
+         {
+            log.warn("Failed to fin jsp rsrc: " + jspResources[j]);
+         }
+      }
+      log.trace("JSP StandardCompileClasspath: " + tmp);
+      String[] cp = new String[tmp.size()];
+      tmp.toArray(cp);
+      return cp;
+   }
+
+   /**
+    * A utility method that walks up the ClassLoader chain starting at the given
+    * loader and queries each ClassLoader for a 'URL[] getURLs()' method from
+    * which a complete classpath of URL strings is built.
+    */
+   public String[] getCompileClasspath(ClassLoader loader)
+   {
+      HashSet tmp = new HashSet();
+      ClassLoader cl = loader;
+      while (cl != null)
+      {
+         URL[] urls = AbstractWarDeployer.getClassLoaderURLs(cl);
+         addURLs(tmp, urls);
+         cl = cl.getParent();
+      }
+      try
+      {
+         URL[] globalUrls = (URL[]) server.getAttribute(LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY,
+            "URLs");
+         addURLs(tmp, globalUrls);
+      }
+      catch (Exception e)
+      {
+         log.warn("Could not get global URL[] from default loader repository!", e);
+      } // end of try-catch
+      log.trace("JSP CompileClasspath: " + tmp);
+      String[] cp = new String[tmp.size()];
+      tmp.toArray(cp);
+      return cp;
+   }
+
+   private void addURLs(Set urlSet, URL[] urls)
+   {
+      for (int u = 0; u < urls.length; u++)
+      {
+         URL url = urls[u];
+         urlSet.add(url.toExternalForm());
+      }
+   }
+
+   /**
+    * Create the JACC permission based on the security constraints obtained from
+    * the web.xml metadata.
+    * @param metaData
+    * @param pc
+    * @throws PolicyContextException
+    */
+   protected void createPermissions(WebMetaData metaData, PolicyConfiguration pc)
+      throws PolicyContextException
+   {
+      WebPermissionMapping.createPermissions(metaData, pc);
+   }
+
+}


Property changes on: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/server/src/main/org/jboss/web/deployers/WebModule.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/WebModule.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/server/src/main/org/jboss/web/deployers/WebModule.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.deployers;
+
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployment.DeploymentException;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.web.WebApplication;
+
+/** A container service used to introduce war dependencies. This service is
+ created by the AbstractWebContainer during the create(DeploymentInfo) call
+ and registered under the name "jboss.web.deployment:war="+di.shortName
+ This name is stored in the di.context under the key AbstractWebContainer.WEB_MODULE
+
+ When the jboss-web.xml dependencies are satisfied, this service is started
+ and this triggers the AbstractWebDeployer.start. Likewise, a stop on this
+ service triggers the AbstractWebDeployer.stop.
+ 
+ @see AbstractWarDeployer
+ 
+ @author Scott.Stark at jboss.org
+ @version $Revison:$
+ */
+public class WebModule
+   implements WebModuleMBean
+{
+   private static Logger log = Logger.getLogger(WebModule.class);
+   private DeploymentUnit di;
+   private AbstractWarDeployer container;
+   private AbstractWarDeployment deployment;
+
+   public WebModule(DeploymentUnit di, AbstractWarDeployer container,
+         AbstractWarDeployment deployment)
+   {
+      this.di = di;
+      this.container = container;
+      this.deployment = deployment;
+   }
+
+   public void create()
+   {
+      
+   }
+   public void start() throws Exception
+   {
+      startModule();
+   }
+
+   public void stop() throws Exception
+   {
+      stopModule();
+   }
+
+   public void destroy()
+   {
+      this.di = null;
+      this.container = null;
+      this.deployment = null;      
+   }
+
+   /** Invokes the deployer start
+    */
+   public synchronized void startModule()
+      throws Exception
+   {
+      // Get the war URL
+      WebMetaData metaData = di.getAttachment(WebMetaData.class);
+      WebApplication webApp = deployment.start(di, metaData);
+      String warURL = di.getName();
+      container.addDeployedApp(warURL, webApp);
+   }
+
+   /** Invokes the deployer stop
+    */
+   public synchronized void stopModule()
+      throws DeploymentException
+   {
+      String warURL = di.getName();
+      try
+      {
+         WebApplication webApp = container.removeDeployedApp(warURL);
+         if( deployment != null && webApp != null )
+         {
+            deployment.stop(di, webApp);
+         }
+         else
+         {
+            log.debug("Failed to find deployer/deployment for war: "+warURL);
+         }
+      }
+      catch (Exception e)
+      {
+         throw new DeploymentException("Error during stop", e);
+      }
+   }
+
+}


Property changes on: trunk/server/src/main/org/jboss/web/deployers/WebModule.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/server/src/main/org/jboss/web/deployers/WebModuleMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/WebModuleMBean.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/server/src/main/org/jboss/web/deployers/WebModuleMBean.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.deployers;
+
+/** The standard mbean service interface for the WebModule
+ * @author Scott.Stark at jboss.org
+ * @version $Revison:$
+ */
+public interface WebModuleMBean
+{
+   public void create() throws Exception;
+   public void start() throws Exception;
+   public void stop() throws Exception;
+   public void destroy() throws Exception;
+}


Property changes on: trunk/server/src/main/org/jboss/web/deployers/WebModuleMBean.java
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/tomcat/build.xml
===================================================================
--- trunk/tomcat/build.xml	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/build.xml	2006-10-14 06:13:26 UTC (rev 57669)
@@ -16,7 +16,7 @@
 
 <!-- $Id$ -->
 
-<project default="main" name="JBoss/Tomcat-5">
+<project default="main" name="JBossWeb">
 
   <!--
      | Include the common Buildmagic elements.
@@ -211,46 +211,47 @@
     <call target="compile"/>
 
     <mkdir dir="${build.lib}"/>
-    <mkdir dir="${build.deploy}/jbossweb-tomcat6.sar/META-INF"/>
+    <mkdir dir="${build.deploy}/jbossweb-tomcat6.deployer/META-INF"/>
 
-    <!-- Build the jbossweb-tomcat6.sar -->
-    <copy file="${build.resources}/jboss-service.xml"
-      tofile="${build.deploy}/jbossweb-tomcat6.sar/META-INF/jboss-service.xml"/>
+    <!-- Build the jbossweb-tomcat6.deployer -->
+  	 <copy todir="${build.deploy}/jbossweb-tomcat6.deployer/META-INF">
+  	 	<fileset dir="${build.resources}">
+  	 		<include name="jboss-structure.xml" />
+  	 		<include name="war-deployers-beans.xml" />
+  	 		<include name="webserver-xmbean.xml" />
+  	 	</fileset>
+  	 </copy>	
     <copy file="${build.resources}/context.xml"
-      todir="${build.deploy}/jbossweb-tomcat6.sar"/>
+      todir="${build.deploy}/jbossweb-tomcat6.deployer"/>
     <copy file="${build.resources}/web.xml"
-      tofile="${build.deploy}/jbossweb-tomcat6.sar/conf/web.xml"/>
+      tofile="${build.deploy}/jbossweb-tomcat6.deployer/conf/web.xml"/>
     <copy file="${build.resources}/server.xml"
-      tofile="${build.deploy}/jbossweb-tomcat6.sar/server.xml"/>
-    <!-- TDI 20041108 breaks the build
-    <copy file="${build.resources}/sso-channel.xml"
-       tofile="${build.deploy}/jbossweb-tomcat6.sar/sso-channel.xml" />
-    -->
-    <copy todir="${build.deploy}/jbossweb-tomcat6.sar">
+      tofile="${build.deploy}/jbossweb-tomcat6.deployer/server.xml"/>
+    <copy todir="${build.deploy}/jbossweb-tomcat6.deployer">
       <fileset dir="${jboss.web.lib}">
         <include name="*.jar"/>
       </fileset>
     </copy>
     
-    <copy todir="${build.deploy}/jbossweb-tomcat6.sar"
+    <copy todir="${build.deploy}/jbossweb-tomcat6.deployer"
        file="${sun.jstl.lib}/jstl.jar" />        
 
-    <mkdir dir="${build.deploy}/jbossweb-tomcat6.sar/jsf-libs"/>
+    <mkdir dir="${build.deploy}/jbossweb-tomcat6.deployer/jsf-libs"/>
    
-    <copy todir="${build.deploy}/jbossweb-tomcat6.sar/jsf-libs">        
+    <copy todir="${build.deploy}/jbossweb-tomcat6.deployer/jsf-libs">        
        <fileset dir="${sun.jsf.lib}">           
           <include name="*.jar" />
        </fileset>
     </copy>
 
     <!-- jar for jsf integration classes -->
-    <jar jarfile="${build.deploy}/jbossweb-tomcat6.sar/jsf-libs/jboss-faces.jar">
+    <jar jarfile="${build.deploy}/jbossweb-tomcat6.deployer/jsf-libs/jboss-faces.jar">
       <fileset dir="${build.classes}">
          <include name="org/jboss/web/jsf/integration/**"/>
       </fileset>
     </jar>
 
-    <jar jarfile="${build.deploy}/jbossweb-tomcat6.sar/tomcat6-service.jar"
+    <jar jarfile="${build.deploy}/jbossweb-tomcat6.deployer/tomcat6-service.jar"
       manifest="${build.etc}/default.mf">
       <!-- The service classes -->
       <fileset dir="${build.classes}">
@@ -269,11 +270,6 @@
         <include name="org/jboss/**/*.properties"/>
       </fileset>
     </jar>
-    <copy todir="${build.deploy}/jbossweb-tomcat6.sar">
-      <fileset dir="${source.webapps}">
-         <exclude name="jboss-faces.war/**"/>
-      </fileset>
-    </copy>
 
      <!-- jar for fine grained aop -->
      <!-- package in .aop. This is used for fine-grained replication -->
@@ -288,7 +284,7 @@
      </jar>
      
     <!-- jboss-web-metamodel.jar -->
-    <jar jarfile="${build.deploy}/jbossweb-tomcat6.sar/jboss-web-metamodel.jar">
+    <jar jarfile="${build.deploy}/jbossweb-tomcat6.deployer/jboss-web-metamodel.jar">
       <fileset dir="${build.classes}">
         <include name="org/jboss/web/metamodel/**"/>
       </fileset>    

Added: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/DeployerConfig.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/DeployerConfig.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/DeployerConfig.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -0,0 +1,352 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.tc6.deployers; 
+
+import javax.management.ObjectName;
+ 
+import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
+
+/**
+ * The tomcat war deployer configuration passed in from the web container.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 56125 $
+ */
+public class DeployerConfig
+{
+   /**
+    * The tomcat sar class loader
+    */
+   private ClassLoader serviceClassLoader;
+   /**
+    * The domain used for the tomcat mbeans
+    */
+   private String catalinaDomain = "Catalina";
+
+   /**
+    * The fully qualified name of the class that will be used for session
+    * management if <tt>distributable</tt> is set to true.
+    */
+   private String managerClass = "org.jboss.web.tomcat.tc6.session.JBossManager";
+
+   /**
+    * JMX Object name of the TreeCache MBean. Used by JBossCacheManager
+    */
+   private String cacheName = "jboss.cache:service=TreeCache";
+
+   /**
+    * The web context class to create
+    */
+   private String contextClassName;
+   /**
+    * The parent class loader first model flag
+    */
+   private boolean java2ClassLoadingCompliance = false;
+   /**
+    * A flag indicating if war archives should be unpacked
+    */
+   private boolean unpackWars = true;
+   /**
+    * If true, ejb-links that don't resolve don't cause an error
+    * (fallback to jndi-name)
+    */
+   private boolean lenientEjbLink = false;
+   /**
+    * The tomcat service JMX object name
+    */
+   private ObjectName serviceName;
+   /**
+    * The catalina debug level
+    */
+   private int debugLevel;
+   /**
+    * A flag indicating if the JBoss UCL should be used
+    */
+   private boolean useJBossWebLoader = true;
+   /**
+    * A flag indicating if the working dir for a war deployment should be
+    * delete when the war is undeployed.
+    */
+   private boolean deleteWorkDirs = true;
+   /**
+    * Which snapshot mode should be used in clustered environment?
+    * Default: instant
+    */
+   private String snapshotMode = "instant"; // instant or interval
+   /**
+    * With IntervalSnapshotManager use this interval (in ms) for snapshotting
+    */
+   private int snapshotInterval = 1000;
+
+   /**
+    * Should the clustering code use caching or not?
+    */
+   private boolean useLocalCache;
+
+   /**
+    * Whether to use MOD_JK(2) for sticky session combined with JvmRoute. If set to true,
+    * it will insert a JvmRouteFilter to intercept every request and replace the JvmRoute
+    * if it detects a failover.
+    */
+   private boolean useJK = false;
+
+   /**
+    * Get the request attribute name under which the JAAS Subject is store
+    */
+   private String subjectAttributeName = null;
+   /**
+    * The default security-domain name to use
+    */
+   private String defaultSecurityDomain;
+   /** Package names that should be ignored for class loading */
+   private String[] filteredPackages;
+
+   /**
+    * Flag indicating whether web-app specific context xmls may set the privileged flag.
+    */
+   private boolean allowSelfPrivilegedWebApps = false;
+   /** The service used to flush authentication cache on session invalidation. */
+   private JaasSecurityManagerServiceMBean secMgrService;  
+   
+   public ClassLoader getServiceClassLoader()
+   {
+      return serviceClassLoader;
+   }
+
+   public void setServiceClassLoader(ClassLoader serviceClassLoader)
+   {
+      this.serviceClassLoader = serviceClassLoader;
+   }
+
+   public String getManagerClass()
+   {
+      return managerClass;
+   }
+
+   public void setManagerClass(String managerClass)
+   {
+      this.managerClass = managerClass;
+   }
+
+   public String getCacheName()
+   {
+      return cacheName;
+   }
+
+   public void setCacheName(String cacheName)
+   {
+      this.cacheName = cacheName;
+   }
+
+   public String getCatalinaDomain()
+   {
+      return catalinaDomain;
+   }
+
+   public void setCatalinaDomain(String catalinaDomain)
+   {
+      this.catalinaDomain = catalinaDomain;
+   }
+
+   public String getContextClassName()
+   {
+      return contextClassName;
+   }
+
+   public void setContextClassName(String contextClassName)
+   {
+      this.contextClassName = contextClassName;
+   }
+
+   public boolean isJava2ClassLoadingCompliance()
+   {
+      return java2ClassLoadingCompliance;
+   }
+
+   public void setJava2ClassLoadingCompliance(boolean java2ClassLoadingCompliance)
+   {
+      this.java2ClassLoadingCompliance = java2ClassLoadingCompliance;
+   }
+
+   public boolean isUnpackWars()
+   {
+      return unpackWars;
+   }
+
+   public void setUnpackWars(boolean unpackWars)
+   {
+      this.unpackWars = unpackWars;
+   }
+
+   public boolean isLenientEjbLink()
+   {
+      return lenientEjbLink;
+   }
+
+   public void setLenientEjbLink(boolean lenientEjbLink)
+   {
+      this.lenientEjbLink = lenientEjbLink;
+   }
+
+   public ObjectName getServiceName()
+   {
+      return serviceName;
+   }
+
+   public void setServiceName(ObjectName serviceName)
+   {
+      this.serviceName = serviceName;
+   }
+
+   public int getDebugLevel()
+   {
+      return debugLevel;
+   }
+
+   public void setDebugLevel(int debugLevel)
+   {
+      this.debugLevel = debugLevel;
+   }
+
+   public boolean isUseJBossWebLoader()
+   {
+      return useJBossWebLoader;
+   }
+
+   public void setUseJBossWebLoader(boolean useJBossWebLoader)
+   {
+      this.useJBossWebLoader = useJBossWebLoader;
+   }
+
+   public boolean isDeleteWorkDirs()
+   {
+      return deleteWorkDirs;
+   }
+
+   public void setDeleteWorkDirs(boolean deleteWorkDirs)
+   {
+      this.deleteWorkDirs = deleteWorkDirs;
+   }
+
+   public String getSnapshotMode()
+   {
+      return snapshotMode;
+   }
+
+   public void setSnapshotMode(String snapshotMode)
+   {
+      this.snapshotMode = snapshotMode;
+   }
+
+   public int getSnapshotInterval()
+   {
+      return snapshotInterval;
+   }
+
+   public void setSnapshotInterval(int snapshotInterval)
+   {
+      this.snapshotInterval = snapshotInterval;
+   }
+
+   public boolean isUseLocalCache()
+   {
+      return useLocalCache;
+   }
+
+   public void setUseLocalCache(boolean useLocalCache)
+   {
+      this.useLocalCache = useLocalCache;
+   }
+
+   public boolean isUseJK()
+   {
+      return useJK;
+   }
+
+   public void setUseJK(boolean useJK)
+   {
+      this.useJK = useJK;
+   }
+
+   public String getSubjectAttributeName()
+   {
+      return subjectAttributeName;
+   }
+
+   public void setSubjectAttributeName(String subjectAttributeName)
+   {
+      this.subjectAttributeName = subjectAttributeName;
+   }
+
+   /**
+    * 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;
+   }
+
+   public boolean isAllowSelfPrivilegedWebApps()
+   {
+      return allowSelfPrivilegedWebApps;
+   }
+
+   public void setAllowSelfPrivilegedWebApps(boolean allowSelfPrivilegedWebApps)
+   {
+      this.allowSelfPrivilegedWebApps = allowSelfPrivilegedWebApps;
+   } 
+   
+   public JaasSecurityManagerServiceMBean getSecurityManagerService()
+   {
+      return secMgrService;
+   }
+   public void setSecurityManagerService(JaasSecurityManagerServiceMBean mgr)
+   {
+      this.secMgrService = mgr;
+   }
+
+   public String[] getFilteredPackages()
+   {
+      return filteredPackages;
+   }
+   public void setFilteredPackages(String[] filteredPackages)
+   {
+      this.filteredPackages = filteredPackages;
+   }  
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/DeployerConfig.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployer.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployer.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -0,0 +1,735 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.web.tomcat.tc6.deployers;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.security.jacc.PolicyContext;
+
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.connector.Connector;
+import org.apache.tomcat.util.modeler.Registry;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployment.SubDeployerExt;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
+import org.jboss.system.server.Server;
+import org.jboss.system.server.ServerImplMBean;
+import org.jboss.web.deployers.AbstractWarDeployer;
+import org.jboss.web.deployers.AbstractWarDeployment;
+import org.jboss.web.tomcat.security.HttpServletRequestPolicyContextHandler;
+import org.jboss.web.tomcat.tc6.session.SessionIDGenerator;
+
+
+/**
+ * An implementation of the AbstractWebContainer for the Jakarta TomcatDeployer
+ * servlet container. It has no code dependency on tomcat - only the new JMX
+ * model is used.
+ * <p/>
+ * TomcatDeployer is organized as a set of mbeans - just like jboss.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Costin Manolache
+ * @author Wonne.Keysers at realsoftware.be
+ * @author Dimitris.Andreadis at jboss.org
+ * @version $Revision: 56809 $
+ * @see org.jboss.web.deployers.AbstractWarDeployer
+ */
+public class TomcatDeployer extends AbstractWarDeployer
+   implements NotificationListener, TomcatDeployerMBean
+{
+   // Constants -----------------------------------------------------
+   public static final String NAME = "TomcatDeployer";
+
+   /**
+    * Default value for property <code>cacheName</code>. This name will be used by JBossCache exclusively
+    * for Tomcat clustering, e.g., session and sso replication.
+    */
+   public static final String DEFAULT_CACHE_NAME =
+      "jboss.cache:service=TomcatClusteringCache";
+
+   // XXX We could make this configurable - so it can support other containers
+   // that provide JMX-based deployment.
+   private String contextClassName =
+      "org.apache.catalina.core.StandardContext";
+
+   /**
+    * Configurable map of tomcat authenticators
+    * Keyed in by the http auth method that gets 
+    * plugged into the Context Config and then into the StandardContext 
+    */
+   private Properties authenticators = null;
+
+   /**
+    * Domain for tomcat6 mbeans
+    */
+   private String catalinaDomain = "Catalina";
+
+   /**
+    * ObjectName of a shared TreeCache used for clustered session replication
+    * and clustered single-sign-on
+    */
+   private String cacheName = DEFAULT_CACHE_NAME;
+
+   /**
+    * The fully qualified name of the class that will be used for session
+    * management if <tt>distributable</tt> is set to true.
+    */
+   protected String managerClass = "org.jboss.web.tomcat.tc6.session.JBossCacheManager";
+
+   /**
+    * With IntervalSnapshotManager use this interval (in ms)
+    * for snapshotting
+    */
+   private int snapshotInterval = 1000;
+
+   /**
+    * Which snapshot mode should be used in clustered environment?
+    * Default: instant
+    */
+   private String snapshotMode = "instant"; // instant or interval
+
+   /**
+    * Should the clustering code use a local cache for the sessions?
+    */
+   private boolean useLocalCache = true;
+
+   /**
+    * Whether we are using Apache MOD_JK(2) module or not
+    */
+   private boolean useJK = false;
+
+   /**
+    * A flag indicating if the JBoss Loader should be used
+    */
+   private boolean useJBossWebLoader = true;
+   
+   /**
+    * JBAS-3358: Work directory shouldn't be deleted on Context Destroy
+    */
+   private boolean deleteWorkDirOnContextDestroy = false;
+   
+   /**
+    * JBAS-2283: Provide custom header based auth support
+    */
+   private String httpHeaderForSSOAuth = null;
+   private String sessionCookieForSSOAuth = null;
+
+
+   /**
+    * The server xml configuration file name
+    */
+   private String serverConfigFile = "server.xml";
+
+   /**
+    * Get the request attribute name under which the JAAS Subject is store
+    */
+   private String subjectAttributeName = null;
+
+   /**
+    * Flag indicating whether web-app specific context xmls may set the privileged flag.
+    */
+   private boolean allowSelfPrivilegedWebApps = false;
+
+   /** The service used to flush authentication cache on session invalidation. */
+   private JaasSecurityManagerServiceMBean secMgrService;  
+   
+   /** */
+   private String[] filteredPackages;
+
+   /** Hold a proxy reference to myself, used when registering to MainDeployer */
+   private SubDeployerExt thisProxy;
+
+   public TomcatDeployer()
+   {
+   }
+
+   public String getName()
+   {
+      return NAME;
+   }
+
+
+   public String getManagerClass()
+   {
+      return managerClass;
+   }
+
+   public void setManagerClass(String managerClass)
+   {
+      this.managerClass = managerClass;
+   }
+
+
+   public String getDomain()
+   {
+      return this.catalinaDomain;
+   }
+
+   public Properties getAuthenticators()
+   {
+      return this.authenticators;
+   }
+
+   public void setAuthenticators(Properties prop)
+   {
+      this.authenticators = prop;
+      log.debug("Passed set of authenticators=" + prop);
+   }
+
+   /**
+    * The most important atteribute - defines the managed domain.
+    * A catalina instance (engine) corresponds to a JMX domain, that's
+    * how we know where to deploy webapps.
+    *
+    * @param catalinaDomain the domain portion of the JMX ObjectNames
+    */
+   public void setDomain(String catalinaDomain)
+   {
+      this.catalinaDomain = catalinaDomain;
+   }
+
+   public void setContextMBeanCode(String className)
+   {
+      this.contextClassName = className;
+   }
+
+   public String getContextMBeanCode()
+   {
+      return contextClassName;
+   }
+
+   /**
+    * Set the snapshot interval in milliseconds for snapshot mode = interval
+    */
+   public void setSnapshotInterval(int interval)
+   {
+      this.snapshotInterval = interval;
+   }
+
+   /**
+    * Get the snapshot interval
+    */
+   public int getSnapshotInterval()
+   {
+      return this.snapshotInterval;
+   }
+
+   /**
+    * Set the snapshot mode. Currently supported: instant or interval
+    */
+   public void setSnapshotMode(String mode)
+   {
+      this.snapshotMode = mode;
+   }
+
+   /**
+    * Get the snapshot mode
+    */
+   public String getSnapshotMode()
+   {
+      return this.snapshotMode;
+   }
+
+   /**
+    * Gets the JMX object name of a shared TreeCache to be used for clustered
+    * single-sign-on.
+    *
+    * @see #DEFAULT_CACHE_NAME
+    * @see org.jboss.web.tomcat.tc6.sso.TreeCacheSSOClusterManager
+    */
+   public String getCacheName()
+   {
+      return cacheName;
+   }
+
+   /**
+    * Gets the JMX object name of a shared TreeCache to be used for clustered
+    * single-sign-on.
+    * <p/>
+    * <b>NOTE:</b> TreeCache must be deployed before this service.
+    *
+    * @see #DEFAULT_CACHE_NAME
+    * @see org.jboss.web.tomcat.tc6.sso.TreeCacheSSOClusterManager
+    */
+   public void setCacheName(String cacheName)
+   {
+      this.cacheName = cacheName;
+   }
+
+   public boolean isUseLocalCache()
+   {
+      return useLocalCache;
+   }
+
+   public void setUseLocalCache(boolean useLocalCache)
+   {
+      this.useLocalCache = useLocalCache;
+   }
+
+   public boolean isUseJK()
+   {
+      return useJK;
+   }
+
+   public void setUseJK(boolean useJK)
+   {
+      this.useJK = useJK;
+   } 
+
+   public boolean getDeleteWorkDirOnContextDestroy()
+   {
+      return deleteWorkDirOnContextDestroy;
+   }
+
+   public void setDeleteWorkDirOnContextDestroy(boolean deleteFlag)
+   {
+      this.deleteWorkDirOnContextDestroy = deleteFlag;
+   } 
+   
+   public String getHttpHeaderForSSOAuth()
+   {
+      return httpHeaderForSSOAuth;
+   }
+    
+   public void setHttpHeaderForSSOAuth(String httpHeader)
+   {
+       this.httpHeaderForSSOAuth = httpHeader;
+   }
+   
+   public String getSessionCookieForSSOAuth()
+   {
+       return sessionCookieForSSOAuth;
+   }
+   
+   public void setSessionCookieForSSOAuth(String sessionC)
+   {
+      this.sessionCookieForSSOAuth = sessionC;
+   }
+   
+   /**
+    * The SessionIdAlphabet is the set of characters used to create a session Id
+    */
+   public void setSessionIdAlphabet(String sessionIdAlphabet)
+   {
+       SessionIDGenerator.getInstance().setSessionIdAlphabet(sessionIdAlphabet);
+   }
+
+   /**
+    * The SessionIdAlphabet is the set of characters used to create a session Id
+    */
+   public String getSessionIdAlphabet()
+   {
+       return SessionIDGenerator.getInstance().getSessionIdAlphabet();
+   }
+
+   public boolean getUseJBossWebLoader()
+   {
+      return useJBossWebLoader;
+   }
+
+   public void setUseJBossWebLoader(boolean flag)
+   {
+      this.useJBossWebLoader = flag;
+   }
+
+   public String getConfigFile()
+   {
+      return serverConfigFile;
+   }
+
+   public void setConfigFile(String configFile)
+   {
+      this.serverConfigFile = configFile;
+   }
+
+   public String getSubjectAttributeName()
+   {
+      return this.subjectAttributeName;
+   }
+
+   public void setSubjectAttributeName(String name)
+   {
+      this.subjectAttributeName = name;
+   }
+
+   public boolean isAllowSelfPrivilegedWebApps()
+   {
+      return allowSelfPrivilegedWebApps;
+   }
+
+   public void setAllowSelfPrivilegedWebApps(boolean allowSelfPrivilegedWebApps)
+   {
+      this.allowSelfPrivilegedWebApps = allowSelfPrivilegedWebApps;
+   } 
+
+   public void setSecurityManagerService(JaasSecurityManagerServiceMBean mgr)
+   {
+      this.secMgrService = mgr;
+   }
+
+   public String[] getFilteredPackages()
+   {
+      return filteredPackages;
+   }
+   public void setFilteredPackages(String[] pkgs)
+   {
+      this.filteredPackages = pkgs;
+   }
+
+   public void start()
+      throws Exception
+   {
+      super.start();
+
+      log.debug("Starting tomcat deployer");
+      MBeanServer server = super.getServer();
+      System.setProperty("catalina.ext.dirs",
+         (System.getProperty("jboss.server.home.dir")
+         + File.separator + "lib"));
+
+      String objectNameS = catalinaDomain + ":type=server";
+      ObjectName objectName = new ObjectName(objectNameS);
+
+      // Set the modeler Registry MBeanServer to the that of the tomcat service
+      Registry.getRegistry().setMBeanServer(server);
+
+      Registry.getRegistry().registerComponent(Class.forName("org.apache.catalina.startup.Catalina").newInstance(), 
+              objectName, "org.apache.catalina.startup.Catalina");
+      /*
+      server.createMBean("org.apache.tomcat.util.modeler.BaseModelMBean",
+         objectName,
+         new Object[]{"org.apache.catalina.startup.Catalina"},
+         new String[]{"java.lang.String"});
+         */
+
+      server.setAttribute(objectName, new Attribute
+         ("catalinaHome",
+            System.getProperty("jboss.server.home.dir")));
+      server.setAttribute(objectName, new Attribute
+         ("configFile", serverConfigFile));
+      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)));
+
+      server.invoke(objectName, "create", new Object[]{},
+         new String[]{});
+
+      server.invoke(objectName, "start", new Object[]{},
+         new String[]{});
+
+      // Configure any SingleSignOn valves      
+
+      ObjectName ssoQuery = new ObjectName(catalinaDomain + ":type=Valve,*");
+      Iterator iterator = server.queryMBeans(ssoQuery, null).iterator();
+      while (iterator.hasNext())
+      {
+         ObjectName ssoObjectName =
+            ((ObjectInstance) iterator.next()).getObjectName();
+         String name = ssoObjectName.getKeyProperty("name");
+
+         /* Ensure that the SingleSignOn valve requires that each
+            request be reauthenticated to the security mgr. Should not
+            be neccessary now that we cache the principal in the session.
+         if ((name != null) && (name.indexOf("SingleSignOn") >= 0))
+         {
+            log.info("Turning on reauthentication of each request on " +
+                     ssoObjectName);
+            server.setAttribute(ssoObjectName, new Attribute
+               ("requireReauthentication", Boolean.TRUE));
+         }
+         */
+
+         // If the valve is a ClusteredSingleSignOn and we have a shared
+         // TreeCache configured, configure the valve to use the shared one
+         if (cacheName != null && "ClusteredSingleSignOn".equals(name))
+         {
+            String tcName = (String) server.getAttribute(ssoObjectName,
+               "treeCacheName");
+            tcName = (tcName != null ? tcName : DEFAULT_CACHE_NAME);
+            ObjectName ssoCacheName = new ObjectName(tcName);
+            // Only override if the valve's cacheName property was not
+            // explicitly set in server.xml to a non-default value
+            if (ssoCacheName.equals(new ObjectName(DEFAULT_CACHE_NAME)))
+            {
+               log.info("Setting the cache name to " + cacheName +
+                  " on " + ssoObjectName);
+               server.setAttribute(ssoObjectName,
+                  new Attribute("treeCacheName", cacheName));
+            }
+         }
+      }
+
+      // Register the web container JACC PolicyContextHandlers
+      HttpServletRequestPolicyContextHandler handler = new HttpServletRequestPolicyContextHandler();
+      PolicyContext.registerHandler(HttpServletRequestPolicyContextHandler.WEB_REQUEST_KEY,
+         handler, true);
+
+      // If we are hot-deployed *after* the overall server is started
+      // 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");
+      if (started.booleanValue() == true)
+      {
+         log.debug("Server '" + ServerImplMBean.OBJECT_NAME +
+               "' already started, starting connectors now");
+
+         startConnectors();
+      }
+      else
+      {
+         // Register for notification of the overall server startup
+         log.debug("Server '" + ServerImplMBean.OBJECT_NAME +
+               "' not started, registering for start-up notification");
+
+         server.addNotificationListener(ServerImplMBean.OBJECT_NAME, this, null, null);
+      }
+   }
+
+
+   public void stop()
+      throws Exception
+   {
+      MBeanServer server = super.getServer();
+      String objectNameS = catalinaDomain + ":type=server";
+      ObjectName objectName = new ObjectName(objectNameS);
+
+      server.invoke(objectName, "stop", new Object[]{},
+         new String[]{});
+
+      server.invoke(objectName, "destroy", new Object[]{},
+         new String[]{});
+
+      server.unregisterMBean(objectName);
+
+      MBeanServer server2 = server;
+
+      // Unregister any remaining jboss.web or Catalina MBeans
+      ObjectName queryObjectName = new ObjectName
+         (catalinaDomain + ":*");
+      Iterator iterator =
+         server2.queryMBeans(queryObjectName, null).iterator();
+      while (iterator.hasNext())
+      {
+         ObjectInstance oi = (ObjectInstance) iterator.next();
+         ObjectName toRemove = oi.getObjectName();
+         // Exception: Don't unregister the service right now
+         if (!"WebServer".equals(toRemove.getKeyProperty("service")))
+         {
+            if (server2.isRegistered(toRemove))
+            {
+               server2.unregisterMBean(toRemove);
+            }
+         }
+      }
+      queryObjectName = new ObjectName("Catalina:*");
+      iterator = server2.queryMBeans(queryObjectName, null).iterator();
+      while (iterator.hasNext())
+      {
+         ObjectInstance oi = (ObjectInstance) iterator.next();
+         ObjectName name = oi.getObjectName();
+         server2.unregisterMBean(name);
+      }
+      super.stop();
+   }
+
+   public void startConnectors() throws Exception
+   {
+      MBeanServer server = super.getServer();
+      ObjectName service = new ObjectName(catalinaDomain + ":type=Service,serviceName=jboss.web");
+      Object[] args = {};
+      String[] sig = {};
+      Connector[] connectors = (Connector[]) server.invoke(service,
+         "findConnectors", args, sig);
+      for (int n = 0; n < connectors.length; n++)
+      {
+         Lifecycle lc = (Lifecycle) connectors[n];
+         lc.start();
+      }
+      /* TODO:
+      // Notify listeners that connectors have started processing requests
+      sendNotification(new Notification(TOMCAT_CONNECTORS_STARTED,
+            this, getNextNotificationSequenceNumber()));
+      */
+   }
+
+   public void stopConnectors() throws Exception
+   {
+      MBeanServer server = super.getServer();
+      ObjectName service = new ObjectName(catalinaDomain + ":type=Service,serviceName=jboss.web");
+      Object[] args = {};
+      String[] sig = {};
+      Connector[] connectors = (Connector[]) server.invoke(service,
+         "findConnectors", args, sig);
+      for (int n = 0; n < connectors.length; n++)
+      {
+         Lifecycle lc = (Lifecycle) connectors[n];
+         lc.stop();
+      }
+   }
+
+   public void handleNotification(Notification msg, Object handback)
+   {
+      String type = msg.getType();
+      if (type.equals(Server.START_NOTIFICATION_TYPE))
+      {
+         log.debug("Saw " + type + " notification, starting connectors");
+         try
+         {
+            startConnectors();
+         }
+         catch (Exception e)
+         {
+            log.warn("Failed to startConnectors", e);
+         }
+      }
+   }
+
+   /**
+    * A trival extension of URLClassLoader that uses an empty URL[] as its
+    * classpath so that all work is delegated to its parent.
+    */
+   static class ENCLoader extends URLClassLoader
+   {
+      private boolean parentFirst;
+
+      ENCLoader(URL[] urls, ClassLoader parent, boolean parentFirst)
+      {
+         super(urls, parent);
+         this.parentFirst = parentFirst;
+      }
+
+      protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
+      {
+         if (parentFirst) return super.loadClass(name, resolve);
+         try
+         {
+            Class clazz = findClass(name);
+            if (resolve) {
+                resolveClass(clazz);
+            }
+            return clazz;
+         }
+         catch (ClassNotFoundException e)
+         {
+            return getParent().loadClass(name);
+         }
+      }
+
+   }
+
+   public static ClassLoader getTmpLoader(URL warURL, ClassLoader parent, boolean parentFirst) throws Exception
+   {
+
+      String path = warURL.getFile();
+      ArrayList<URL> list = new ArrayList<URL>();
+      File classesDir = new File(path, "WEB-INF/classes");
+      if (classesDir.exists())
+      {
+         list.add(classesDir.toURL());
+      }
+      File libDir = new File(path, "WEB-INF/lib");
+      if (libDir.exists())
+      {
+         File[] jars = libDir.listFiles();
+         int length = jars != null ? jars.length : 0;
+         for (int j = 0; j < length; j++)
+         {
+            File jar = jars[j];
+            if(jar.getAbsolutePath().endsWith(".jar"))
+            {
+               list.add(jar.toURL());
+            }
+         }
+      }
+      ENCLoader loader = new ENCLoader(list.toArray(new URL[list.size()]), parent, parentFirst);
+      return loader;
+
+   }
+
+   /**
+    * Create a tomcat war deployment for the deployment unit/metaData.
+    * @param unit
+    * @param metaData
+    */
+   @Override
+   public AbstractWarDeployment getDeployment(DeploymentUnit unit, WebMetaData metaData)
+      throws Exception
+   {
+      TomcatDeployment deployment = new TomcatDeployment();
+      DeployerConfig config = new DeployerConfig();
+      config.setDefaultSecurityDomain(this.defaultSecurityDomain);
+      config.setSubjectAttributeName(this.subjectAttributeName);
+      config.setServiceClassLoader(getClass().getClassLoader());
+      config.setManagerClass(this.managerClass);
+      config.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
+      config.setUnpackWars(this.unpackWars);
+      config.setLenientEjbLink(this.lenientEjbLink);
+      config.setCatalinaDomain(catalinaDomain);
+      config.setContextClassName(contextClassName);
+      config.setServiceName(null);
+      config.setSnapshotInterval(this.snapshotInterval);
+      config.setSnapshotMode(this.snapshotMode);
+      config.setUseLocalCache(this.useLocalCache);
+      config.setUseJK(this.useJK);
+      config.setSubjectAttributeName(this.subjectAttributeName);
+      config.setUseJBossWebLoader(this.useJBossWebLoader);
+      config.setAllowSelfPrivilegedWebApps(this.allowSelfPrivilegedWebApps); 
+      config.setSecurityManagerService(this.secMgrService);
+      config.setFilteredPackages(filteredPackages);
+      deployment.setServer(super.getServer());
+      deployment.init(config);
+
+      /*
+      // new JavaEE5 stuff
+      WebMetaData metadata = (WebMetaData)di.metaData;
+      TomcatInjectionContainer ic = new TomcatInjectionContainer(di);
+      URL warURL = di.localUrl != null ? di.localUrl : di.url;
+      ClassLoader parent = di.ucl;
+      if (di.parent != null) parent = di.parent.ucl;
+      ClassLoader tmpLoader = getTmpLoader(warURL, parent, java2ClassLoadingCompliance);
+      ic.setClassLoader(tmpLoader);
+
+      ic.processMetadata();
+      JmxDependencyPolicy dependencyPolicy = (JmxDependencyPolicy)ic.getDependencyPolicy();
+      metadata.setDepends(dependencyPolicy.getDependencies(metadata.getDepends()));
+      */
+      return deployment;
+   }
+}


Property changes on: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployer.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployerMBean.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployerMBean.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployerMBean.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -0,0 +1,216 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.web.tomcat.tc6.deployers;
+
+import org.jboss.web.deployers.AbstractWarDeployerMBean;
+import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
+
+/**
+ * An implementation of the AbstractWebContainer for the Jakarta Tomcat5
+ * servlet container. It has no code dependency on tomcat - only the new JMX
+ * model is used.
+ * <p/>
+ * Tomcat5 is organized as a set of mbeans - just like jboss.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Costin Manolache
+ * @version $Revision: 45726 $
+ * @see AbstractWebContainerMBean
+ */
+public interface TomcatDeployerMBean extends AbstractWarDeployerMBean
+{
+   /** JMX notification type to signal after-start connector event */ 
+   public final String TOMCAT_CONNECTORS_STARTED  = "jboss.tomcat.connectors.started";
+   
+   /**
+    * @return the jmx domain for the tomcat management mbeans
+    */
+   public String getDomain();
+
+   /**
+    * The most important attribute - defines the managed domain.
+    * A catalina instance (engine) corresponds to a JMX domain, that's
+    * how we know where to deploy webapps.
+    *
+    * @param domainName the jmx domain under which tc registers
+    */
+   public void setDomain(String domainName);
+
+   /**
+    * Set the snapshot mode in a clustered environment
+    */
+   public void setSnapshotMode(String mode);
+
+   /**
+    * Get the snapshot mode in a clustered environment
+    */
+   public String getSnapshotMode();
+
+   /**
+    * Set the snapshot interval in ms for the interval snapshot mode
+    */
+   public void setSnapshotInterval(int interval);
+
+   /**
+    * Get the snapshot interval
+    */
+   public int getSnapshotInterval();
+
+   /**
+    * Get the clustering code cache behaviour
+    */
+   public boolean isUseLocalCache();
+
+   /**
+    * Set the clustering code cache behaviour
+    */
+   public void setUseLocalCache(boolean useLocalCache);
+
+   /**
+    * Get the clustering code failover behaviour whether MOD_JK(2) is used or not.
+    */
+   public boolean isUseJK();
+
+   /**
+    * Set the clustering code failover behaviour whether MOD_JK(2) is used or not.
+    */
+   public void setUseJK(boolean useJK);
+
+   /**
+    * The SessionIdAlphabet is the set of characters used to create a session Id
+    */
+   public void setSessionIdAlphabet(String sessionIdAlphabet);
+
+   /**
+    * The SessionIdAlphabet is the set of characters used to create a session Id
+    */
+   public String getSessionIdAlphabet();
+   
+   /**
+    * Gets the JMX object name of a shared TreeCache to be used for clustered
+    * single-sign-on.
+    *
+    * @see org.jboss.web.tomcat.tc6.sso.TreeCacheSSOClusterManager
+    */
+   public String getCacheName();
+
+   /**
+    * Gets the JMX object name of a shared TreeCache to be used for clustered
+    * single-sign-on.
+    * <p/>
+    * <b>NOTE:</b> TreeCache must be deployed before this service.
+    *
+    * @see org.jboss.web.tomcat.tc6.sso.TreeCacheSSOClusterManager
+    */
+   public void setCacheName(String cacheName);
+
+   /**
+    * Get the JBoss UCL use flag
+    */
+   public boolean getUseJBossWebLoader();
+
+   /**
+    * Set the JBoss UCL use flag
+    */
+   public void setUseJBossWebLoader(boolean flag);
+
+   public String getManagerClass();
+
+   public void setManagerClass(String managerClass);
+
+   /** */
+   public String getContextMBeanCode();
+
+   /** */
+   public void setContextMBeanCode(String className);
+
+   /**
+    * Get the name of the external tomcat server configuration file.
+    *
+    * @return the config file name, server.xml for example
+    */
+   public String getConfigFile();
+
+   /**
+    * Set the name of the external tomcat server configuration file.
+    *
+    * @param configFile - the config file name, server.xml for example
+    */
+   public void setConfigFile(String configFile);
+
+   /**
+    * Get the request attribute name under which the JAAS Subject is store
+    */
+   public String getSubjectAttributeName();
+
+   /**
+    * Set the request attribute name under which the JAAS Subject will be
+    * stored when running with a security mgr that supports JAAS. If this is
+    * empty then the Subject will not be store in the request.
+    *
+    * @param name the HttpServletRequest attribute name to store the Subject
+    */
+   public void setSubjectAttributeName(String name);
+
+   /**
+    * Start all connectors of the Domain + ":type=Service,serviceName=jboss.web"
+    * service.
+    *
+    * @throws Exception
+    */
+   public void startConnectors() throws Exception;
+
+   /**
+    * Stop all connectors of the Domain + ":type=Service,serviceName=jboss.web"
+    * service.
+    *
+    * @throws Exception
+    */
+   public void stopConnectors() throws Exception;
+
+   /**
+    * Get whether web-apps are able to control the privileged flag
+    */
+   public boolean isAllowSelfPrivilegedWebApps();
+
+   /**
+    * Set whether web-apps are able to control the privileged flag
+    */
+   public void setAllowSelfPrivilegedWebApps(boolean flag);
+
+   /** Set the SecurityManagerService binding. This is used to flush any
+    * associated authentication cache on session invalidation.
+    * @param mgr the JaasSecurityManagerServiceMBean
+    */ 
+   public void setSecurityManagerService(JaasSecurityManagerServiceMBean mgr);
+
+   /**
+    * 
+    * @return
+    */ 
+   public String[] getFilteredPackages();
+   /**
+    * 
+    * @param pkgs
+    */ 
+   public void setFilteredPackages(String[] pkgs);
+}

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java	2006-10-14 06:13:26 UTC (rev 57669)
@@ -1,36 +1,34 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.web.tomcat.tc6.deployers;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
 import java.net.MalformedURLException;
-import java.net.URLClassLoader;
+import java.net.URL;
 import java.security.CodeSource;
 import java.security.cert.Certificate;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -39,61 +37,40 @@
 import java.util.zip.ZipFile;
 
 import javax.management.Attribute;
-import javax.management.JMException;
 import javax.management.MBeanServer;
-import javax.management.ObjectInstance;
 import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.LinkRef;
-import javax.naming.NamingException;
 
 import org.apache.catalina.Loader;
+import org.apache.tomcat.util.modeler.Registry;
 import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.ejb.EjbUtil;
 import org.jboss.logging.Logger;
-import org.jboss.metadata.EjbLocalRefMetaData;
-import org.jboss.metadata.EjbRefMetaData;
-import org.jboss.metadata.EnvEntryMetaData;
-import org.jboss.metadata.MessageDestinationMetaData;
-import org.jboss.metadata.MessageDestinationRefMetaData;
-import org.jboss.metadata.ResourceEnvRefMetaData;
-import org.jboss.metadata.ResourceRefMetaData;
 import org.jboss.metadata.WebMetaData;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
 import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.naming.NonSerializableFactory;
-import org.jboss.util.naming.Util;
 import org.jboss.security.AuthorizationManager;
 import org.jboss.security.authorization.PolicyRegistration;
-import org.jboss.security.plugins.AuthorizationManagerServiceMBean;
-import org.jboss.web.AbstractWebContainer;
-import org.jboss.web.AbstractWebDeployer;
 import org.jboss.web.WebApplication;
+import org.jboss.web.deployers.AbstractWarDeployment;
 import org.jboss.web.tomcat.security.JaccContextValve;
 import org.jboss.web.tomcat.security.RunAsListener;
 import org.jboss.web.tomcat.security.SecurityAssociationValve;
-import org.jboss.web.tomcat.tc6.DeployerConfig;
 import org.jboss.web.tomcat.tc6.WebAppLoader;
 import org.jboss.web.tomcat.tc6.WebCtxLoader;
 import org.jboss.web.tomcat.tc6.session.AbstractJBossManager;
 import org.jboss.web.tomcat.tc6.session.ClusteringNotSupportedException;
 import org.jboss.web.tomcat.tc6.session.JBossCacheManager;
-import org.jboss.webservice.WebServiceClientHandler;
 import org.omg.CORBA.ORB;
-import org.apache.tomcat.util.modeler.Registry;
 
 /**
  * A tomcat web application deployment.
- *
+ * 
  * @author Scott.Stark at jboss.org
  * @author Costin Manolache
  * @version $Revision: 56605 $
  */
-public class TomcatDeployment 
+public class TomcatDeployment extends AbstractWarDeployment
 {
    private static final Logger log = Logger.getLogger(TomcatDeployment.class);
+
    /**
     * The name of the war level context configuration descriptor
     */
@@ -104,26 +81,13 @@
     */
    private static final String XACML_POLICY_FILE = "WEB-INF/jboss-xacml-policy.xml";
 
-   private WebApplication warInfo;
    private DeployerConfig config;
-   private String[] javaVMs =
-      {" jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost"};
+   private String[] javaVMs = { " jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost" };
    private String serverName = "jboss";
-   private String hostName;
-   private String warUrl;
+   private HashMap vhostToHostNames = new HashMap();
    private ORB orb = null;
-   private MBeanServer server;
+   // private TomcatInjectionContainer injectionContainer;
 
-   //private TomcatInjectionContainer injectionContainer;
-
-   public TomcatDeployment(WebApplication warInfo, String hostName, String warUrl)
-   {
-      this.warInfo = warInfo;
-      this.hostName = hostName;
-      this.warUrl = warUrl;
-      this.config = (DeployerConfig) warInfo.getDeployerConfig();
-   }
-
    public ORB getORB()
    {
       return orb;
@@ -133,20 +97,36 @@
       this.orb = orb;
    }
 
-   public void start()
-      throws Exception
+   @Override
+   public void init(Object config) throws Exception
    {
-      // TODO: Need to remove the dependency on MBeanServer
-      server = MBeanServerLocator.locateJBoss();
-      performDeployInternal();
+      this.config = (DeployerConfig) config;
    }
-   public void stop()
-   {  
-      server = null;
+
+   @Override
+   protected void performDeploy(WebApplication warInfo, String warUrl)
+         throws Exception
+   {
+      WebMetaData metaData = warInfo.getMetaData();
+      String hostName = null;
+      // Get any jboss-web/virtual-hosts
+      Iterator vhostNames = metaData.getVirtualHosts();
+      // Map the virtual hosts onto the configured hosts
+      Iterator hostNames = mapVirtualHosts(vhostNames);
+      if (hostNames.hasNext())
+      {
+         hostName = hostNames.next().toString();
+      }
+      performDeployInternal(hostName, warInfo, warUrl);
+      while (hostNames.hasNext())
+      {
+         String additionalHostName = hostNames.next().toString();
+         performDeployInternal(additionalHostName, warInfo, warUrl);
+      }
    }
 
-   protected void performDeployInternal()
-      throws Exception
+   protected void performDeployInternal(String hostName,
+         WebApplication warInfo, String warUrl) throws Exception
    {
 
       WebMetaData metaData = warInfo.getMetaData();
@@ -158,82 +138,81 @@
          metaData.setContextRoot(ctxPath);
       }
 
-      log.info("deploy, ctxPath=" + ctxPath + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
+      log.info("deploy, ctxPath=" + ctxPath + ", warUrl="
+            + shortWarUrlFromServerHome(warUrl));
 
       URL url = new URL(warUrl);
 
       ClassLoader loader = Thread.currentThread().getContextClassLoader();
-      // injectionContainer = new TomcatInjectionContainer(webAppParser, appInfo);
+      // injectionContainer = new TomcatInjectionContainer(webAppParser,
+      // appInfo);
       Loader webLoader = getWebLoader(loader, url);
 
       warInfo.setName(url.getPath());
       warInfo.setClassLoader(loader);
       warInfo.setURL(url);
 
-      String objectNameS = warInfo.getDomain()
-         + ":j2eeType=WebModule,name=//" +
-         ((hostName == null) ? "localhost" : hostName)
-         + ctxPath + ",J2EEApplication=none,J2EEServer=none";
+      String objectNameS = warInfo.getDomain() + ":j2eeType=WebModule,name=//"
+            + ((hostName == null) ? "localhost" : hostName) + ctxPath
+            + ",J2EEApplication=none,J2EEServer=none";
 
       ObjectName objectName = new ObjectName(objectNameS);
 
       /*
-      server.createMBean("org.apache.tomcat.util.modeler.BaseModelMBean",
-         objectName, new Object[]{warInfo.getContextClassName()},
-         new String[]{"java.lang.String"});
-         */
+       * server.createMBean("org.apache.tomcat.util.modeler.BaseModelMBean",
+       * objectName, new Object[]{warInfo.getContextClassName()}, new
+       * String[]{"java.lang.String"});
+       */
       String contextClassName = config.getContextClassName();
-      Registry.getRegistry().registerComponent(Class.forName(contextClassName).newInstance(), 
-              objectName, contextClassName);
+      Registry.getRegistry().registerComponent(
+            Class.forName(contextClassName).newInstance(), objectName,
+            contextClassName);
 
       // Find and set warInfo file on the context
       // If WAR is packed, expand warInfo file to temp folder
       String ctxConfig = null;
       try
       {
+         // TODO: this should be input metadata
          ctxConfig = findConfig(url);
-      }
-      catch (IOException e)
+      } catch (IOException e)
       {
          log.debug("No " + CONTEXT_CONFIG_FILE + " in " + url, e);
       }
 
       /*
-      if (injectionContainer != null)
-      {
-        server.setAttribute(objectName, new Attribute("annotationProcessor", injectionContainer));
-      }
-      */
+       * TODO:
+       * if (injectionContainer != null) { server.setAttribute(objectName, new
+       * Attribute("annotationProcessor", injectionContainer)); }
+       */
 
       server.setAttribute(objectName, new Attribute("docBase", url.getFile()));
 
       server.setAttribute(objectName, new Attribute("configFile", ctxConfig));
 
-      server.setAttribute(objectName, new Attribute
-         ("defaultContextXml", "context.xml"));
-      server.setAttribute(objectName, new Attribute
-         ("defaultWebXml", "conf/web.xml"));
+      server.setAttribute(objectName, new Attribute("defaultContextXml",
+            "context.xml"));
+      server.setAttribute(objectName, new Attribute("defaultWebXml",
+            "conf/web.xml"));
 
       server.setAttribute(objectName, new Attribute("javaVMs", javaVMs));
 
       server.setAttribute(objectName, new Attribute("server", serverName));
 
-      server.setAttribute(objectName, new Attribute
-         ("saveConfig", Boolean.FALSE));
+      server.setAttribute(objectName,
+            new Attribute("saveConfig", Boolean.FALSE));
 
       if (webLoader != null)
       {
-         server.setAttribute(objectName, new Attribute
-            ("loader", webLoader));
-      }
-      else
+         server.setAttribute(objectName, new Attribute("loader", webLoader));
+      } else
       {
-         server.setAttribute(objectName, new Attribute
-            ("parentClassLoader", loader));
+         server.setAttribute(objectName, new Attribute("parentClassLoader",
+               loader));
       }
 
-      server.setAttribute(objectName, new Attribute
-         ("delegate", new Boolean(warInfo.getJava2ClassLoadingCompliance())));
+      server.setAttribute(objectName, new Attribute("delegate", new Boolean(
+            warInfo.getJava2ClassLoadingCompliance())));
 
       String[] jspCP = getCompileClasspath(loader);
       StringBuffer classpath = new StringBuffer();
@@ -250,7 +229,7 @@
             continue;
          if (repository == null)
             continue;
-         // ok it is a file.  Make sure that is is a directory or jar file
+         // ok it is a file. Make sure that is is a directory or jar file
          File fp = new File(repository);
          if (!fp.isDirectory())
          {
@@ -263,8 +242,7 @@
 
                ZipFile zip = new ZipFile(fp);
                zip.close();
-            }
-            catch (IOException e)
+            } catch (IOException e)
             {
                continue;
             }
@@ -275,64 +253,70 @@
          classpath.append(repository);
       }
 
-      server.setAttribute(objectName, new Attribute
-         ("compilerClasspath", classpath.toString()));
+      server.setAttribute(objectName, new Attribute("compilerClasspath",
+            classpath.toString()));
 
       // Set the session cookies flag according to metadata
       switch (metaData.getSessionCookies())
       {
-         case WebMetaData.SESSION_COOKIES_ENABLED:
-            server.setAttribute(objectName, new Attribute
-               ("cookies", new Boolean(true)));
-            log.debug("Enabling session cookies");
-            break;
-         case WebMetaData.SESSION_COOKIES_DISABLED:
-            server.setAttribute(objectName, new Attribute
-               ("cookies", new Boolean(false)));
-            log.debug("Disabling session cookies");
-            break;
-         default:
-            log.debug("Using session cookies default setting");
+      case WebMetaData.SESSION_COOKIES_ENABLED:
+         server.setAttribute(objectName, new Attribute("cookies", new Boolean(
+               true)));
+         log.debug("Enabling session cookies");
+         break;
+      case WebMetaData.SESSION_COOKIES_DISABLED:
+         server.setAttribute(objectName, new Attribute("cookies", new Boolean(
+               false)));
+         log.debug("Disabling session cookies");
+         break;
+      default:
+         log.debug("Using session cookies default setting");
       }
 
       // Add a valve to estalish the JACC context before authorization valves
       Certificate[] certs = null;
       CodeSource cs = new CodeSource(url, certs);
-      JaccContextValve jaccValve = new JaccContextValve(metaData.getJaccContextID(), cs);
-      server.invoke(objectName, "addValve",
-         new Object[]{jaccValve},
-         new String[]{"org.apache.catalina.Valve"}
-      );
+      JaccContextValve jaccValve = new JaccContextValve(metaData
+            .getJaccContextID(), cs);
+      server.invoke(objectName, "addValve", new Object[] { jaccValve },
+            new String[] { "org.apache.catalina.Valve" });
 
       // Pass the metadata to the RunAsListener via a thread local
       RunAsListener.metaDataLocal.set(metaData);
       try
       {
          // Init the container; this will also start it
-         server.invoke(objectName, "init", new Object[]{}, new String[]{});
-      }
-      finally
+         server.invoke(objectName, "init", new Object[] {}, new String[] {});
+      } finally
       {
          RunAsListener.metaDataLocal.set(null);
       }
 
       // make the context class loader known to the WebMetaData, ws4ee needs it
       // to instanciate service endpoint pojos that live in this webapp
-      Loader ctxLoader = (Loader)server.getAttribute(objectName, "loader");
+      Loader ctxLoader = (Loader) server.getAttribute(objectName, "loader");
       metaData.setContextLoader(ctxLoader.getClassLoader());
 
+      // Start it
+      server.invoke(objectName, "start", new Object[]{},
+            new String[]{});
+
       // Clustering
       if (metaData.getDistributable())
       {
-         // Try to initate clustering, fallback to standard if no clustering is available
+         // Try to initate clustering, fallback to standard if no clustering is
+         // available
          try
          {
             AbstractJBossManager manager = null;
             String managerClassName = config.getManagerClass();
-            Class managerClass = Thread.currentThread().getContextClassLoader().loadClass(managerClassName);
+            Class managerClass = Thread.currentThread().getContextClassLoader()
+                  .loadClass(managerClassName);
             manager = (AbstractJBossManager) managerClass.newInstance();
-            String name = "//" + ((hostName == null) ? "localhost" : hostName) + ctxPath;
-            manager.init(name, metaData, config.isUseJK(), config.isUseLocalCache());
+            String name = "//" + ((hostName == null) ? "localhost" : hostName)
+                  + ctxPath;
+            manager.init(name, metaData, config.isUseJK(), config
+                  .isUseLocalCache());
 
             if (manager instanceof JBossCacheManager)
             {
@@ -350,78 +334,78 @@
          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)
          {
             // JBAS-3513 Just log a WARN, not an ERROR
             log.debug("Classes needed for clustered webapp unavailable", ncdf);
-            log.warn("Failed to setup clustering, clustering disabled. NoClassDefFoundError: " + 
-                  ncdf.getMessage());            
+            log.warn("Failed to setup clustering, clustering disabled. NoClassDefFoundError: "
+                        + ncdf.getMessage());
          }
-         catch(Throwable t)
+         catch (Throwable t)
          {
             // TODO consider letting this through and fail the deployment
             log.error("Failed to setup clustering, clustering disabled. Exception: ", t);
          }
       }
 
-      /* Add security association valve after the authorization
-      valves so that the authenticated user may be associated with the
-      request thread/session.
-      */
+      /*
+       * Add security association valve after the authorization valves so that
+       * the authenticated user may be associated with the request
+       * thread/session.
+       */
       SecurityAssociationValve valve = new SecurityAssociationValve(metaData,
-         config.getSecurityManagerService());
+            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" });
 
-      // Retrieve the state, and throw an exception in case of a failure
+      /* TODO: Retrieve the state, and throw an exception in case of a failure
       Integer state = (Integer) server.getAttribute(objectName, "state");
       if (state.intValue() != 1)
       {
          throw new DeploymentException("URL " + warUrl + " deployment failed");
       }
+      */
 
       warInfo.setAppData(objectName);
 
-      /* TODO: Create mbeans for the servlets
-      ObjectName servletQuery = new ObjectName
-         (config.getCatalinaDomain() + ":j2eeType=Servlet,WebModule="
-         + objectName.getKeyProperty("name") + ",*");
-      Iterator iterator = server.queryMBeans(servletQuery, null).iterator();
-      while (iterator.hasNext())
-      {
-         di.mbeans.add(((ObjectInstance)iterator.next()).getObjectName());
-      }
-      */
+      /*
+       * TODO: Create mbeans for the servlets ObjectName servletQuery = new
+       * ObjectName (config.getCatalinaDomain() + ":j2eeType=Servlet,WebModule=" +
+       * objectName.getKeyProperty("name") + ",*"); Iterator iterator =
+       * server.queryMBeans(servletQuery, null).iterator(); while
+       * (iterator.hasNext()) {
+       * di.mbeans.add(((ObjectInstance)iterator.next()).getObjectName()); }
+       */
 
-      if(metaData.getSecurityDomain() != null)
+      if (metaData.getSecurityDomain() != null)
       {
-         String secDomain = org.jboss.security.Util.unprefixSecurityDomain(metaData.getSecurityDomain());
-         //Associate the Context Id with the Security Domain
-         String contextID = metaData.getJaccContextID(); 
+         String secDomain = org.jboss.security.Util
+               .unprefixSecurityDomain(metaData.getSecurityDomain());
+         // Associate the Context Id with the Security Domain
+         String contextID = metaData.getJaccContextID();
 
-         //Check if xacml policy is available 
+         // Check if xacml policy is available
          URL xacmlPolicyFile = null;
          try
          {
             xacmlPolicyFile = this.findXACMLFile(url);
-            if(xacmlPolicyFile != null)
-            {  
-               AuthorizationManager authzmgr= org.jboss.security.Util.getAuthorizationManager(secDomain);
-               if(authzmgr instanceof PolicyRegistration)
+            if (xacmlPolicyFile != null)
+            {
+               AuthorizationManager authzmgr = org.jboss.security.Util
+                     .getAuthorizationManager(secDomain);
+               if (authzmgr instanceof PolicyRegistration)
                {
-                  PolicyRegistration xam = (PolicyRegistration)authzmgr;
-                  xam.registerPolicy(contextID,xacmlPolicyFile);
+                  PolicyRegistration xam = (PolicyRegistration) authzmgr;
+                  xam.registerPolicy(contextID, xacmlPolicyFile);
                }
             }
-         }
-         catch(IOException ioe)
+         } catch (IOException ioe)
          {
-            //Ignore
+            // Ignore
          }
       }
 
@@ -429,74 +413,78 @@
    }
 
    public Loader getWebLoader(ClassLoader loader, URL url)
-           throws MalformedURLException
+         throws MalformedURLException
    {
       Loader webLoader = null;
-      /* If we are using the jboss class loader we need to augment its path
-      to include the WEB-INF/{lib,classes} dirs or else scoped class loading
-      does not see the war level overrides. The call to setWarURL adds these
-      paths to the deployment UCL.
-      */
+      /*
+       * If we are using the jboss class loader we need to augment its path to
+       * include the WEB-INF/{lib,classes} dirs or else scoped class loading
+       * does not see the war level overrides. The call to setWarURL adds these
+       * paths to the deployment UCL.
+       */
 
       if (config.isUseJBossWebLoader())
       {
-         WebCtxLoader jbossLoader = new WebCtxLoader(loader/*, injectionContainer*/);
+         WebCtxLoader jbossLoader = new WebCtxLoader(loader/*
+                                                             * ,
+                                                             * injectionContainer
+                                                             */);
          jbossLoader.setWarURL(url);
          webLoader = jbossLoader;
-      }
-      else
+      } else
       {
          String[] pkgs = config.getFilteredPackages();
-         WebAppLoader jbossLoader = new WebAppLoader(loader, pkgs/*, injectionContainer*/);
-         jbossLoader.setDelegate(warInfo.getJava2ClassLoadingCompliance());
+         WebAppLoader jbossLoader = new WebAppLoader(loader, pkgs/*
+                                                                   * ,
+                                                                   * injectionContainer
+                                                                   */);
+         jbossLoader.setDelegate(getJava2ClassLoadingCompliance());
          webLoader = jbossLoader;
       }
       return webLoader;
    }
 
    /*
-   public void setInjectionContainer(TomcatInjectionContainer container)
-   {
-      this.injectionContainer = container;
-   }
-   */
+    * public void setInjectionContainer(TomcatInjectionContainer container) {
+    * this.injectionContainer = container; }
+    */
 
    /**
-   * Called as part of the undeploy() method template to ask the
-   * subclass for perform the web container specific undeployment steps.
-   */
-  protected void performUndeploy(String warUrl, WebApplication warInfo)
-     throws Exception
-  {
-     if (warInfo == null)
-     {
-        log.debug("performUndeploy, no WebApplication found for URL "
-           + warUrl);
-        return;
-     }
+    * Called as part of the undeploy() method template to ask the subclass for
+    * perform the web container specific undeployment steps.
+    */
+   protected void performUndeploy(String warUrl, WebApplication warInfo)
+         throws Exception
+   {
+      if (warInfo == null)
+      {
+         log
+               .debug("performUndeploy, no WebApplication found for URL "
+                     + warUrl);
+         return;
+      }
 
-     log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot()
-        + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
+      log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot()
+            + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
 
-     WebMetaData metaData = warInfo.getMetaData();
-     String hostName = null;
-     Iterator hostNames = metaData.getVirtualHosts();
-     if (hostNames.hasNext())
-     {
-        hostName = hostNames.next().toString();
-     }
-     performUndeployInternal(hostName, warUrl, warInfo);
-     while (hostNames.hasNext())
-     {
-        String additionalHostName = hostNames.next().toString();
-        performUndeployInternal(additionalHostName, warUrl, warInfo);
-     }
+      WebMetaData metaData = warInfo.getMetaData();
+      String hostName = null;
+      Iterator hostNames = metaData.getVirtualHosts();
+      if (hostNames.hasNext())
+      {
+         hostName = hostNames.next().toString();
+      }
+      performUndeployInternal(hostName, warUrl, warInfo);
+      while (hostNames.hasNext())
+      {
+         String additionalHostName = hostNames.next().toString();
+         performUndeployInternal(additionalHostName, warUrl, warInfo);
+      }
 
-  }
+   }
 
    protected void performUndeployInternal(String hostName, String warUrl,
-                                          WebApplication warInfo)
-      throws Exception
+         WebApplication warInfo) throws Exception
    {
 
       WebMetaData metaData = warInfo.getMetaData();
@@ -509,19 +497,69 @@
          return;
 
       ObjectName objectName = new ObjectName(config.getCatalinaDomain()
-         + ":j2eeType=WebModule,name=//" +
-         ((hostName == null) ? "localhost" : hostName)
-         + ctxPath + ",J2EEApplication=none,J2EEServer=none");
+            + ":j2eeType=WebModule,name=//"
+            + ((hostName == null) ? "localhost" : hostName) + ctxPath
+            + ",J2EEApplication=none,J2EEServer=none");
 
       if (server.isRegistered(objectName))
       {
          // Contexts should be stopped by the host already
-         server.invoke(objectName, "destroy", new Object[]{},
-            new String[]{});
+         server.invoke(objectName, "destroy", new Object[] {}, new String[] {});
       }
 
    }
 
+   /**
+    * Resolve the input virtual host names to the names of the configured Hosts
+    * @param vhostNames Iterator<String> for the jboss-web/virtual-host elements 
+    * @return Iterator<String> of the unique Host names
+    * @throws Exception
+    */
+   protected synchronized Iterator mapVirtualHosts(Iterator vhostNames)
+      throws Exception
+   {
+      if (vhostToHostNames.size() == 0)
+      {
+         // Query the configured Host mbeans
+         String hostQuery = config.getCatalinaDomain() + ":type=Host,*";
+         ObjectName query = new ObjectName(hostQuery);
+         Set hosts = server.queryNames(query, null);
+         Iterator iter = hosts.iterator();
+         while (iter.hasNext())
+         {
+            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);
+               int count = aliases != null ? aliases.length : 0;
+               for (int n = 0; n < count; n++)
+               {
+                  vhostToHostNames.put(aliases[n], name);
+               }
+            }
+         }
+      }
+
+      // Map the virtual host names to the hosts
+      HashSet hosts = new HashSet();
+      while (vhostNames.hasNext())
+      {
+         String vhost = (String)vhostNames.next();
+         String host = (String)vhostToHostNames.get(vhost);
+         if (host == null)
+         {
+            log.warn("Failed to map vhost: " + vhost);
+            // This will cause a new host to be created
+            host = vhost;
+         }
+         hosts.add(host);
+      }
+      return hosts.iterator();
+   }
+
    private String findConfig(URL warURL) throws IOException
    {
       String result = null;
@@ -530,9 +568,9 @@
       if (warURL.getProtocol().equals("file") && warFile.isDirectory() == true)
       {
          File webDD = new File(warFile, CONTEXT_CONFIG_FILE);
-         if (webDD.exists() == true) result = webDD.getAbsolutePath();
-      }
-      else
+         if (webDD.exists() == true)
+            result = webDD.getAbsolutePath();
+      } else
       {
          ZipFile zipFile = new ZipFile(warFile);
          ZipEntry entry = zipFile.getEntry(CONTEXT_CONFIG_FILE);
@@ -556,403 +594,8 @@
    }
 
    /**
-    * A utility method that walks up the ClassLoader chain starting at the given
-    * loader and queries each ClassLoader for a 'URL[] getURLs()' method from
-    * which a complete classpath of URL strings is built.
-    */
-   public String[] getCompileClasspath(ClassLoader loader)
-   {
-      HashSet tmp = new HashSet();
-      ClassLoader cl = loader;
-      while (cl != null)
-      {
-         URL[] urls = AbstractWebContainer.getClassLoaderURLs(cl);
-         addURLs(tmp, urls);
-         cl = cl.getParent();
-      }
-      try
-      {
-         URL[] globalUrls = (URL[]) server.getAttribute(LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY,
-            "URLs");
-         addURLs(tmp, globalUrls);
-      }
-      catch (Exception e)
-      {
-         log.warn("Could not get global URL[] from default loader repository!", e);
-      } // end of try-catch
-      log.trace("JSP CompileClasspath: " + tmp);
-      String[] cp = new String[tmp.size()];
-      tmp.toArray(cp);
-      return cp;
-   }
-
-   private void addURLs(Set urlSet, URL[] urls)
-   {
-      for (int u = 0; u < urls.length; u++)
-      {
-         URL url = urls[u];
-         urlSet.add(url.toExternalForm());
-      }
-   }
-
-   /**
-    * This method is invoked from within subclass performDeploy() method
-    * implementations when they invoke WebDescriptorParser.parseWebAppDescriptors().
-    * @param loader the ClassLoader for the web application. May not be null.
-    * @param metaData the WebMetaData from the WebApplication object passed to
-    * the performDeploy method.
-    */
-   protected void processEnc(ClassLoader loader, WebMetaData metaData)
-      throws Exception
-   {
-      log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin");
-      InitialContext iniCtx = new InitialContext();
-      Context envCtx = null;
-      Thread currentThread = Thread.currentThread();
-      ClassLoader currentLoader = currentThread.getContextClassLoader();
-      try
-      {
-         // Create a java:comp/env environment unique for the web application
-         log.debug("Creating ENC using ClassLoader: " + loader);
-         ClassLoader parent = loader.getParent();
-         while (parent != null)
-         {
-            log.debug(".." + parent);
-            parent = parent.getParent();
-         }
-         // TODO: Where does this ENC get tidied up?
-         currentThread.setContextClassLoader(loader);
-         metaData.setENCLoader(loader);
-         envCtx = (Context) iniCtx.lookup("java:comp");
-
-         
-         // Bind the orb
-         if (orb != null)
-         {
-            NonSerializableFactory.rebind(envCtx, "ORB", orb);
-            log.debug("Bound java:comp/ORB");
-         }
-         
-         // Add a link to the global transaction manager
-         envCtx.bind("UserTransaction", new LinkRef("UserTransaction"));
-         log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction");
-         envCtx = envCtx.createSubcontext("env");
-         processEncReferences(metaData, envCtx);
-      }
-      finally
-      {
-         currentThread.setContextClassLoader(currentLoader);
-      }
-
-      String securityDomain = metaData.getSecurityDomain();
-      log.debug("linkSecurityDomain");
-      linkSecurityDomain(securityDomain, envCtx);
-      log.debug("AbstractWebContainer.parseWebAppDescriptors, End");
-   }
-
-   protected void processEncReferences(WebMetaData metaData, Context envCtx)
-           throws ClassNotFoundException, NamingException, DeploymentException
-   {
-      Iterator envEntries = metaData.getEnvironmentEntries();
-      log.debug("addEnvEntries");
-      addEnvEntries(envEntries, envCtx);
-      Iterator resourceEnvRefs = metaData.getResourceEnvReferences();
-      log.debug("linkResourceEnvRefs");
-      linkResourceEnvRefs(resourceEnvRefs, envCtx);
-      Iterator resourceRefs = metaData.getResourceReferences();
-      log.debug("linkResourceRefs");
-      linkResourceRefs(resourceRefs, envCtx);
-      log.debug("linkMessageDestinationRefs");
-      linkMessageDestinationRefs(metaData, envCtx);
-      Iterator ejbRefs = metaData.getEjbReferences();
-      log.debug("linkEjbRefs");
-      linkEjbRefs(ejbRefs, envCtx);
-      Iterator ejbLocalRefs = metaData.getEjbLocalReferences();
-      log.debug("linkEjbLocalRefs");
-      linkEjbLocalRefs(ejbLocalRefs, envCtx);
-      Iterator serviceRefs = metaData.getServiceReferences();
-      log.debug("linkServiceRefs");
-      //WebServiceClientHandler.setupServiceRefEnvironment(envCtx, serviceRefs);
-   }
-
-   protected void addEnvEntries(Iterator envEntries, Context envCtx)
-      throws ClassNotFoundException, NamingException
-   {
-      while (envEntries.hasNext())
-      {
-         EnvEntryMetaData entry = (EnvEntryMetaData) envEntries.next();
-         log.debug("Binding env-entry: " + entry.getName() + " of type: " +
-            entry.getType() + " to value:" + entry.getValue());
-         EnvEntryMetaData.bindEnvEntry(envCtx, entry);
-      }
-   }
-
-   protected void linkResourceEnvRefs(Iterator resourceEnvRefs, Context envCtx)
-      throws NamingException
-   {
-      while (resourceEnvRefs.hasNext())
-      {
-         ResourceEnvRefMetaData ref = (ResourceEnvRefMetaData) resourceEnvRefs.next();
-         String resourceName = ref.getJndiName();
-         String refName = ref.getRefName();
-         if (ref.getType().equals("java.net.URL"))
-         {
-            try
-            {
-               log.debug("Binding '" + refName + "' to URL: " + resourceName);
-               URL url = new URL(resourceName);
-               Util.bind(envCtx, refName, url);
-            }
-            catch (MalformedURLException e)
-            {
-               throw new NamingException("Malformed URL:" + e.getMessage());
-            }
-         }
-         else if (resourceName != null)
-         {
-            log.debug("Linking '" + refName + "' to JNDI name: " + resourceName);
-            Util.bind(envCtx, refName, new LinkRef(resourceName));
-         }
-         else
-         {
-            throw new NamingException("resource-env-ref: " + refName
-               + " has no valid JNDI binding. Check the jboss-web/resource-env-ref.");
-         }
-      }
-   }
-
-   protected void linkResourceRefs(Iterator resourceRefs, Context envCtx)
-      throws NamingException
-   {
-      while (resourceRefs.hasNext())
-      {
-         ResourceRefMetaData ref = (ResourceRefMetaData) resourceRefs.next();
-         String jndiName = ref.getJndiName();
-         String refName = ref.getRefName();
-         if (ref.getType().equals("java.net.URL"))
-         {
-            try
-            {
-               String resURL = ref.getResURL();
-               if (ref.getResURL() != null)
-               {
-                  log.debug("Binding '" + refName + "' to URL: " + resURL);
-                  URL url = new URL(resURL);
-                  Util.bind(envCtx, refName, url);
-               }
-               else
-               {
-                  log.debug("Linking '" + refName + "' to URL: " + resURL);
-                  LinkRef urlLink = new LinkRef(jndiName);
-                  Util.bind(envCtx, refName, urlLink);
-               }
-            }
-            catch (MalformedURLException e)
-            {
-               throw new NamingException("Malformed URL:" + e.getMessage());
-            }
-         }
-         else if (jndiName != null)
-         {
-            log.debug("Linking '" + refName + "' to JNDI name: " + jndiName);
-            Util.bind(envCtx, refName, new LinkRef(jndiName));
-         }
-         else
-         {
-            throw new NamingException("resource-ref: " + refName
-               + " has no valid JNDI binding. Check the jboss-web/resource-ref.");
-         }
-      }
-   }
-
-   protected void linkMessageDestinationRefs(WebMetaData metaData, Context envCtx)
-      throws NamingException, DeploymentException
-   {
-      Iterator i = metaData.getMessageDestinationReferences();
-
-      while (i.hasNext())
-      {
-         MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData) i.next();
-
-         String refName = ref.getRefName();
-         String jndiName = ref.getJNDIName();
-         String link = ref.getLink();
-         if (link != null)
-         {
-            if (jndiName == null)
-            {
-               MessageDestinationMetaData messageDestination = null; //EjbUtil.findMessageDestination(server, di, link);
-               if (messageDestination == null)
-                  throw new DeploymentException("message-destination-ref '" + refName +
-                     "' message-destination-link '" + link + "' not found and no jndi-name in jboss-web.xml");
-               else
-               {
-                  String linkJNDIName = messageDestination.getJNDIName();
-                  if (linkJNDIName == null)
-                     log.warn("message-destination '" + link + "' has no jndi-name in jboss-web.xml");
-                  else
-                     jndiName = linkJNDIName;
-               }
-            }
-            else
-               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 DeploymentException("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(Iterator ejbRefs, Context envCtx)
-      throws NamingException
-   {
-      while (ejbRefs.hasNext())
-      {
-         EjbRefMetaData ejb = (EjbRefMetaData) ejbRefs.next();
-         String name = ejb.getName();
-         String linkName = ejb.getLink();
-         String jndiName = null;
-         
-         //use ejb-link if it is specified
-         if (linkName != null)
-         {
-            jndiName = null; // EjbUtil.findEjbLink(server, di, linkName);
-             
-            //if flag does not allow misconfigured ejb-links, it is an error
-            if ((jndiName == null) && !(warInfo.getLenientEjbLink()))
-               throw new NamingException("ejb-ref: " + name + ", no ejb-link match");
-         }
-
-         
-         //fall through to the jndiName
-         if (jndiName == null)
-         {
-            jndiName = ejb.getJndiName();
-            if (jndiName == null)
-               throw new NamingException("ejb-ref: " + name + ", no ejb-link in web.xml and no jndi-name in jboss-web.xml");
-         }
-
-         log.debug("Linking ejb-ref: " + name + " to JNDI name: " + jndiName);
-         Util.bind(envCtx, name, new LinkRef(jndiName));
-      }
-   }
-
-   protected void linkEjbLocalRefs(Iterator ejbRefs, Context envCtx)
-      throws NamingException
-   {
-      while (ejbRefs.hasNext())
-      {
-         EjbLocalRefMetaData ejb = (EjbLocalRefMetaData) ejbRefs.next();
-         String name = ejb.getName();
-         String linkName = ejb.getLink();
-         String jndiName = null;
-
-         //use the ejb-link field if it is specified
-         if (linkName != null)
-         {
-            jndiName = null; // EjbUtil.findLocalEjbLink(server, di, linkName);
-             
-            //if flag does not allow misconfigured ejb-links, it is an error    
-            if ((jndiName == null) && !(warInfo.getLenientEjbLink()))
-               throw new NamingException("ejb-ref: " + name + ", no ejb-link match");
-         }
-
-
-         if (jndiName == null)
-         {
-            jndiName = ejb.getJndiName();
-            if (jndiName == null)
-            {
-               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";
-               }
-               else
-               {
-                  msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '"
-                     + linkName + "' failed to resolve to an ejb with a LocalHome";
-               }
-               throw new NamingException(msg);
-            }
-         }
-
-         log.debug("Linking ejb-local-ref: " + name + " to JNDI name: " + jndiName);
-         Util.bind(envCtx, name, new LinkRef(jndiName));
-      }
-   }
-
-   /**
-    * This creates a java:comp/env/security context that contains a securityMgr
-    * binding pointing to an AuthenticationManager implementation and a
-    * realmMapping binding pointing to a RealmMapping implementation. If the
-    * jboss-web.xml descriptor contained a security-domain element then the
-    * bindings are LinkRefs to the jndi name specified by the security-domain
-    * 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
-   {
-      if (securityDomain == null)
-      {
-         securityDomain = config.getDefaultSecurityDomain();
-         log.debug("No security-domain given, using default: " + 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/security-domain", new LinkRef(securityDomain));
-      Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject"));
-   }
-
-   /**
-    * A utility method that searches the given loader for the resources:
-    * "javax/servlet/resources/web-app_2_3.dtd", "org/apache/jasper/resources/jsp12.dtd",
-    * and "javax/ejb/EJBHome.class" and returns an array of URL strings. Any
-    * jar: urls are reduced to the underlying <url> portion of the
-    * 'jar:<url>!/{entry}' construct.
-    */
-   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"
-      };
-      ArrayList tmp = new ArrayList();
-      for (int j = 0; j < jspResources.length; j++)
-      {
-         URL rsrcURL = loader.getResource(jspResources[j]);
-         if (rsrcURL != null)
-         {
-            String url = rsrcURL.toExternalForm();
-            if (rsrcURL.getProtocol().equals("jar"))
-            {
-               // Parse the jar:<url>!/{entry} URL
-               url = url.substring(4);
-               int seperator = url.indexOf('!');
-               url = url.substring(0, seperator);
-            }
-            tmp.add(url);
-         }
-         else
-         {
-            log.warn("Failed to fin jsp rsrc: " + jspResources[j]);
-         }
-      }
-      log.trace("JSP StandardCompileClasspath: " + tmp);
-      String[] cp = new String[tmp.size()];
-      tmp.toArray(cp);
-      return cp;
-   }
-
-   /**
     * Locate a XACMl Policy file packaged in the war
+    * 
     * @param warURL
     * @return
     * @throws IOException
@@ -971,16 +614,4 @@
       return result;
    }
 
-    private String shortWarUrlFromServerHome(String warUrl)
-    {
-        String serverHomeUrl =  System.getProperty(org.jboss.system.server.ServerConfig.SERVER_HOME_URL);
-
-        if (warUrl == null || serverHomeUrl == null)
-            return warUrl;
-
-        if (warUrl.startsWith(serverHomeUrl))
-          return ".../" + warUrl.substring(serverHomeUrl.length());
-        else
-          return warUrl;
-    } 
 }

Deleted: trunk/tomcat/src/resources/jboss-service-all.xml
===================================================================
--- trunk/tomcat/src/resources/jboss-service-all.xml	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/src/resources/jboss-service-all.xml	2006-10-14 06:13:26 UTC (rev 57669)
@@ -1,170 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id$ -->
-<server>
-   <mbean code="org.jboss.web.tomcat.tc6.Tomcat6"
-      name="jboss.web:service=WebServer" xmbean-dd="META-INF/webserver-xmbean.xml"> 
-      
-      <!-- You can configure a set of authenticators keyed by http-auth method used. This
-      will apply the same set of authenticators across all web applications. You can
-      override the set of authenticators at the web application level by adding
-      <authenticators> element to the respective jboss-web.xml --> 
-      <attribute name="Authenticators" serialDataType="jbxb">
-         <java:properties xmlns:java="urn:jboss:java-properties"
-            xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
-            xs:schemaLocation="urn:jboss:java-properties resource:java-properties_1_0.xsd">
-            <java:property>
-               <java:key>BASIC</java:key>
-               <java:value>org.apache.catalina.authenticator.BasicAuthenticator</java:value>
-            </java:property>
-            <java:property>
-               <java:key>CLIENT-CERT</java:key>
-               <java:value>org.apache.catalina.authenticator.SSLAuthenticator</java:value>
-            </java:property>
-            <java:property>
-               <java:key>DIGEST</java:key>
-               <java:value>org.apache.catalina.authenticator.DigestAuthenticator</java:value>
-            </java:property>
-            <java:property>
-               <java:key>FORM</java:key>
-               <java:value>org.apache.catalina.authenticator.FormAuthenticator</java:value>
-            </java:property> 
-            <java:property>
-               <java:key>NONE</java:key>
-               <java:value>org.apache.catalina.authenticator.NonLoginAuthenticator</java:value>
-            </java:property> 
-         </java:properties>
-      </attribute> 
-      
-      <!-- The JAAS security domain to use in the absense of an explicit
-      security-domain specification in the war WEB-INF/jboss-web.xml
-      -->
-      <attribute name="DefaultSecurityDomain">java:/jaas/other</attribute>
-      
-      <!-- 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.
-      -->
-      <attribute name="Java2ClassLoadingCompliance">false</attribute>
-      <!-- A flag indicating if the JBoss Loader should be used. This loader
-      uses a unified class loader as the class loader rather than the tomcat
-      specific class loader.
-      The default is false to ensure that wars have isolated class loading
-      for duplicate jars and jsp files.
-      -->
-      <attribute name="UseJBossWebLoader">false</attribute>
-      <!-- The list of package names that should not be loaded without
-      delegating to the parent class loader before trying the web app
-      class loader. The packages listed here are those tha are used by
-      the web container implementation and cannot be overriden.
-      This only applies when UseJBossWebLoader=false.
-      -->
-      <attribute name="FilteredPackages">org.apache.commons.logging</attribute>
-      
-      <attribute name="LenientEjbLink">true</attribute>
-
-      <!--Flag to delete the Work Dir on Context Destroy -->
-      <attribute name="DeleteWorkDirOnContextDestroy">false</attribute>
-      
-      <!--
-      Class of the session manager (used if context is marked as 'distributable'. Currently allowed values:
-      - org.jboss.web.tomcat.tc6.session.JBossCacheManager
-      -->
-      <attribute name="ManagerClass">
-         org.jboss.web.tomcat.tc6.session.JBossCacheManager</attribute>
-      
-      <!-- The name of the request attribute under with the authenticated JAAS
-      Subject is stored on successful authentication. If null or empty then
-      the Subject will not be stored.
-      -->
-      <!--
-      <attribute name="SubjectAttributeName">j_subject</attribute>
-      -->
-      
-      <!-- The SessionIdAlphabet is the set of characters used to create a session Id
-      It must be made up of exactly 65 unique characters
-      <attribute name="SessionIdAlphabet">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-*</attribute>
-      -->
-      
-      <!--
-      *******************************************************
-      ****************** CLUSTERING *************************
-      *******************************************************
-      In order to activate HTTP Session clustering for Tomcat
-      make sure you run JBoss's "all" configuration i.e.
-      "run -c all"
-      (the default configuration doesn't contain clustering)
-      
-      Furthermore, you may change SnapshotMode and
-      SnapshotInterval attributes below to indicate when to
-      synchronize changes with the other node(s).
-      
-      If you use Apache+mod_jk(2) you will most probably use
-      the AJP1.3 connector below. Thus, if you so wish,
-      you may comment (i.e. deactivate) the HTTP connector
-      as it won't be used anymore.
-      
-      *******************************************************
-      *******************************************************
-      *******************************************************
-      -->
-      
-      <!--
-      If you are using clustering, the following two attributes
-      define when the sessions are replicated to the other nodes.
-      The default value, "instant", synchronously replicates changes
-      to the other nodes at the end of requests. In this case, the 
-      "SnapshotInterval" attribute is not used.
-      The "interval" mode, in association with the "SnapshotInterval"
-      attribute, indicates that modified sessions will only be replicated
-      every "SnapshotInterval" milliseconds at most.   
-      
-      Note that this attribute is not in effect if the replication-granularity
-      is set to FIELD. If it is FIELD, it will be per http request (that is, 
-      "instant" mode.)
-      -->
-      <attribute name="SnapshotMode">instant</attribute>
-      <!-- you may switch to "interval" -->
-      <attribute name="SnapshotInterval">2000</attribute>
-      
-      <!--
-      Whether to use MOD_JK(2) for load balancing with sticky session 
-      combined with JvmRoute. If set to true, it will insert a JvmRouteValve 
-      to intercept every request and replace the JvmRoute if it detects a 
-      failover. In addition, you will need to set the JvmRoute inside
-      Tomcat, e.g.,
-      Engine name="jboss.web" jmvRoute="Node1" defaultHost="localhost" 
-      in server.xml.
-      
-      For clustering purpose only.
-      -->
-      <attribute name="UseJK">false</attribute>
-      
-      <attribute name="Domain">jboss.web</attribute>
-
-      <!-- A mapping to the server security manager service which must be
-      operation compatible with type
-      org.jboss.security.plugins.JaasSecurityManagerServiceMBean. This is only
-      needed if web applications are allowed to flush the security manager
-      authentication cache when the web sessions invalidate.
-      -->
-      <depends optional-attribute-name="SecurityManagerService"
-         proxy-type="attribute">jboss.security:service=JaasSecurityManager
-      </depends>
-      
-      <!--
-         Needed if using HTTP Session Clustering or if the
-         ClusteredSingleSignOn valve is enabled in the tomcat server.xml file
-      -->
-      <depends>jboss.cache:service=TomcatClusteringCache</depends>
-      
-      <depends>jboss:service=TransactionManager</depends>
-      
-      <!-- Only needed if the org.jboss.web.tomcat.tc6.jca.CachedConnectionValve
-      is enabled in the tomcat server.xml file.
-      -->
-      <depends>jboss.jca:service=CachedConnectionManager</depends>
-                
-   </mbean>
-
-</server>
-

Deleted: trunk/tomcat/src/resources/jboss-service.xml
===================================================================
--- trunk/tomcat/src/resources/jboss-service.xml	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/src/resources/jboss-service.xml	2006-10-14 06:13:26 UTC (rev 57669)
@@ -1,174 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id$ -->
-<server>
-
-   <!-- Tomcat 6 Service-->
-   <mbean code="org.jboss.web.tomcat.tc6.Tomcat6"
-      name="jboss.web:service=WebServer" xmbean-dd="META-INF/webserver-xmbean.xml">
-
-      <!-- You can configure a set of authenticators keyed by http-auth method used. This
-      will apply the same set of authenticators across all web applications. You can
-      override the set of authenticators at the web application level by adding
-      <authenticators> element to the respective jboss-web.xml --> 
-      <attribute name="Authenticators" serialDataType="jbxb">
-         <java:properties xmlns:java="urn:jboss:java-properties"
-            xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
-            xs:schemaLocation="urn:jboss:java-properties resource:java-properties_1_0.xsd">
-            <java:property>
-               <java:key>BASIC</java:key>
-               <java:value>org.apache.catalina.authenticator.BasicAuthenticator</java:value>
-            </java:property>
-            <java:property>
-               <java:key>CLIENT-CERT</java:key>
-               <java:value>org.apache.catalina.authenticator.SSLAuthenticator</java:value>
-            </java:property>
-            <java:property>
-               <java:key>DIGEST</java:key>
-               <java:value>org.apache.catalina.authenticator.DigestAuthenticator</java:value>
-            </java:property>
-            <java:property>
-               <java:key>FORM</java:key>
-               <java:value>org.apache.catalina.authenticator.FormAuthenticator</java:value>
-            </java:property> 
-            <java:property>
-               <java:key>NONE</java:key>
-               <java:value>org.apache.catalina.authenticator.NonLoginAuthenticator</java:value>
-            </java:property> 
-         </java:properties>
-      </attribute> 
-	   
-      <!-- The JAAS security domain to use in the absense of an explicit
-      security-domain specification in the war WEB-INF/jboss-web.xml
-      -->
-      <attribute name="DefaultSecurityDomain">java:/jaas/other</attribute>
-
-      <!-- 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.
-      -->
-      <attribute name="Java2ClassLoadingCompliance">false</attribute>
-      <!-- A flag indicating if the JBoss Loader should be used. This loader
-           uses a unified class loader as the class loader rather than the tomcat
-           specific class loader.
-           The default is false to ensure that wars have isolated class loading
-           for duplicate jars and jsp files.
-      -->
-      <attribute name="UseJBossWebLoader">false</attribute>
-      <!-- The list of package prefixes that should not be loaded without
-         delegating to the parent class loader before trying the web app
-         class loader. The packages listed here are those tha are used by
-         the web container implementation and cannot be overriden. The format
-         is a comma separated list of the package names. There cannot be any
-         whitespace between the package prefixes.
-         This setting only applies when UseJBossWebLoader=false.
-      -->
-      <attribute name="FilteredPackages">javax.servlet,org.apache.commons.logging</attribute>
-
-      <attribute name="LenientEjbLink">true</attribute>
-
-      <!--Flag to delete the Work Dir on Context Destroy -->
-      <attribute name="DeleteWorkDirOnContextDestroy">false</attribute>
-
-      <!--
-          Class of the session manager (used if context is marked as 'distributable'. Currently allowed values:
-          - org.jboss.web.tomcat.tc6.session.JBossCacheManager
-      -->
-      <attribute name="ManagerClass">org.jboss.web.tomcat.tc6.session.JBossCacheManager</attribute>
-
-      <!-- The name of the request attribute under with the authenticated JAAS
-      Subject is stored on successful authentication. If null or empty then
-      the Subject will not be stored.
-      -->
-      <!--
-      <attribute name="SubjectAttributeName">j_subject</attribute>
-      -->
-
-      <!-- The SessionIdAlphabet is the set of characters used to create a session Id
-           It must be made up of exactly 65 unique characters
-      <attribute name="SessionIdAlphabet">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-*</attribute>
-      -->
-
-      <!--
-      *******************************************************
-      ****************** CLUSTERING *************************
-      *******************************************************
-      In order to activate HTTP Session clustering for Tomcat
-      make sure you run JBoss's "all" configuration i.e.
-      "run -c all"
-      (the default configuration doesn't contain clustering)
-
-      Furthermore, you may change SnapshotMode and
-      SnapshotInterval attributes below to indicate when to
-      synchronize changes with the other node(s).
-
-      If you use Apache+mod_jk(2) you will most probably use
-      the AJP1.3 connector below. Thus, if you so wish,
-      you may comment (i.e. deactivate) the HTTP connector
-      as it won't be used anymore.
-
-      *******************************************************
-      *******************************************************
-      *******************************************************
-      -->
-		
-      <!--
-      If you are using clustering, the following two attributes
-      define when the sessions are replicated to the other nodes.
-      The default value, "instant", synchronously replicates changes
-      to the other nodes at the end of requests. In this case, the 
-      "SnapshotInterval" attribute is not used.
-      The "interval" mode, in association with the "SnapshotInterval"
-      attribute, indicates that modified sessions will only be replicated
-      every "SnapshotInterval" milliseconds at most.	
-		
-      Note that this attribute is not in effect if the replication-granularity
-      is set to FIELD. If it is FIELD, it will be per http request (that is, 
-      "instant" mode.)
-      -->
-      <attribute name="SnapshotMode">instant</attribute> <!-- you may switch to "interval" -->
-      <attribute name="SnapshotInterval">2000</attribute>
-
-      <!--
-      Whether to use MOD_JK(2) for load balancing with sticky session 
-      combined with JvmRoute. If set to true, it will insert a JvmRouteValve 
-      to intercept every request and replace the JvmRoute if it detects a 
-      failover. In addition, you will need to set the JvmRoute inside
-      Tomcat, e.g.,
-        Engine name="jboss.web" jmvRoute="Node1" defaultHost="localhost" 
-      in server.xml.
-
-      For clustering purpose only.
-      -->
-      <attribute name="UseJK">false</attribute>
-
-      <attribute name="Domain">jboss.web</attribute>
-
-      <!-- A mapping to the server security manager service which must be
-      operation compatible with type
-      org.jboss.security.plugins.JaasSecurityManagerServiceMBean. This is only
-      needed if web applications are allowed to flush the security manager
-      authentication cache when the web sessions invalidate.
-      -->
-      <depends optional-attribute-name="SecurityManagerService"
-         proxy-type="attribute">jboss.security:service=JaasSecurityManager
-      </depends>
-
-      <!--
-      	Needed if using HTTP Session Clustering or if the
-         ClusteredSingleSignOn valve is enabled in the tomcat server.xml file
-      -->
-      <!--
-      <depends>jboss.cache:service=TomcatClusteringCache</depends>
-      -->
-      
-      <depends>jboss:service=TransactionManager</depends>
-      
-      <!-- Only needed if the org.jboss.web.tomcat.tc6.jca.CachedConnectionValve
-      is enabled in the tomcat server.xml file.
-      -->
-      <depends>jboss.jca:service=CachedConnectionManager</depends>
-      
-   </mbean>
-
-</server>
-

Added: trunk/tomcat/src/resources/jboss-structure.xml
===================================================================
--- trunk/tomcat/src/resources/jboss-structure.xml	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/src/resources/jboss-structure.xml	2006-10-14 06:13:26 UTC (rev 57669)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<structure>
+    <context>
+        <path name="jbossweb-tomcat6.deployer" />
+        <metaDataPath name="META-INF" />
+        <classpath>
+            <path name="" suffixes=".jar" />
+            <path name="jsf-libs" suffixes=".jar" />
+        </classpath>
+    </context>
+</structure>

Modified: trunk/tomcat/src/resources/server.xml
===================================================================
--- trunk/tomcat/src/resources/server.xml	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/src/resources/server.xml	2006-10-14 06:13:26 UTC (rev 57669)
@@ -150,10 +150,11 @@
                  
                  Important: The dependency on the CachedConnectionManager
                  in META-INF/jboss-service.xml must be uncommented, too
-            -->
+            TODO:
             <Valve className="org.jboss.web.tomcat.tc6.jca.CachedConnectionValve"
                 cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
                 transactionManagerObjectName="jboss:service=TransactionManager" />
+           -->
                 
          </Host>
 

Added: trunk/tomcat/src/resources/war-deployers-all-beans.xml
===================================================================
--- trunk/tomcat/src/resources/war-deployers-all-beans.xml	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/src/resources/war-deployers-all-beans.xml	2006-10-14 06:13:26 UTC (rev 57669)
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Web application deployers
+$Id:$
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <!-- Tomcat
+   <bean name="VFSClassLoader" class="org.jboss.virtual.classloading.VFSClassLoader">
+      <constructor factoryClass="org.jboss.virtual.classloading.VFSClassLoaderFactory"
+                   factoryMethod="newClassLoader">
+         <parameter class="java.net.URI">${jboss.server.home.url}/deployers/jbossweb-tomcat6.deployer/</parameter>
+         <parameter>
+         	<array class="[Ljava.lang.String;" elementClass="java.lang.String">
+	         	<value>*.jar</value>
+	         	<value>jsf-libs/*.jar</value>
+         	</array>
+         	</parameter>
+      </constructor>
+   </bean>
+   -->
+
+   <!-- web.xml parsing deployer -->
+   <bean name="WebAppParsingDeployer" class="org.jboss.deployment.WebAppParsingDeployer">
+      <install bean="MainDeployer" method="addDeployer">
+         <parameter><this/></parameter>
+      </install>
+      <uninstall bean="MainDeployer" method="removeDeployer">
+         <parameter><this/></parameter>
+      </uninstall>
+   </bean>
+   <bean name="JBossWebAppParsingDeployer" class="org.jboss.deployment.JBossWebAppParsingDeployer">
+      <install bean="MainDeployer" method="addDeployer">
+         <parameter><this/></parameter>
+      </install>
+      <uninstall bean="MainDeployer" method="removeDeployer">
+         <parameter><this/></parameter>
+      </uninstall>
+   </bean>
+
+   <bean name="WarDeployer" class="org.jboss.web.tomcat.tc6.deployers.TomcatDeployer">
+      <install bean="MainDeployer" method="addDeployer">
+         <parameter><this/></parameter>
+      </install>
+      <uninstall bean="MainDeployer" method="removeDeployer">
+         <parameter><this/></parameter>
+      </uninstall>
+
+      <!-- The JAAS security domain to use in the absense of an explicit
+      security-domain specification in the war WEB-INF/jboss-web.xml
+      -->
+      <property name="defaultSecurityDomain">java:/jaas/other</property>
+
+      <!-- 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.
+      -->
+      <property name="java2ClassLoadingCompliance">false</property>
+      <!-- A flag indicating if the JBoss Loader should be used. This loader
+           uses a unified class loader as the class loader rather than the tomcat
+           specific class loader.
+           The default is false to ensure that wars have isolated class loading
+           for duplicate jars and jsp files.
+      -->
+      <property name="useJBossWebLoader">false</property>
+      <!-- The list of package prefixes that should not be loaded without
+         delegating to the parent class loader before trying the web app
+         class loader. The packages listed here are those tha are used by
+         the web container implementation and cannot be overriden. The format
+         is a comma separated list of the package names. There cannot be any
+         whitespace between the package prefixes.
+         This setting only applies when UseJBossWebLoader=false.
+      -->
+      <property name="filteredPackages">javax.servlet,org.apache.commons.logging</property>
+
+      <property name="lenientEjbLink">true</property>
+
+      <!--Flag to delete the Work Dir on Context Destroy -->
+      <property name="deleteWorkDirOnContextDestroy">false</property>
+
+      <!--
+          Class of the session manager (used if context is marked as 'distributable'. Currently allowed values:
+          - org.jboss.web.tomcat.tc6.session.JBossCacheManager
+      -->
+      <property name="managerClass">org.jboss.web.tomcat.tc6.session.JBossCacheManager</property>
+
+      <!-- The name of the request property under with the authenticated JAAS
+      Subject is stored on successful authentication. If null or empty then
+      the Subject will not be stored.
+      -->
+      <!--
+      <property name="subjectAttributeName">j_subject</property>
+      -->
+
+      <!-- The SessionIdAlphabet is the set of characters used to create a session Id
+           It must be made up of exactly 65 unique characters
+      <property name="sessionIdAlphabet">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-*</property>
+      -->
+
+      <!--
+      *******************************************************
+      ****************** CLUSTERING *************************
+      *******************************************************
+      In order to activate HTTP Session clustering for Tomcat
+      make sure you run JBoss's "all" configuration i.e.
+      "run -c all"
+      (the default configuration doesn't contain clustering)
+
+      Furthermore, you may change SnapshotMode and
+      SnapshotInterval propertys below to indicate when to
+      synchronize changes with the other node(s).
+
+      If you use Apache+mod_jk(2) you will most probably use
+      the AJP1.3 connector below. Thus, if you so wish,
+      you may comment (i.e. deactivate) the HTTP connector
+      as it won't be used anymore.
+
+      *******************************************************
+      *******************************************************
+      *******************************************************
+      -->
+		
+      <!--
+      If you are using clustering, the following two propertys
+      define when the sessions are replicated to the other nodes.
+      The default value, "instant", synchronously replicates changes
+      to the other nodes at the end of requests. In this case, the 
+      "SnapshotInterval" property is not used.
+      The "interval" mode, in association with the "SnapshotInterval"
+      property, indicates that modified sessions will only be replicated
+      every "SnapshotInterval" milliseconds at most.	
+		
+      Note that this property is not in effect if the replication-granularity
+      is set to FIELD. If it is FIELD, it will be per http request (that is, 
+      "instant" mode.)
+      -->
+      <property name="snapshotMode">instant</property> <!-- you may switch to "interval" -->
+      <property name="snapshotInterval">2000</property>
+
+      <!--
+      Whether to use MOD_JK(2) for load balancing with sticky session 
+      combined with JvmRoute. If set to true, it will insert a JvmRouteValve 
+      to intercept every request and replace the JvmRoute if it detects a 
+      failover. In addition, you will need to set the JvmRoute inside
+      Tomcat, e.g.,
+        Engine name="jboss.web" jmvRoute="Node1" defaultHost="localhost" 
+      in server.xml.
+
+      For clustering purpose only.
+      -->
+      <property name="useJK">false</property>
+
+      <property name="domain">jboss.web</property>
+		<property name="securityManagerService">
+			<inject bean="jboss.security:service=JaasSecurityManager" />
+	   </property>
+      <depends>jboss.cache:service=TomcatClusteringCache</depends>
+      
+      <depends>jboss:service=TransactionManager</depends>
+      
+      <!-- Only needed if the org.jboss.web.tomcat.tc6.jca.CachedConnectionValve
+TODO: injection
+      is enabled in the tomcat server.xml file.
+      <depends>jboss.jca:service=CachedConnectionManager</depends>
+      -->
+   </bean>
+
+</deployment>


Property changes on: trunk/tomcat/src/resources/war-deployers-all-beans.xml
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/tomcat/src/resources/war-deployers-beans.xml
===================================================================
--- trunk/tomcat/src/resources/war-deployers-beans.xml	2006-10-14 05:08:55 UTC (rev 57668)
+++ trunk/tomcat/src/resources/war-deployers-beans.xml	2006-10-14 06:13:26 UTC (rev 57669)
@@ -1,35 +1,168 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Web application deployers
-$Id:$
--->
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
-   <!-- web.xml parsing deployer -->
-   <bean name="WebAppParsingDeployer" class="org.jboss.deployment.WebAppParsingDeployer">
-      <install bean="MainDeployer" method="addDeployer">
-         <parameter><this/></parameter>
-      </install>
-      <uninstall bean="MainDeployer" method="removeDeployer">
-         <parameter><this/></parameter>
-      </uninstall>
-   </bean>
-   <bean name="WebAppParsingDeployer" class="org.jboss.deployment.JBossWebAppParsingDeployer">
-      <install bean="MainDeployer" method="addDeployer">
-         <parameter><this/></parameter>
-      </install>
-      <uninstall bean="MainDeployer" method="removeDeployer">
-         <parameter><this/></parameter>
-      </uninstall>
-   </bean>
-   <bean name="WebAppParsingDeployer" class="org.jboss.web.tomcat.tc6.deployers.WarDeployer">
-      <install bean="MainDeployer" method="addDeployer">
-         <parameter><this/></parameter>
-      </install>
-      <uninstall bean="MainDeployer" method="removeDeployer">
-         <parameter><this/></parameter>
-      </uninstall>
-   </bean>
-
-</deployment>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Web application deployers
+$Id:$
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <!-- Tomcat
+   <bean name="VFSClassLoader" class="org.jboss.virtual.classloading.VFSClassLoader">
+      <constructor factoryClass="org.jboss.virtual.classloading.VFSClassLoaderFactory"
+                   factoryMethod="newClassLoader">
+         <parameter class="java.net.URI">${jboss.server.home.url}/deployers/jbossweb-tomcat6.deployer/</parameter>
+         <parameter>
+         	<array class="[Ljava.lang.String;" elementClass="java.lang.String">
+	         	<value>*.jar</value>
+	         	<value>jsf-libs/*.jar</value>
+         	</array>
+         	</parameter>
+      </constructor>
+   </bean>
+   -->
+
+   <!-- web.xml parsing deployer -->
+   <bean name="WebAppParsingDeployer" class="org.jboss.deployment.WebAppParsingDeployer">
+      <install bean="MainDeployer" method="addDeployer">
+         <parameter><this/></parameter>
+      </install>
+      <uninstall bean="MainDeployer" method="removeDeployer">
+         <parameter><this/></parameter>
+      </uninstall>
+   </bean>
+   <bean name="JBossWebAppParsingDeployer" class="org.jboss.deployment.JBossWebAppParsingDeployer">
+      <install bean="MainDeployer" method="addDeployer">
+         <parameter><this/></parameter>
+      </install>
+      <uninstall bean="MainDeployer" method="removeDeployer">
+         <parameter><this/></parameter>
+      </uninstall>
+   </bean>
+
+   <bean name="WarDeployer" class="org.jboss.web.tomcat.tc6.deployers.TomcatDeployer">
+      <install bean="MainDeployer" method="addDeployer">
+         <parameter><this/></parameter>
+      </install>
+      <uninstall bean="MainDeployer" method="removeDeployer">
+         <parameter><this/></parameter>
+      </uninstall>
+
+      <!-- The JAAS security domain to use in the absense of an explicit
+      security-domain specification in the war WEB-INF/jboss-web.xml
+      -->
+      <property name="defaultSecurityDomain">java:/jaas/other</property>
+
+      <!-- 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.
+      -->
+      <property name="java2ClassLoadingCompliance">false</property>
+      <!-- A flag indicating if the JBoss Loader should be used. This loader
+           uses a unified class loader as the class loader rather than the tomcat
+           specific class loader.
+           The default is false to ensure that wars have isolated class loading
+           for duplicate jars and jsp files.
+      -->
+      <property name="useJBossWebLoader">false</property>
+      <!-- The list of package prefixes that should not be loaded without
+         delegating to the parent class loader before trying the web app
+         class loader. The packages listed here are those tha are used by
+         the web container implementation and cannot be overriden. The format
+         is a comma separated list of the package names. There cannot be any
+         whitespace between the package prefixes.
+         This setting only applies when UseJBossWebLoader=false.
+      -->
+      <property name="filteredPackages">javax.servlet,org.apache.commons.logging</property>
+
+      <property name="lenientEjbLink">true</property>
+
+      <!--Flag to delete the Work Dir on Context Destroy -->
+      <property name="deleteWorkDirOnContextDestroy">false</property>
+
+      <!--
+          Class of the session manager (used if context is marked as 'distributable'. Currently allowed values:
+          - org.jboss.web.tomcat.tc6.session.JBossCacheManager
+      -->
+      <property name="managerClass">org.jboss.web.tomcat.tc6.session.JBossCacheManager</property>
+
+      <!-- The name of the request property under with the authenticated JAAS
+      Subject is stored on successful authentication. If null or empty then
+      the Subject will not be stored.
+      -->
+      <!--
+      <property name="subjectAttributeName">j_subject</property>
+      -->
+
+      <!-- The SessionIdAlphabet is the set of characters used to create a session Id
+           It must be made up of exactly 65 unique characters
+      <property name="sessionIdAlphabet">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-*</property>
+      -->
+
+      <!--
+      *******************************************************
+      ****************** CLUSTERING *************************
+      *******************************************************
+      In order to activate HTTP Session clustering for Tomcat
+      make sure you run JBoss's "all" configuration i.e.
+      "run -c all"
+      (the default configuration doesn't contain clustering)
+
+      Furthermore, you may change SnapshotMode and
+      SnapshotInterval propertys below to indicate when to
+      synchronize changes with the other node(s).
+
+      If you use Apache+mod_jk(2) you will most probably use
+      the AJP1.3 connector below. Thus, if you so wish,
+      you may comment (i.e. deactivate) the HTTP connector
+      as it won't be used anymore.
+
+      *******************************************************
+      *******************************************************
+      *******************************************************
+      -->
+		
+      <!--
+      If you are using clustering, the following two propertys
+      define when the sessions are replicated to the other nodes.
+      The default value, "instant", synchronously replicates changes
+      to the other nodes at the end of requests. In this case, the 
+      "SnapshotInterval" property is not used.
+      The "interval" mode, in association with the "SnapshotInterval"
+      property, indicates that modified sessions will only be replicated
+      every "SnapshotInterval" milliseconds at most.	
+		
+      Note that this property is not in effect if the replication-granularity
+      is set to FIELD. If it is FIELD, it will be per http request (that is, 
+      "instant" mode.)
+      -->
+      <property name="snapshotMode">instant</property> <!-- you may switch to "interval" -->
+      <property name="snapshotInterval">2000</property>
+
+      <!--
+      Whether to use MOD_JK(2) for load balancing with sticky session 
+      combined with JvmRoute. If set to true, it will insert a JvmRouteValve 
+      to intercept every request and replace the JvmRoute if it detects a 
+      failover. In addition, you will need to set the JvmRoute inside
+      Tomcat, e.g.,
+        Engine name="jboss.web" jmvRoute="Node1" defaultHost="localhost" 
+      in server.xml.
+
+      For clustering purpose only.
+      -->
+      <property name="useJK">false</property>
+
+      <property name="domain">jboss.web</property>
+		<property name="securityManagerService">
+			<inject bean="jboss.security:service=JaasSecurityManager" />
+	   </property>
+      
+      <depends>jboss:service=TransactionManager</depends>
+
+      <!-- Only needed if the org.jboss.web.tomcat.tc6.jca.CachedConnectionValve
+TODO: injection
+      is enabled in the tomcat server.xml file.
+      <depends>jboss.jca:service=CachedConnectionManager</depends>
+      -->
+   </bean>
+
+</deployment>




More information about the jboss-cvs-commits mailing list