You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gd...@apache.org on 2007/12/11 09:34:00 UTC

svn commit: r603174 [1/3] - in /geronimo/server/trunk: assemblies/geronimo-tomcat6-javaee5/ plugins/jetty/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/ plugins/jetty/jetty6-clustering-builder-wad...

Author: gdamour
Date: Tue Dec 11 00:33:18 2007
New Revision: 603174

URL: http://svn.apache.org/viewvc?rev=603174&view=rev
Log:
Add support for the clustering of Tomcat Web-applications over WADI. The change
replicates the same projects and design than for the clustering of Jetty
Web-applications over WADI.

A couple of things specific to Tomcat: we insert a Valve in front of all the 
Valves, even the Geronimo before after one, in order to hook-in the traversal
of the WADI Contextualiser stack prior to enter the web-application.

This fixes GERONIMO-3696 - Tomcat Clustering over WADI

Added:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/LICENSE.txt
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/NOTICE.txt
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/TomcatClusteringWADIConverter.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/pom.xml
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsd/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsd/geronimo-tomcat-clustering-wadi-1.2.xsd
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsdconfig/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsdconfig/xmlconfig.xml
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilderTest.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder_testBuiltGBeans.xml
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder_testOverrideDefaults.xml
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/LICENSE.txt
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/NOTICE.txt
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/pom.xml
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValve.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValveRetriever.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/cluster/AbstractClusteredValve.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/cluster/ClusteredManager.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/cluster/ClusteredManagerRetriever.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/cluster/
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/cluster/AbstractClusteredValveTest.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/cluster/ClusteredManagerTest.java
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-builder-wadi/
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-builder-wadi/LICENSE.txt
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-builder-wadi/NOTICE.txt
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-builder-wadi/pom.xml
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-builder-wadi/src/
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-builder-wadi/src/main/
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-builder-wadi/src/main/plan/
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-builder-wadi/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-wadi/
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-wadi/LICENSE.txt
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-wadi/NOTICE.txt
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-wadi/pom.xml
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-wadi/src/
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-wadi/src/main/
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-wadi/src/main/plan/
    geronimo/server/trunk/plugins/tomcat/tomcat6-clustering-wadi/src/main/plan/plan.xml
Modified:
    geronimo/server/trunk/assemblies/geronimo-tomcat6-javaee5/pom.xml
    geronimo/server/trunk/plugins/jetty/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java
    geronimo/server/trunk/plugins/jetty/jetty6-clustering-builder-wadi/pom.xml
    geronimo/server/trunk/plugins/jetty/jetty6-clustering-builder-wadi/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/pom.xml
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
    geronimo/server/trunk/plugins/tomcat/pom.xml
    geronimo/server/trunk/plugins/tomcat/tomcat6-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/tomcat/tomcat6/pom.xml

Modified: geronimo/server/trunk/assemblies/geronimo-tomcat6-javaee5/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-tomcat6-javaee5/pom.xml?rev=603174&r1=603173&r2=603174&view=diff
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-tomcat6-javaee5/pom.xml (original)
+++ geronimo/server/trunk/assemblies/geronimo-tomcat6-javaee5/pom.xml Tue Dec 11 00:33:18 2007
@@ -147,6 +147,20 @@
 
         <dependency>
             <groupId>org.apache.geronimo.configs</groupId>
+            <artifactId>tomcat6-clustering-wadi</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.configs</groupId>
+            <artifactId>tomcat6-clustering-builder-wadi</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.configs</groupId>
             <artifactId>system-database</artifactId>
             <version>${version}</version>
             <type>car</type>

Modified: geronimo/server/trunk/plugins/jetty/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java?rev=603174&r1=603173&r2=603174&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java (original)
+++ geronimo/server/trunk/plugins/jetty/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java Tue Dec 11 00:33:18 2007
@@ -60,6 +60,12 @@
     private static final QName CLUSTERING_WADI_QNAME = GerClusteringWadiDocument.type.getDocumentElementName();
     private static final QNameSet CLUSTERING_WADI_QNAME_SET = QNameSet.singleton(CLUSTERING_WADI_QNAME);
 
+    static  {
+        SchemaConversionUtils.registerNamespaceConversions(
+            Collections.singletonMap(CLUSTERING_WADI_QNAME.getLocalPart(),
+            new NamespaceElementConverter(CLUSTERING_WADI_QNAME.getNamespaceURI())));
+    }
+    
     private final int defaultSweepInterval;
     private final int defaultNumPartitions;
     private final AbstractNameQuery defaultBackingStrategyFactoryName;
@@ -71,15 +77,22 @@
             AbstractNameQuery defaultBackingStrategyFactoryName,
             AbstractNameQuery defaultClusterName,
             Environment defaultEnvironment) {
+        if (defaultSweepInterval < 1) {
+            throw new IllegalArgumentException("defaultSweepInterval is lower than 1");
+        } else if (defaultNumPartitions < 1) {
+            throw new IllegalArgumentException("defaultNumPartitions is lower than 1");
+        } else if (null == defaultBackingStrategyFactoryName) {
+            throw new IllegalArgumentException("defaultBackingStrategyFactoryName is required");
+        } else if (null == defaultClusterName) {
+            throw new IllegalArgumentException("defaultClusterName is required");
+        } else if (null == defaultEnvironment) {
+            throw new IllegalArgumentException("defaultEnvironment is required");
+        }
         this.defaultSweepInterval = defaultSweepInterval;
         this.defaultNumPartitions = defaultNumPartitions;
         this.defaultBackingStrategyFactoryName = defaultBackingStrategyFactoryName;
         this.defaultClusterName = defaultClusterName;
         this.defaultEnvironment = defaultEnvironment;
-        
-        SchemaConversionUtils.registerNamespaceConversions(
-            Collections.singletonMap(CLUSTERING_WADI_QNAME.getLocalPart(),
-            new NamespaceElementConverter(CLUSTERING_WADI_QNAME.getNamespaceURI())));
     }
 
     public void buildEnvironment(XmlObject container, Environment environment) throws DeploymentException {

Modified: geronimo/server/trunk/plugins/jetty/jetty6-clustering-builder-wadi/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty/jetty6-clustering-builder-wadi/pom.xml?rev=603174&r1=603173&r2=603174&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty/jetty6-clustering-builder-wadi/pom.xml (original)
+++ geronimo/server/trunk/plugins/jetty/jetty6-clustering-builder-wadi/pom.xml Tue Dec 11 00:33:18 2007
@@ -96,19 +96,6 @@
                                 <gbean name="JettyClusteringBuilder">
                                     <attribute name="defaultSweepInterval">${DefaultWadiSweepInterval}</attribute>
                                     <attribute name="defaultNumPartitions">${DefaultWadiNumPartitions}</attribute>
-                                    <!--<attribute name="defaultBackingStrategyFactoryName">?name=DefaultBackingStrategyFactory</attribute>-->
-                                    <!--<attribute name="defaultClusterName">?name=DefaultCluster</attribute>-->
-                                    <!--<xml-attribute name="defaultEnvironment" propertyEditor="org.apache.geronimo.deployment.service.EnvironmentBuilder">-->
-                                        <!--<environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">-->
-                                            <!--<dependencies>-->
-                                                <!--<dependency>-->
-                                                    <!--<groupId>${pom.groupId}</groupId>-->
-                                                    <!--<artifactId>jetty6-clustering-wadi</artifactId>-->
-                                                    <!--<type>car</type>-->
-                                                <!--</dependency>-->
-                                            <!--</dependencies>-->
-                                        <!--</environment>-->
-                                    <!--</xml-attribute>-->
                                 </gbean>
                              </config-xml-content>
                             <config-substitution key="DefaultWadiSweepInterval">36000</config-substitution>

Modified: geronimo/server/trunk/plugins/jetty/jetty6-clustering-builder-wadi/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty/jetty6-clustering-builder-wadi/src/main/plan/plan.xml?rev=603174&r1=603173&r2=603174&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty/jetty6-clustering-builder-wadi/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/jetty/jetty6-clustering-builder-wadi/src/main/plan/plan.xml Tue Dec 11 00:33:18 2007
@@ -21,7 +21,7 @@
 <module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
 
     <gbean name="JettyClusteringBuilder" class="org.apache.geronimo.jetty6.cluster.wadi.builder.WADIJettyClusteringBuilder">
-        <attribute name="defaultSweepInterval">36000</attribute>
+        <attribute name="defaultSweepInterval">10</attribute>
         <attribute name="defaultNumPartitions">24</attribute>
         <attribute name="defaultBackingStrategyFactoryName">?name=DefaultBackingStrategyFactory</attribute>
         <attribute name="defaultClusterName">?name=DefaultCluster</attribute>

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=603174&r1=603173&r2=603174&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Tue Dec 11 00:33:18 2007
@@ -17,6 +17,9 @@
 
 package org.apache.geronimo.tomcat.deployment;
 
+import static java.lang.Boolean.FALSE;
+import static java.lang.Boolean.TRUE;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileWriter;
@@ -36,6 +39,7 @@
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
+import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
@@ -63,15 +67,16 @@
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
 import org.apache.geronimo.security.jacc.ComponentPermissions;
-import org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean;
 import org.apache.geronimo.tomcat.LifecycleListenerGBean;
 import org.apache.geronimo.tomcat.ManagerGBean;
 import org.apache.geronimo.tomcat.RealmGBean;
 import org.apache.geronimo.tomcat.TomcatWebAppContext;
 import org.apache.geronimo.tomcat.ValveGBean;
+import org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
 import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
 import org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder;
+import org.apache.geronimo.xbeans.geronimo.j2ee.GerClusteringDocument;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.config.GerTomcatDocument;
@@ -101,24 +106,26 @@
 
     private static final Log log = LogFactory.getLog(TomcatModuleBuilder.class);
 
-    private final Environment defaultEnvironment;
-    private final AbstractNameQuery tomcatContainerName;
-
     private static final String TOMCAT_NAMESPACE = TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI();
     private static final String IS_JAVAEE = "IS_JAVAEE";
 
+    private final Environment defaultEnvironment;
+    private final AbstractNameQuery tomcatContainerName;
+    protected final NamespaceDrivenBuilderCollection clusteringBuilders;
+
     public TomcatModuleBuilder(Environment defaultEnvironment,
             AbstractNameQuery tomcatContainerName,
             Collection<WebServiceBuilder> webServiceBuilder,
             Collection securityBuilders,
             Collection serviceBuilders,
             NamingBuilder namingBuilders,
+            Collection<NamespaceDrivenBuilder> clusteringBuilders,
             Collection<ModuleBuilderExtension> moduleBuilderExtensions,
             ResourceEnvironmentSetter resourceEnvironmentSetter,
             Kernel kernel) {
         super(kernel, securityBuilders, serviceBuilders, namingBuilders, resourceEnvironmentSetter, webServiceBuilder, moduleBuilderExtensions);
         this.defaultEnvironment = defaultEnvironment;
-
+        this.clusteringBuilders = new NamespaceDrivenBuilderCollection(clusteringBuilders, GerClusteringDocument.type.getDocumentElementName());
         this.tomcatContainerName = tomcatContainerName;
     }
 
@@ -175,10 +182,14 @@
         TomcatWebAppType tomcatWebApp = getTomcatWebApp(plan, moduleFile, standAlone, targetPath, webApp);
         contextRoot = getContextRoot(tomcatWebApp, contextRoot, webApp, standAlone, moduleFile, targetPath);
 
-
         EnvironmentType environmentType = tomcatWebApp.getEnvironment();
         Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
 
+        Boolean distributable = webApp.getDistributableArray().length == 1 ? TRUE : FALSE;
+        if (TRUE == distributable) {
+            clusteringBuilders.buildEnvironment(tomcatWebApp, environment);
+        }
+        
         // Note: logic elsewhere depends on the default artifact ID being the file name less extension (ConfigIDExtractor)
         String warName = "";
         File temp = new File(moduleFile.getName());
@@ -364,6 +375,14 @@
                 AbstractName managerName = earContext.getNaming().createChildName(moduleName, manager, ManagerGBean.J2EE_TYPE);
                 webModuleData.setReferencePattern("Manager", managerName);
             }
+            
+            Boolean distributable = webApp.getDistributableArray().length == 1 ? TRUE : FALSE;
+            if (TRUE == distributable) {
+                clusteringBuilders.build(tomcatWebApp, earContext, moduleContext);
+                if (null == webModuleData.getReferencePatterns(TomcatWebAppContext.GBEAN_REF_CLUSTERED_VALVE_RETRIEVER)) {
+                    log.warn("No clustering builders configured: app will not be clustered");
+                }
+            }
 
             //Handle the role permissions and webservices on the servlets.
             ServletType[] servletTypes = webApp.getServletArray();
@@ -533,6 +552,7 @@
 
 
     public static final GBeanInfo GBEAN_INFO;
+    public static final String GBEAN_REF_CLUSTERING_BUILDERS = "ClusteringBuilders";
 
     static {
         GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(TomcatModuleBuilder.class, NameFactory.MODULE_BUILDER);
@@ -542,6 +562,7 @@
         infoBuilder.addReference("SecurityBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("ServiceBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("NamingBuilders", NamingBuilder.class, NameFactory.MODULE_BUILDER);
+        infoBuilder.addReference(GBEAN_REF_CLUSTERING_BUILDERS, NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("ModuleBuilderExtensions", ModuleBuilderExtension.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("ResourceEnvironmentSetter", ResourceEnvironmentSetter.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addAttribute("kernel", Kernel.class, false);
@@ -554,6 +575,7 @@
                 "SecurityBuilders",
                 "ServiceBuilders",
                 "NamingBuilders",
+                GBEAN_REF_CLUSTERING_BUILDERS,
                 "ModuleBuilderExtensions",
                 "ResourceEnvironmentSetter",
                 "kernel"});

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd?rev=603174&r1=603173&r2=603174&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd Tue Dec 11 00:33:18 2007
@@ -127,6 +127,15 @@
                 </xs:annotation>
             </xs:element>
 
+            <xs:element ref="app:clustering" minOccurs="0">
+                <xs:annotation>
+                    <xs:documentation>
+                        Reference to abstract clustering element defined in
+                        imported "geronimo-application-2.0.xsd"
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:element>
+
             <!--<xs:element name="context-priority-classloader" type="xs:boolean" minOccurs="0"/>-->
 
             <xs:element ref="naming:web-container" minOccurs="0">

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java?rev=603174&r1=603173&r2=603174&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java Tue Dec 11 00:33:18 2007
@@ -54,7 +54,16 @@
     private TomcatModuleBuilder builder;
 
     protected void setUp() throws Exception {
-        builder = new TomcatModuleBuilder(defaultEnvironment, tomcatContainerObjectName, Collections.singleton(webServiceBuilder), Collections.singleton(new GeronimoSecurityBuilderImpl(null)), Collections.singleton(new GBeanBuilder(null, null)), new NamingBuilderCollection(null, null), null, new MockResourceEnvironmentSetter(), null);
+        builder = new TomcatModuleBuilder(defaultEnvironment,
+            tomcatContainerObjectName,
+            Collections.singleton(webServiceBuilder),
+            Collections.singleton(new GeronimoSecurityBuilderImpl(null)),
+            Collections.singleton(new GBeanBuilder(null, null)),
+            new NamingBuilderCollection(null, null),
+            Collections.EMPTY_LIST,
+            null,
+            new MockResourceEnvironmentSetter(),
+            null);
     }
 
     public void testResourceRef() throws Exception {

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?rev=603174&r1=603173&r2=603174&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java Tue Dec 11 00:33:18 2007
@@ -333,7 +333,17 @@
 
         defaultEnvironment.addDependency(baseId, ImportType.ALL);
         defaultEnvironment.setConfigId(webModuleArtifact);
-        builder = new TomcatModuleBuilder(defaultEnvironment, new AbstractNameQuery(containerName), Collections.singleton(webServiceBuilder), Collections.singleton(new GeronimoSecurityBuilderImpl(new AbstractNameQuery(URI.create("?name=CredentialStore")))), Collections.singleton(new GBeanBuilder(null, null)), new NamingBuilderCollection(null, null), null, new MockResourceEnvironmentSetter(), null);
+        builder = new TomcatModuleBuilder(defaultEnvironment,
+            new AbstractNameQuery(containerName),
+            Collections.singleton(webServiceBuilder),
+            Collections.singleton(new GeronimoSecurityBuilderImpl(new AbstractNameQuery(URI
+                    .create("?name=CredentialStore")))),
+            Collections.singleton(new GBeanBuilder(null, null)),
+            new NamingBuilderCollection(null, null),
+            Collections.EMPTY_LIST,
+            null,
+            new MockResourceEnvironmentSetter(),
+            null);
     }
 
     protected void tearDown() throws Exception {

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/LICENSE.txt
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/LICENSE.txt?rev=603174&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/LICENSE.txt (added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/LICENSE.txt Tue Dec 11 00:33:18 2007
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/NOTICE.txt
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/NOTICE.txt?rev=603174&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/NOTICE.txt (added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/NOTICE.txt Tue Dec 11 00:33:18 2007
@@ -0,0 +1,5 @@
+Apache Geronimo 
+Copyright 2003-2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/TomcatClusteringWADIConverter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/TomcatClusteringWADIConverter.java?rev=603174&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/TomcatClusteringWADIConverter.java (added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/TomcatClusteringWADIConverter.java Tue Dec 11 00:33:18 2007
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.tomcat.cluster.wadi.builder;
+
+import javax.xml.namespace.QName;
+
+import org.apache.geronimo.schema.ElementConverter;
+import org.apache.geronimo.xbeans.geronimo.GerTomcatClusteringWadiDocument;
+import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
+import org.apache.xmlbeans.XmlCursor;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class TomcatClusteringWADIConverter implements ElementConverter {
+    private static final String TOMCAT_CLUSTERING_WADI_NS = GerTomcatClusteringWadiDocument.type.getDocumentElementName().getNamespaceURI();
+    private static final String NAMING_NS = GerPatternType.type.getName().getNamespaceURI();
+    private static final String CLUSTER_ELEMENT_NAME = "cluster";
+    private static final String BACKING_STRATEGY_FACTORY_ELEMENT_NAME = "backing-strategy-factory";
+
+    public void convertElement(XmlCursor cursor, XmlCursor end) {
+        end.toCursor(cursor);
+        end.toEndToken();
+
+        while (cursor.hasNextToken() && cursor.isLeftOf(end)) {
+            if (cursor.isStart()) {
+                String localPart = cursor.getName().getLocalPart();
+                cursor.setName(new QName(TOMCAT_CLUSTERING_WADI_NS, localPart));
+                if (localPart.equals(CLUSTER_ELEMENT_NAME) || localPart.equals(BACKING_STRATEGY_FACTORY_ELEMENT_NAME)) {
+                    convertChildrenToNamingNS(cursor);
+                    cursor.toEndToken();
+                }
+            }
+            cursor.toNextToken();
+        }
+    }
+
+    protected void convertChildrenToNamingNS(XmlCursor cursor) {
+        XmlCursor namingCursor = cursor.newCursor();
+        try {
+            if (namingCursor.toFirstChild()) {
+                XmlCursor endNamingCursor = namingCursor.newCursor();
+                try {
+                    convertToNamingNS(namingCursor, endNamingCursor);
+                } finally {
+                    endNamingCursor.dispose();
+                }
+            }
+        } finally {
+            namingCursor.dispose();
+        }
+    }
+
+    protected void convertToNamingNS(XmlCursor cursor, XmlCursor end) {
+        end.toCursor(cursor);
+        end.toEndToken();
+        while (cursor.hasNextToken() && cursor.isLeftOf(end)) {
+            if (cursor.isStart()) {
+                String localPart = cursor.getName().getLocalPart();
+                cursor.setName(new QName(NAMING_NS, localPart));
+            }
+            cursor.toNextToken();
+        }
+    }
+
+}

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java?rev=603174&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java (added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java Tue Dec 11 00:33:18 2007
@@ -0,0 +1,331 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.tomcat.cluster.wadi.builder;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.geronimo.clustering.wadi.BasicWADISessionManager;
+import org.apache.geronimo.clustering.wadi.WADISessionManagerConfigInfo;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
+import org.apache.geronimo.deployment.service.EnvironmentBuilder;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
+import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.tomcat.TomcatWebAppContext;
+import org.apache.geronimo.tomcat.cluster.ClusteredManagerRetriever;
+import org.apache.geronimo.tomcat.cluster.wadi.WADIClusteredValveRetriever;
+import org.apache.geronimo.xbeans.geronimo.GerTomcatClusteringWadiDocument;
+import org.apache.geronimo.xbeans.geronimo.GerTomcatClusteringWadiType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
+import org.apache.xmlbeans.QNameSet;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class WADITomcatClusteringBuilder implements NamespaceDrivenBuilder {
+    private static final QName CLUSTERING_WADI_QNAME = GerTomcatClusteringWadiDocument.type.getDocumentElementName();
+    private static final QNameSet CLUSTERING_WADI_QNAME_SET = QNameSet.singleton(CLUSTERING_WADI_QNAME);
+
+    static {
+        SchemaConversionUtils.registerNamespaceConversions(
+            Collections.singletonMap(CLUSTERING_WADI_QNAME.getLocalPart(),
+            new TomcatClusteringWADIConverter()));
+    }
+    
+    private final int defaultSweepInterval;
+    private final int defaultSessionTimeout;
+    private final int defaultNumPartitions;
+    private final AbstractNameQuery defaultBackingStrategyFactoryName;
+    private final AbstractNameQuery defaultClusterName;
+    private final Environment defaultEnvironment;
+
+    public WADITomcatClusteringBuilder(int defaultSweepInterval,
+            int defaultSessionTimeout,
+            int defaultNumPartitions,
+            AbstractNameQuery defaultBackingStrategyFactoryName,
+            AbstractNameQuery defaultClusterName,
+            Environment defaultEnvironment) {
+        if (defaultSweepInterval < 1) {
+            throw new IllegalArgumentException("defaultSweepInterval is lower than 1");
+        } else if (defaultSessionTimeout < 1) {
+            throw new IllegalArgumentException("defaultSessionTimeout is lower than 1");
+        } else if (defaultNumPartitions < 1) {
+            throw new IllegalArgumentException("defaultNumPartitions is lower than 1");
+        } else if (null == defaultBackingStrategyFactoryName) {
+            throw new IllegalArgumentException("defaultBackingStrategyFactoryName is required");
+        } else if (null == defaultClusterName) {
+            throw new IllegalArgumentException("defaultClusterName is required");
+        } else if (null == defaultEnvironment) {
+            throw new IllegalArgumentException("defaultEnvironment is required");
+        }
+        this.defaultSweepInterval = defaultSweepInterval;
+        this.defaultSessionTimeout = defaultSessionTimeout;
+        this.defaultNumPartitions = defaultNumPartitions;
+        this.defaultBackingStrategyFactoryName = defaultBackingStrategyFactoryName;
+        this.defaultClusterName = defaultClusterName;
+        this.defaultEnvironment = defaultEnvironment;
+    }
+
+    public void buildEnvironment(XmlObject container, Environment environment) throws DeploymentException {
+        if (getWadiClusterConfig(container) != null) {
+            EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+        }
+    }
+
+    public void build(XmlObject container, DeploymentContext applicationContext, DeploymentContext moduleContext)
+            throws DeploymentException {
+        GerTomcatClusteringWadiType clusteringWadiType = getWadiClusterConfig(container);
+        if (clusteringWadiType != null) {
+            GBeanData webModuleData = extractWebModule(moduleContext);
+            try {
+                AbstractName sessionManagerName = addSessionManager(clusteringWadiType, webModuleData, moduleContext);
+                addClusteredManagerRetriever(moduleContext, webModuleData, sessionManagerName);
+                addClusteredValveRetriever(moduleContext, webModuleData, sessionManagerName);
+            } catch (GBeanAlreadyExistsException e) {
+                throw new DeploymentException("Duplicate GBean", e);
+            }
+        }
+    }
+
+    protected GBeanData extractWebModule(DeploymentContext moduleContext) throws DeploymentException {
+        Configuration configuration = moduleContext.getConfiguration();
+        AbstractNameQuery webModuleQuery = new AbstractNameQuery(configuration.getId(),
+            Collections.EMPTY_MAP,
+            Collections.singleton(TomcatWebAppContext.class.getName()));
+        try {
+            return configuration.findGBeanData(webModuleQuery);
+        } catch (GBeanNotFoundException e) {
+            throw new DeploymentException("Could not locate web module gbean in web app configuration", e);
+        }
+    }
+
+    public QNameSet getSpecQNameSet() {
+        return QNameSet.EMPTY;
+    }
+
+    public QNameSet getPlanQNameSet() {
+        return CLUSTERING_WADI_QNAME_SET;
+    }
+
+    protected GerTomcatClusteringWadiType getWadiClusterConfig(XmlObject container) throws DeploymentException {
+        XmlObject[] items = container.selectChildren(CLUSTERING_WADI_QNAME_SET);
+        if (items.length > 1) {
+            throw new DeploymentException("Unexpected count of clustering elements in geronimo plan " + items.length
+                    + " qnameset: " + CLUSTERING_WADI_QNAME_SET);
+        }
+        if (items.length == 1) {
+            return (GerTomcatClusteringWadiType) items[0].copy().changeType(GerTomcatClusteringWadiType.type);
+        }
+        return null;
+    }
+
+    protected AbstractName addSessionManager(GerTomcatClusteringWadiType clustering,
+            GBeanData webModuleData,
+            DeploymentContext moduleContext) throws GBeanAlreadyExistsException {
+        AbstractName name = newGBeanName(moduleContext, "WADISessionManager");
+
+        GBeanData beanData = new GBeanData(name, BasicWADISessionManager.GBEAN_INFO);
+
+        setConfigInfo(clustering, webModuleData, beanData);
+        setCluster(clustering, beanData);
+        setBackingStrategyFactory(clustering, beanData);
+
+        addGBean(moduleContext, beanData);
+
+        return name;
+    }
+
+    protected void setConfigInfo(GerTomcatClusteringWadiType clustering, GBeanData webModuleData, GBeanData beanData) {
+        int sweepInterval = getSweepInterval(clustering);
+        int numPartitions = getNumberOfPartitions(clustering);
+        Integer sessionTimeout = getSessionTimeout(webModuleData);
+        boolean disableReplication = isDisableReplication(clustering);
+        boolean deltaReplication = isDeltaReplication(clustering);
+        
+        String contextPath = (String) webModuleData.getAttribute("contextPath");
+        URI serviceSpaceName;
+        try {
+            serviceSpaceName = new URI(contextPath);
+        } catch (URISyntaxException e) {
+            AssertionError error = new AssertionError("contextPath [" + contextPath + "] cannot be parsed as an URI.");
+            throw (AssertionError) error.initCause(e);
+        }
+        
+        WADISessionManagerConfigInfo configInfo = new WADISessionManagerConfigInfo(serviceSpaceName,
+                sweepInterval,
+                numPartitions,
+                sessionTimeout.intValue(),
+                disableReplication,
+                deltaReplication);
+        beanData.setAttribute(BasicWADISessionManager.GBEAN_ATTR_WADI_CONFIG_INFO, configInfo);
+    }
+
+    protected Integer getSessionTimeout(GBeanData webModuleData) throws AssertionError {
+        return defaultSessionTimeout;
+    }
+
+    protected boolean isDeltaReplication(GerTomcatClusteringWadiType clustering) {
+        if (clustering.isSetDeltaReplication()) {
+            return clustering.getDeltaReplication();
+        }
+        return false;
+    }
+
+    protected boolean isDisableReplication(GerTomcatClusteringWadiType clustering) {
+        if (clustering.isSetDisableReplication()) {
+            return clustering.getDisableReplication();
+        }
+        return false;
+    }
+
+    protected int getNumberOfPartitions(GerTomcatClusteringWadiType clustering) {
+        if (clustering.isSetNumPartitions()) {
+            return clustering.getNumPartitions().intValue();
+        }
+        return defaultNumPartitions;
+    }
+
+    protected int getSweepInterval(GerTomcatClusteringWadiType clustering) {
+        if (clustering.isSetSweepInterval()) {
+            return clustering.getSweepInterval().intValue();
+        }
+        return defaultSweepInterval;
+    }
+
+    protected void setCluster(GerTomcatClusteringWadiType clustering, GBeanData beanData) {
+        Set patterns = new HashSet();
+        if (clustering.isSetCluster()) {
+            addAbstractNameQueries(patterns, clustering.getCluster());
+        } else {
+            patterns.add(defaultClusterName);
+        }
+        beanData.setReferencePatterns(BasicWADISessionManager.GBEAN_REF_CLUSTER, patterns);
+    }
+
+    protected void setBackingStrategyFactory(GerTomcatClusteringWadiType clustering, GBeanData beanData) {
+        Set patterns = new HashSet();
+        if (clustering.isSetBackingStrategyFactory()) {
+            addAbstractNameQueries(patterns, clustering.getBackingStrategyFactory());
+        } else {
+            patterns.add(defaultBackingStrategyFactoryName);
+        }
+        beanData.setReferencePatterns(BasicWADISessionManager.GBEAN_REF_BACKING_STRATEGY_FACTORY, patterns);
+    }
+
+    protected AbstractName addClusteredValveRetriever(DeploymentContext moduleContext,
+            GBeanData webModuleData,
+            AbstractName sessionManagerName) throws GBeanAlreadyExistsException {
+        AbstractName name = newGBeanName(moduleContext, "WADIClusteredValveRetriever");
+
+        GBeanData beanData = new GBeanData(name, WADIClusteredValveRetriever.GBEAN_INFO);
+        beanData.setReferencePattern(WADIClusteredValveRetriever.GBEAN_REF_WADI_SESSION_MANAGER, sessionManagerName);
+
+        webModuleData.setReferencePattern(TomcatWebAppContext.GBEAN_REF_CLUSTERED_VALVE_RETRIEVER, name);
+
+        addGBean(moduleContext, beanData);
+
+        return name;
+    }
+
+    protected AbstractName addClusteredManagerRetriever(DeploymentContext moduleContext,
+            GBeanData webModuleData,
+            AbstractName sessionManagerName) throws GBeanAlreadyExistsException {
+        AbstractName name = newGBeanName(moduleContext, "ClusteredManagerRetriever");
+
+        GBeanData beanData = new GBeanData(name, ClusteredManagerRetriever.GBEAN_INFO);
+        beanData.setReferencePattern(ClusteredManagerRetriever.GBEAN_REF_SESSION_MANAGER, sessionManagerName);
+
+        webModuleData.setReferencePattern(TomcatWebAppContext.GBEAN_REF_MANAGER_RETRIEVER, name);
+
+        addGBean(moduleContext, beanData);
+
+        return name;
+    }
+    
+    protected void addGBean(DeploymentContext moduleContext, GBeanData beanData) throws GBeanAlreadyExistsException {
+        moduleContext.addGBean(beanData);
+    }
+
+    protected AbstractName newGBeanName(DeploymentContext moduleContext, String name) {
+        return moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
+                name,
+                NameFactory.GERONIMO_SERVICE);
+    }
+
+    protected void addAbstractNameQueries(Set patterns, GerPatternType patternType) {
+        AbstractNameQuery query = ENCConfigBuilder.buildAbstractNameQuery(patternType, null, null, null);
+        patterns.add(query);
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static final String GBEAN_ATTR_DFT_SWEEP_INTERVAL = "defaultSweepInterval";
+    public static final String GBEAN_ATTR_DFT_SESSION_TIMEOUT = "defaultSessionTimeout";
+    public static final String GBEAN_ATTR_DFT_NUM_PARTITIONS = "defaultNumPartitions";
+    public static final String GBEAN_ATTR_DFT_BACKING_STRATEGY_FACTORY_NAME = "defaultBackingStrategyFactoryName";
+    public static final String GBEAN_ATTR_DFT_CLUSTER_NAME = "defaultClusterName";
+    public static final String GBEAN_ATTR_DFT_ENVIRONMENT = "defaultEnvironment";
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic("WADI Session Manager",
+                WADITomcatClusteringBuilder.class,
+                NameFactory.MODULE_BUILDER);
+
+        infoBuilder.addAttribute(GBEAN_ATTR_DFT_SWEEP_INTERVAL, int.class, true);
+        infoBuilder.addAttribute(GBEAN_ATTR_DFT_SESSION_TIMEOUT, int.class, true);
+        infoBuilder.addAttribute(GBEAN_ATTR_DFT_NUM_PARTITIONS, int.class, true);
+        infoBuilder.addAttribute(GBEAN_ATTR_DFT_BACKING_STRATEGY_FACTORY_NAME, AbstractNameQuery.class, true);
+        infoBuilder.addAttribute(GBEAN_ATTR_DFT_CLUSTER_NAME, AbstractNameQuery.class, true);
+        infoBuilder.addAttribute(GBEAN_ATTR_DFT_ENVIRONMENT, Environment.class, true);
+
+        infoBuilder.setConstructor(new String[]{GBEAN_ATTR_DFT_SWEEP_INTERVAL,
+                GBEAN_ATTR_DFT_SESSION_TIMEOUT,
+                GBEAN_ATTR_DFT_NUM_PARTITIONS,
+                GBEAN_ATTR_DFT_BACKING_STRATEGY_FACTORY_NAME,
+                GBEAN_ATTR_DFT_CLUSTER_NAME,
+                GBEAN_ATTR_DFT_ENVIRONMENT});
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/pom.xml?rev=603174&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/pom.xml (added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/pom.xml Tue Dec 11 00:33:18 2007
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev: 598023 $ $Date: 2007-11-26 05:08:16 +1100 (Mon, 26 Nov 2007) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.geronimo.modules</groupId>
+        <artifactId>modules</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>geronimo-tomcat6-clustering-builder-wadi</artifactId>
+    <name>Geronimo Modules :: Tomcat :: Clustering Builder for WADI</name>
+    
+    <dependencies>
+        <!-- xmlbeans, stax-api comes transitively via g-service-builder from this -->
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>geronimo-naming-builder</artifactId>
+            <version>${version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>geronimo-tomcat6-builder</artifactId>
+            <version>${version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>geronimo-tomcat6-clustering-wadi</artifactId>
+            <version>${version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>geronimo-web-2.5-builder</artifactId>
+            <version>${version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>xmlbeans-maven-plugin</artifactId>
+            </plugin>
+            
+            <!--
+            HACK: Copy XmlBeans generated schemas.
+            -->
+            <plugin>
+                <groupId>org.apache.geronimo.buildsupport</groupId>
+                <artifactId>buildsupport-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>copy-xmlbeans-schemas</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
+

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsd/geronimo-tomcat-clustering-wadi-1.2.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsd/geronimo-tomcat-clustering-wadi-1.2.xsd?rev=603174&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsd/geronimo-tomcat-clustering-wadi-1.2.xsd (added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsd/geronimo-tomcat-clustering-wadi-1.2.xsd Tue Dec 11 00:33:18 2007
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<xs:schema xmlns="http://www.w3.org/2001/XMLSchema"
+    targetNamespace="http://geronimo.apache.org/xml/ns/tomcat-clustering-wadi-1.2"
+    xmlns:clust-wadi="http://geronimo.apache.org/xml/ns/tomcat-clustering-wadi-1.2"
+    xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
+    xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    elementFormDefault="qualified"
+    attributeFormDefault="unqualified">
+
+    <xs:import namespace="http://geronimo.apache.org/xml/ns/naming-1.2" schemaLocation="geronimo-naming-1.2.xsd"/>
+    <xs:import namespace="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" schemaLocation="geronimo-application-2.0.xsd"/>
+
+    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+
+    <xs:element name="tomcat-clustering-wadi" type="clust-wadi:tomcat-clustering-wadiType" substitutionGroup="app:clustering"/>
+
+    <xs:complexType name="tomcat-clustering-wadiType">
+        <xs:complexContent>
+            <xs:extension base="app:abstract-clusteringType">
+            <xs:sequence>
+                <xs:element name="sweepInterval" type="xs:integer" minOccurs="0"/>
+                <xs:element name="numPartitions" type="xs:integer" minOccurs="0"/>
+                <xs:element name="cluster" type="naming:patternType" minOccurs="0"/>
+                <xs:element name="disableReplication" type="xs:boolean" minOccurs="0"/>
+                <xs:element name="deltaReplication" type="xs:boolean" minOccurs="0"/>
+                <xs:element name="backing-strategy-factory" type="naming:patternType" minOccurs="0"/>
+            </xs:sequence>
+        </xs:extension>
+        </xs:complexContent>
+    </xs:complexType>
+
+</xs:schema>
+

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsdconfig/xmlconfig.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsdconfig/xmlconfig.xml?rev=603174&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsdconfig/xmlconfig.xml (added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/xsdconfig/xmlconfig.xml Tue Dec 11 00:33:18 2007
@@ -0,0 +1,25 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config"
+    >
+
+    <xb:namespace uri="http://geronimo.apache.org/xml/ns/tomcat-clustering-wadi-1.2">
+        <xb:package>org.apache.geronimo.xbeans.geronimo</xb:package>
+        <xb:prefix>Ger</xb:prefix>
+    </xb:namespace>
+
+</xb:config>

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilderTest.java?rev=603174&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilderTest.java (added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilderTest.java Tue Dec 11 00:33:18 2007
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.tomcat.cluster.wadi.builder;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.geronimo.clustering.wadi.BasicWADISessionManager;
+import org.apache.geronimo.clustering.wadi.WADISessionManagerConfigInfo;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.tomcat.TomcatWebAppContext;
+import org.apache.geronimo.tomcat.cluster.ClusteredManagerRetriever;
+import org.apache.geronimo.tomcat.cluster.wadi.WADIClusteredValveRetriever;
+import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
+import org.apache.geronimo.xbeans.geronimo.j2ee.GerClusteringDocument;
+import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppDocument;
+import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType;
+import org.apache.geronimo.xbeans.geronimo.web.tomcat.config.GerTomcatDocument;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.codehaus.wadi.replication.strategy.BackingStrategyFactory;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class WADITomcatClusteringBuilderTest extends TestCase {
+
+    private AbstractNameQuery clusterNameQuery;
+    private AbstractNameQuery backingStrategyFactoryQuery;
+    private WADITomcatClusteringBuilder builder;
+    private Artifact artifact;
+    private Map<AbstractName, GBeanData> addedGBeanData;
+    private String contextPath;
+
+    @Override
+    protected void setUp() throws Exception {
+        artifact = new Artifact("groupId", "artifactId", "2.0", "car");
+        clusterNameQuery = new AbstractNameQuery(artifact, Collections.singletonMap("name", "ClusterName"));
+        backingStrategyFactoryQuery = new AbstractNameQuery(BackingStrategyFactory.class.getName());
+        contextPath = "/test-path";
+        addedGBeanData = new HashMap<AbstractName, GBeanData>();
+        
+        builder = new WADITomcatClusteringBuilder(1,
+            2,
+            3,
+            backingStrategyFactoryQuery,
+            clusterNameQuery,
+            new Environment()) {
+            @Override
+            protected GBeanData extractWebModule(DeploymentContext moduleContext) throws DeploymentException {
+                GBeanData gbeanData = new GBeanData(TomcatWebAppContext.GBEAN_INFO);
+                gbeanData.setAttribute("contextPath", contextPath);
+                return gbeanData;
+            }
+            @Override
+            protected AbstractName newGBeanName(DeploymentContext moduleContext, String name) {
+                return newGBeanNameFor(name);
+            }
+            @Override
+            protected void addGBean(DeploymentContext moduleContext, GBeanData beanData) throws GBeanAlreadyExistsException {
+                addedGBeanData.put(beanData.getAbstractName(), beanData);
+            }
+        };
+        
+        new NamespaceDrivenBuilderCollection(Collections.singleton(builder), GerClusteringDocument.type.getDocumentElementName());
+    }
+    
+    public void testBuiltGBeans() throws Exception {
+        XmlObject container = newContainer("testBuiltGBeans");
+
+        builder.build(container, null, null);
+        
+        GBeanData beanData = addedGBeanData.get(newGBeanNameFor("WADISessionManager"));
+        assertSessionManagerWithDefault(beanData);
+        
+        beanData = addedGBeanData.get(newGBeanNameFor("ClusteredManagerRetriever"));
+        assertClusteredManagerRetriever(beanData);
+        
+        beanData = addedGBeanData.get(newGBeanNameFor("WADIClusteredValveRetriever"));
+        assertClusteredValveRetriever(beanData);
+    }
+
+    public void testOverrideDefaults() throws Exception {
+        XmlObject container = newContainer("testOverrideDefaults");
+        
+        builder.build(container, null, null);
+        
+        GBeanData beanData = addedGBeanData.get(newGBeanNameFor("WADISessionManager"));
+        assertPattern(beanData, BasicWADISessionManager.GBEAN_REF_BACKING_STRATEGY_FACTORY,
+            new AbstractNameQuery(null, Collections.singletonMap("name", "SpecificFactoryName")));
+        assertPattern(beanData, BasicWADISessionManager.GBEAN_REF_CLUSTER,
+            new AbstractNameQuery(null, Collections.singletonMap("name", "SpecificClusterName")));
+        
+        WADISessionManagerConfigInfo configInfo = (WADISessionManagerConfigInfo)
+            beanData.getAttribute(BasicWADISessionManager.GBEAN_ATTR_WADI_CONFIG_INFO);
+        assertEquals(10, configInfo.getSweepInterval());
+        assertEquals(2, configInfo.getSessionTimeoutSeconds());
+        assertEquals(12, configInfo.getNumPartitions());
+        assertTrue(configInfo.isDeltaReplication());
+        assertTrue(configInfo.isDisableReplication());
+    }
+    
+    private void assertClusteredValveRetriever(GBeanData beanData) {
+        assertNotNull(beanData);
+        assertName(beanData,
+            WADIClusteredValveRetriever.GBEAN_REF_WADI_SESSION_MANAGER,
+            newGBeanNameFor("WADISessionManager"));
+    }
+
+    private void assertClusteredManagerRetriever(GBeanData beanData) {
+        assertNotNull(beanData);
+        assertName(beanData,
+            ClusteredManagerRetriever.GBEAN_REF_SESSION_MANAGER,
+            newGBeanNameFor("WADISessionManager"));
+    }
+
+    private void assertSessionManagerWithDefault(GBeanData beanData) throws URISyntaxException {
+        assertNotNull(beanData);
+        assertPattern(beanData, BasicWADISessionManager.GBEAN_REF_BACKING_STRATEGY_FACTORY, backingStrategyFactoryQuery);
+        assertPattern(beanData, BasicWADISessionManager.GBEAN_REF_CLUSTER, clusterNameQuery);
+        
+        WADISessionManagerConfigInfo configInfo = (WADISessionManagerConfigInfo)
+            beanData.getAttribute(BasicWADISessionManager.GBEAN_ATTR_WADI_CONFIG_INFO);
+        assertEquals(1, configInfo.getSweepInterval());
+        assertEquals(2, configInfo.getSessionTimeoutSeconds());
+        assertEquals(3, configInfo.getNumPartitions());
+        assertEquals(new URI(contextPath), configInfo.getServiceSpaceURI());
+        assertFalse(configInfo.isDeltaReplication());
+        assertFalse(configInfo.isDisableReplication());
+    }
+
+    private void assertPattern(GBeanData beanData, String refName, AbstractNameQuery query) {
+        ReferencePatterns refPatterns = beanData.getReferencePatterns(refName);
+        Set<AbstractNameQuery> patterns = refPatterns.getPatterns();
+        assertEquals(1, patterns.size());
+        AbstractNameQuery pattern = patterns.iterator().next();
+        assertEquals(query, pattern);
+    }
+
+    private void assertName(GBeanData beanData, String refName, AbstractName name) {
+        ReferencePatterns refPatterns = beanData.getReferencePatterns(refName);
+        assertEquals(name, refPatterns.getAbstractName());
+    }
+    
+    private AbstractName newGBeanNameFor(String name) {
+        return new AbstractName(artifact, Collections.singletonMap("name", name));
+    }
+
+    private XmlObject newContainer(String suffix) throws IOException, XmlException, DeploymentException {
+        XmlObject rawPlan = XmlBeansUtil.parse(
+            getClass().getResourceAsStream("WADITomcatClusteringBuilder_" + suffix + ".xml"));
+        GenericToSpecificPlanConverter planConverter = new GenericToSpecificPlanConverter(
+            GerTomcatDocument.type.getDocumentElementName().getNamespaceURI(),
+            TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI(), "tomcat");
+        XmlObject container = planConverter.convertToSpecificPlan(rawPlan);
+        container = container.changeType(TomcatWebAppType.type);
+        XmlBeansUtil.validateDD(container);
+        return container;
+    }
+
+}

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder_testBuiltGBeans.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder_testBuiltGBeans.xml?rev=603174&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder_testBuiltGBeans.xml (added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder_testBuiltGBeans.xml Tue Dec 11 00:33:18 2007
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+    
+     http://www.apache.org/licenses/LICENSE-2.0
+    
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Rev: 602280 $ $Date: 2007-12-08 11:17:52 +1100 (Sat, 08 Dec 2007) $ -->
+
+<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.2">
+
+    <environment>
+        <moduleId>
+            <groupId>groupId</groupId>
+            <artifactId>artifactId</artifactId>
+            <version>2.0</version>
+            <type>war</type>
+        </moduleId>
+    </environment>
+
+   <tomcat-clustering-wadi />
+
+</web-app>

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder_testOverrideDefaults.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder_testOverrideDefaults.xml?rev=603174&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder_testOverrideDefaults.xml (added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/resources/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder_testOverrideDefaults.xml Tue Dec 11 00:33:18 2007
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+    
+     http://www.apache.org/licenses/LICENSE-2.0
+    
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Rev: 602280 $ $Date: 2007-12-08 11:17:52 +1100 (Sat, 08 Dec 2007) $ -->
+
+<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.2"
+    xmlns:clust-wadi="http://geronimo.apache.org/xml/ns/tomcat-clustering-wadi-1.2"
+    xmlns:gernaming="http://geronimo.apache.org/xml/ns/naming-1.2">
+
+    <environment>
+        <moduleId>
+            <groupId>groupId</groupId>
+            <artifactId>artifactId</artifactId>
+            <version>2.0</version>
+            <type>war</type>
+        </moduleId>
+    </environment>
+
+   <tomcat-clustering-wadi>
+       <sweepInterval>10</sweepInterval>
+       <numPartitions>12</numPartitions>
+       <cluster>
+           <name>SpecificClusterName</name>
+       </cluster>
+       <disableReplication>true</disableReplication>
+       <deltaReplication>true</deltaReplication>
+       <backing-strategy-factory>
+           <name>SpecificFactoryName</name>
+       </backing-strategy-factory>
+   </tomcat-clustering-wadi>
+
+</web-app>