[jboss-cvs] JBossAS SVN: r69372 - in trunk/tomcat/src: resources and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Jan 26 18:13:24 EST 2008


Author: bstansberry at jboss.com
Date: 2008-01-26 18:13:24 -0500 (Sat, 26 Jan 2008)
New Revision: 69372

Added:
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java
Modified:
   trunk/tomcat/src/resources/war-deployers-all-beans.xml
   trunk/tomcat/src/resources/war-deployers-beans.xml
Log:
[JBAS-4762] Make distributable webapps depend on the clustering cache
Add some comments to the clustering defaults deployer

Added: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java	                        (rev 0)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDependencyDeployer.java	2008-01-26 23:13:24 UTC (rev 69372)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.service.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.jboss.ReplicationConfig;
+
+/**
+ * Adds a dependency on a clustered cache.
+ * 
+ * TODO consider doing this internally in WebMetaData.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class ClusteringDependencyDeployer extends AbstractDeployer
+{
+   private String clusterCacheDependency;
+   
+   /**
+    * Create a new ClusteringDependencyDeployer.
+    * 
+    */
+   public ClusteringDependencyDeployer()
+   {
+      setStage(DeploymentStages.DESCRIBE);
+      setInput(JBossWebMetaData.class);
+      setOutput(JBossWebMetaData.class);
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
+      if( metaData != null && metaData.getDistributable() != null )
+      {
+         ReplicationConfig rpcfg = metaData.getReplicationConfig();
+         String cacheName = rpcfg == null ? null: rpcfg.getCacheName();
+         if (cacheName == null)
+         {
+            cacheName = clusterCacheDependency;
+         }
+         
+         log.debug("Adding dependency on " + cacheName + " to " + unit.getName());
+         List<String> depends = metaData.getDepends();
+         if (depends == null)
+            depends = new ArrayList<String>();
+         if (!depends.contains(cacheName))
+         {
+            depends.add(cacheName);
+         }
+         metaData.setDepends(depends);
+      }
+   }
+
+   public String getClusterCacheDependency()
+   {
+      return clusterCacheDependency;
+   }
+
+   public void setClusterCacheDependency(String clusterDependency)
+   {
+      this.clusterCacheDependency = clusterDependency;
+   }
+
+}

Modified: trunk/tomcat/src/resources/war-deployers-all-beans.xml
===================================================================
--- trunk/tomcat/src/resources/war-deployers-all-beans.xml	2008-01-26 23:12:12 UTC (rev 69371)
+++ trunk/tomcat/src/resources/war-deployers-all-beans.xml	2008-01-26 23:13:24 UTC (rev 69372)
@@ -32,11 +32,9 @@
    </bean>
         
    <!-- 
-        Injects default clustering metadata.
-        
-        FIXME. This is a temporary measure until we set up a jboss-web.xml 
-        equivalent to conf/web.xml and  conf/standardjboss.xml and use it as the 
-        source for all defaults. 
+        Injects default clustering metadata.        
+        TODO. A better approach is to use a jboss-web.xml equivalent to conf/web.xml 
+        and conf/standardjboss.xml as the source for defaults. 
    -->
    <bean name="WebAppClusteringDefaultsDeployer" 
          class="org.jboss.web.tomcat.service.deployers.ClusteringDefaultsDeployer"> 
@@ -50,12 +48,13 @@
       <!--
       The following two properties define when sessions are replicated to 
       the other nodes.
-      The default value, "instant", synchronously replicates changes
+      The default value, "instant", uses the request thread to replicate 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.   
+      The "interval" mode uses a background thread that periodically checks for
+      modified sessions and replicates them.  The "SnapshotInterval"
+      property controls how often (in milliseconds) the background thread
+      should run.   
       
       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, 
@@ -91,7 +90,22 @@
       <property name="passivationMaxIdleTime">-1</property>  
       <property name="passivationMinIdleTime">-1</property>
       
-   </bean>   
+   </bean>  
+    
+   <!-- 
+      Adds to distributable webapps dependencies on any needed clustering services.
+      
+      With this deployer in place, webapps marked <distributable/> will not 
+      deploy completely in the absence of needed clustering support services.
+      
+      If desired, this deployer can be commented out in a non-clustered AS 
+      configuration (e.g. 'default') in which case a <distributable/> webapp 
+      will still deploy after logging a WARN about the missing clustering 
+      services. The webapp's sessions will not be clustered. This was the 
+      behavior of distributable webapps in the 'default' config in AS 4.x.
+   -->
+   <bean name="WebAppClusteringDependencyDeployer" 
+         class="org.jboss.web.tomcat.service.deployers.ClusteringDependencyDeployer"/> 
    
    <bean name="WarDeployer" class="org.jboss.web.tomcat.service.deployers.TomcatDeployer">
       <!-- Inject the MainDeployer for resolving cross deployment refs -->

Modified: trunk/tomcat/src/resources/war-deployers-beans.xml
===================================================================
--- trunk/tomcat/src/resources/war-deployers-beans.xml	2008-01-26 23:12:12 UTC (rev 69371)
+++ trunk/tomcat/src/resources/war-deployers-beans.xml	2008-01-26 23:13:24 UTC (rev 69372)
@@ -40,11 +40,9 @@
   --> 
         
    <!-- 
-        Injects default clustering metadata.
-        
-        FIXME. This is a temporary measure until we set up a jboss-web.xml 
-        equivalent to conf/web.xml and  conf/standardjboss.xml and use it as the 
-        source for all defaults. 
+        Injects default clustering metadata.        
+        TODO. A better approach is to use a jboss-web.xml equivalent to conf/web.xml 
+        and conf/standardjboss.xml as the source for defaults. 
    -->
    <bean name="WebAppClusteringDefaultsDeployer" 
          class="org.jboss.web.tomcat.service.deployers.ClusteringDefaultsDeployer"> 
@@ -58,12 +56,13 @@
       <!--
       The following two properties define when sessions are replicated to 
       the other nodes.
-      The default value, "instant", synchronously replicates changes
+      The default value, "instant", uses the request thread to replicate 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.   
+      The "interval" mode uses a background thread that periodically checks for
+      modified sessions and replicates them.  The "SnapshotInterval"
+      property controls how often (in milliseconds) the background thread
+      should run.   
       
       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, 
@@ -99,7 +98,22 @@
       <property name="passivationMaxIdleTime">-1</property>  
       <property name="passivationMinIdleTime">-1</property>
       
-   </bean>   
+   </bean>  
+    
+   <!-- 
+      Adds to distributable webapps dependencies on any needed clustering services.
+      
+      With this deployer in place, webapps marked <distributable/> will not 
+      deploy completely in the absence of needed clustering support services.
+      
+      If desired, this deployer can be commented out in a non-clustered AS 
+      configuration (e.g. 'default') in which case a <distributable/> webapp 
+      will still deploy after logging a WARN about the missing clustering 
+      services. The webapp's sessions will not be clustered. This was the 
+      behavior of distributable webapps in the 'default' config in AS 4.x.
+   -->
+   <bean name="WebAppClusteringDependencyDeployer" 
+         class="org.jboss.web.tomcat.service.deployers.ClusteringDependencyDeployer"/> 
 
    <!-- The WebMetaData to service mbean deployer -->
    <bean name="WarDeployer" class="org.jboss.web.tomcat.service.deployers.TomcatDeployer">




More information about the jboss-cvs-commits mailing list