[jboss-cvs] JBossAS SVN: r66985 - trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 12 16:41:20 EST 2007


Author: bstansberry at jboss.com
Date: 2007-11-12 16:41:18 -0500 (Mon, 12 Nov 2007)
New Revision: 66985

Added:
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java
Log:
[JBAS-4967] Extract setting of default clustering JBossWebMetaData from TomcatDeployer

Added: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java	                        (rev 0)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/ClusteringDefaultsDeployer.java	2007-11-12 21:41:18 UTC (rev 66985)
@@ -0,0 +1,267 @@
+/*
+ * 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 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.PassivationConfig;
+import org.jboss.metadata.web.jboss.ReplicationConfig;
+import org.jboss.metadata.web.jboss.ReplicationGranularity;
+import org.jboss.metadata.web.jboss.ReplicationTrigger;
+import org.jboss.metadata.web.jboss.SnapshotMode;
+
+/**
+ * Injects default clustering values into JBossWebMetaData.
+ * 
+ * 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 defaults.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class ClusteringDefaultsDeployer extends AbstractDeployer
+{
+   public static final int IGNORED = -1;
+   
+   private String cacheSource;
+   private String cacheName;
+   private SnapshotMode snapshotMode;
+   private int snapshotInterval;
+   private ReplicationGranularity replicationGranularity;
+   private ReplicationTrigger replicationTrigger;
+   private boolean replicationFieldBatchMode = true;
+   private Boolean useJK;
+   private boolean useSessionPassivation;
+   private int passivationMinIdleTime = IGNORED;
+   private int passivationMaxIdleTime = IGNORED;
+   private boolean useLocalCache = true;
+   
+   /**
+    * Create a new ClusteringDependencyDeployer.
+    * 
+    */
+   public ClusteringDefaultsDeployer()
+   {
+      setStage(DeploymentStages.PARSE);
+      setInput(JBossWebMetaData.class);
+      setOutput(JBossWebMetaData.class);
+   }
+
+   public Boolean isUseJK()
+   {
+      return useJK;
+   }
+
+   public void setUseJK(Boolean useJK)
+   {
+      this.useJK = useJK;
+   }
+
+   public String getCacheName()
+   {
+      return cacheName;
+   }
+
+   public void setCacheName(String cacheName)
+   {
+      this.cacheName = cacheName;
+   }
+
+   public SnapshotMode getSnapshotMode()
+   {
+      return snapshotMode;
+   }
+
+   public void setSnapshotMode(SnapshotMode snapshotMode)
+   {
+      this.snapshotMode = snapshotMode;
+   }
+
+   /**
+    * Get the snapshot interval.
+    */
+   public int getSnapshotInterval()
+   {
+      return snapshotInterval;
+   }
+   
+   /**
+    * Get the snapshot interval.
+    */
+   public void setSnapshotInterval(int snapshotInterval)
+   {
+      this.snapshotInterval = snapshotInterval;
+   }
+
+   public ReplicationGranularity getReplicationGranularity()
+   {
+      return replicationGranularity;
+   }
+
+   public void setReplicationGranularity(ReplicationGranularity granularity)
+   {
+      this.replicationGranularity = granularity;
+   }
+
+   public ReplicationTrigger getReplicationTrigger()
+   {
+      return replicationTrigger;
+   }
+
+   public void setReplicationTrigger(ReplicationTrigger trigger)
+   {
+      this.replicationTrigger = trigger;
+   }
+
+   public boolean isReplicationFieldBatchMode()
+   {
+      return replicationFieldBatchMode;
+   }
+
+   public void setReplicationFieldBatchMode(boolean fieldBatchMode)
+   {
+      this.replicationFieldBatchMode = fieldBatchMode;
+   }
+
+   public boolean isUseLocalCache()
+   {
+      return useLocalCache;
+   }
+
+   public void setUseLocalCache(boolean useLocalCache)
+   {
+      this.useLocalCache = useLocalCache;
+   }
+
+   public boolean isUseSessionPassivation()
+   {
+      return useSessionPassivation;
+   }
+
+   public void setUseSessionPassivation(boolean useSessionPassivation)
+   {
+      this.useSessionPassivation = useSessionPassivation;
+   }
+
+   public int getPassivationMinIdleTime()
+   {
+      return passivationMinIdleTime;
+   }
+
+   public void setPassivationMinIdleTime(int passivationMinIdleTime)
+   {
+      this.passivationMinIdleTime = passivationMinIdleTime;
+   }
+
+   public int getPassivationMaxIdleTime()
+   {
+      return passivationMaxIdleTime;
+   }
+
+   public void setPassivationMaxIdleTime(int passivationMaxIdleTime)
+   {
+      this.passivationMaxIdleTime = passivationMaxIdleTime;
+   }
+
+   public String getCacheSource()
+   {
+      return cacheSource;
+   }
+
+   public void setCacheSource(String cacheSource)
+   {
+      this.cacheSource = cacheSource;
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
+      if( metaData != null && metaData.getDistributable() != null )
+      {
+         if (metaData.getDistributable() != null)
+         {
+            addReplicationConfigDefaults(metaData);
+            
+            addPassivationConfigDefaults(metaData);
+         }
+      }
+   }
+
+   /**
+    * FIXME Comment this
+    * 
+    * @param metaData
+    */
+   private void addPassivationConfigDefaults(JBossWebMetaData metaData)
+   {
+      PassivationConfig passCfg = metaData.getPassivationConfig();
+      if (passCfg == null)
+      {
+         passCfg = new PassivationConfig();
+         metaData.setPassivationConfig(passCfg);
+      }
+      
+      if (passCfg.getUseSessionPassivation() == null)
+         passCfg.setUseSessionPassivation(String.valueOf(this.useSessionPassivation));
+      if (passCfg.getPassivationMinIdleTime() == null)
+         passCfg.setPassivationMinIdleTime(String.valueOf(this.passivationMinIdleTime));
+      if (passCfg.getPassivationMinIdleTime() == null)
+         passCfg.setPassivationMaxIdleTime(String.valueOf(this.passivationMaxIdleTime));
+   }
+
+   /**
+    * FIXME Comment this
+    * 
+    * @param metaData
+    */
+   private void addReplicationConfigDefaults(JBossWebMetaData metaData)
+   {
+      ReplicationConfig repCfg = metaData.getReplicationConfig();
+      if (repCfg == null)
+      {
+         repCfg = new ReplicationConfig();
+         metaData.setReplicationConfig(repCfg);
+      }
+      if (repCfg.getCacheName() == null)
+         repCfg.setCacheName(this.cacheName);
+      if (repCfg.getUseJK() == null && useJK != null)
+         repCfg.setUseJK(this.useJK.toString());
+      if (repCfg.getSnapshotMode() == null)
+         repCfg.setSnapshotModeEnum(this.snapshotMode);
+      if (repCfg.getSnapshotInterval() == null)
+         repCfg.setSnapshotInterval(String.valueOf(this.snapshotInterval));
+      if (repCfg.getUseLocalCache() == null)
+         repCfg.setUseLocalCache(String.valueOf(this.useLocalCache));
+      if (repCfg.getReplicationGranularity() == null)
+         repCfg.setReplicationGranularity(this.replicationGranularity);
+      if (repCfg.getReplicationTrigger() == null)
+         repCfg.setReplicationTrigger(this.replicationTrigger);
+      if (repCfg.getReplicationFieldBatchMode() == null)
+         repCfg.setReplicationFieldBatchMode(this.replicationFieldBatchMode);
+   }
+   
+
+}




More information about the jboss-cvs-commits mailing list