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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 11 17:35:24 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-06-11 17:35:24 -0400 (Wed, 11 Jun 2008)
New Revision: 74424

Removed:
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUAlgorithm.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUConfiguration.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUPolicy.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/PojoGravitationClusteredSessionValve.java
Modified:
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheService.java
Log:
[JBAS-5618] Remove unneeded object passivation logic

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java	2008-06-11 21:13:24 UTC (rev 74423)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/FieldBasedJBossCacheService.java	2008-06-11 21:35:24 UTC (rev 74424)
@@ -37,25 +37,18 @@
 import org.jboss.aspects.patterns.observable.Subject;
 import org.jboss.cache.CacheException;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.Region;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.eviction.EvictionException;
-import org.jboss.cache.eviction.EvictionPolicy;
 import org.jboss.cache.pojo.PojoCache;
 import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException;
-import org.jboss.cache.pojo.PojoCacheThreadContext;
-import org.jboss.cache.pojo.impl.InternalConstant;
-import org.jboss.metadata.web.jboss.ReplicationGranularity;
 
 /**
+ * Adds PojoCache-specific capabilities to JBossCacheService.
+ * 
  * @author Brian Stansberry
  *
  */
 public class FieldBasedJBossCacheService extends JBossCacheService
 {
    private final PojoCache pojoCache_;
-   private Region evictionRegion_;
-   private JBossWebManagedLRUAlgorithm evictionAlgorithm_;
    private WeakHashMap typeMap = new WeakHashMap();
    
    /**
@@ -97,51 +90,6 @@
       return new Fqn(list);      
    }
 
-   @Override
-   public void start(ClassLoader tcl, JBossCacheManager manager)
-   {
-      super.start(tcl, manager);
-      if(manager.isPassivationEnabled())
-      {
-         initializeFieldGranularityEviction(tcl);
-      }
-   }
-   
-   
-
-   @Override
-   public void stop()
-   {
-      super.stop();      
-      
-      if (evictionRegion_ != null)            
-      {
-         getCache().removeRegion(evictionRegion_.getFqn());
-         evictionRegion_ = null;
-      }
-   }
-   
-   public final PojoCacheThreadContext getPojoCacheThreadContext()
-   {
-      return pojoCache_.getThreadContext();
-   }
-
-   @Override
-   public void processEviction()
-   {
-      if (evictionAlgorithm_ != null)
-      {
-         try
-         {
-            evictionAlgorithm_.backgroundProcess(evictionRegion_);
-         }
-         catch (EvictionException e)
-         {
-            log_.error("Problem handling eviction for region " + evictionRegion_, e);
-         }
-      }
-   }
-
    /**
     * store the pojo instance in the cache. Note that this is for the aop cache.
     * THe pojo needs to be "aspectized".
@@ -287,8 +235,7 @@
       if(log_.isTraceEnabled())
       {
          log_.trace("getPojo(): session id: " +realId + " key: " + key +
-                    " fqn: " + fqn + " gravitationEnabled: " + 
-                    getPojoCacheThreadContext().isGravitationEnabled());
+                    " fqn: " + fqn);
       }
       
       try 
@@ -566,36 +513,5 @@
          }
       }
    }
-   
-   private void initializeFieldGranularityEviction(ClassLoader regionCL)
-   {
-      JBossCacheManager manager = getManager();
-      if (manager.getReplicationGranularity() == ReplicationGranularity.FIELD)            
-      {
-         int maxNodes = Math.max(0, manager.getPassivationMaxObjects());
-         int maxIdle = Math.max(0, manager.getPassivationMaxObjectIdleTime());
-         if (maxNodes > 0 || maxIdle > 0)
-         {
-            EvictionPolicyConfig epc = getEvictionPolicyConfig(maxIdle, maxNodes);         
-//            evictionRegion_ = getCache().getRegion(getJBossInternalFqn(), true);           
-            evictionRegion_ = getCache().getRegion(getWebappFqn(), true);            
-            evictionRegion_.setEvictionPolicy(epc);
-            EvictionPolicy policy = evictionRegion_.getEvictionPolicy();
-            evictionAlgorithm_ = (JBossWebManagedLRUAlgorithm) policy.getEvictionAlgorithm();
-            
-            // Assign the classloader to this region as well
-            evictionRegion_.registerContextClassLoader(regionCL);
-         }
-      }
-   }
-   
-   private EvictionPolicyConfig getEvictionPolicyConfig(int timeToLiveSeconds, int maxNodes)
-   {
-      JBossWebManagedLRUConfiguration epc = new JBossWebManagedLRUConfiguration();
-      epc.setEvictionPolicyClass(JBossWebManagedLRUPolicy.class.getName());
-      epc.setTimeToLiveSeconds(timeToLiveSeconds);
-      epc.setMaxNodes(maxNodes);
-      return epc;
-   }
 
 }

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java	2008-06-11 21:13:24 UTC (rev 74423)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheManager.java	2008-06-11 21:35:24 UTC (rev 74424)
@@ -50,12 +50,10 @@
 import org.jboss.cache.CacheManager;
 import org.jboss.cache.CacheStatus;
 import org.jboss.cache.pojo.PojoCache;
-import org.jboss.cache.pojo.PojoCacheThreadContext;
 import org.jboss.ha.framework.server.CacheManagerLocator;
 import org.jboss.ha.framework.server.PojoCacheManager;
 import org.jboss.ha.framework.server.PojoCacheManagerLocator;
 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;
@@ -140,20 +138,6 @@
     */
    private Boolean replicationFieldBatchMode_;
    
-   /**
-    * Max time (milliseconds) a FIELD granularity object can be idle
-    * before it's should be passivated if passivation is enabled.
-    * Setting to < 1 means it's ignored.
-    */
-   protected int passivationMaxObjectIdleTime_ = -1;
-   
-   /**
-    * Max number of FIELD granularity objects that can be cached before
-    * the LRU objects are passivated.
-    * Setting to < 1 means it's ignored.
-    */
-   protected int passivationMaxObjects_ = -1;
-   
    /** Class loader for this web app. */
    private ClassLoader tcl_;
    
@@ -218,19 +202,8 @@
       this.replicationFieldBatchMode_ = (batch == null ? Boolean.TRUE : batch);
       setSnapshotMode(repCfg.getSnapshotMode());
       Integer snapshotInt = repCfg.getSnapshotInterval();
-      setSnapshotInterval(snapshotInt == null ? 0 : snapshotInt.intValue()); 
+      setSnapshotInterval(snapshotInt == null ? 0 : snapshotInt.intValue());
       
-      if (passivationMode_)
-      {
-         PassivationConfig pConfig = webMetaData.getPassivationConfig();
-         Integer max = pConfig.getObjectMaxIdleTime();
-         if (max != null)
-            passivationMaxObjectIdleTime_ = max.intValue();
-         max = pConfig.getMaxObjects();
-         if (max != null)
-            passivationMaxObjects_ = max.intValue();
-      }
-      
       log_.debug("init(): replicationGranularity_ is " + replicationGranularity_ +
          " and replicationFieldBatchMode is " + replicationFieldBatchMode_ +
          " and useJK is " + useJK_ +
@@ -561,7 +534,6 @@
    public long getPassivatedSessionCount()
    {
       return passivatedCount_.get();
-//      return passivatedSessions_.size();
    }
    
    @Override
@@ -585,26 +557,6 @@
    {
       return passivationMinIdleTime_;
    }
-
-   public int getPassivationMaxObjectIdleTime()
-   {
-      return passivationMaxObjectIdleTime_;
-   }
-
-   public void setPassivationMaxObjectIdleTime(int passivationMaxObjectIdleTime)
-   {
-      this.passivationMaxObjectIdleTime_ = passivationMaxObjectIdleTime;
-   }
-
-   public int getPassivationMaxObjects()
-   {
-      return passivationMaxObjects_;
-   }
-
-   public void setPassivationMaxObjects(int passivationMaxObjects)
-   {
-      this.passivationMaxObjects_ = passivationMaxObjects;
-   }  
    
 
    // Manager-methods -------------------------------------
@@ -801,7 +753,7 @@
                        " and max allowed sessions = " + maxActive_);
          }
          
-         processExpires(false);
+         processExpires();
          
          if (calcActiveSessions() >= maxActive_)
          {
@@ -910,7 +862,7 @@
       }
 
 //      add((ClusteredSession) session, true);
-      add((ClusteredSession) session, false);
+      add((ClusteredSession) session, false); // wait to replicate until req end
    }
 
    /**
@@ -1218,37 +1170,7 @@
       JBossCacheClusteredSession session = (JBossCacheClusteredSession) sessions_.get(realId);
       
       if (session == null)
-      {
-         // JBCLUSTER-15
-         // We need to check for maxActive first before attempting to create a new session
-//         if(maxActive_ != -1 
-//               && isPassivationEnabled()
-//               && calcActiveSessions() >= maxActive_)
-//         {
-//            if (log_.isTraceEnabled())
-//            {
-//               log_.trace("loadSession(): active sessions = " + calcActiveSessions() +
-//                          " and max allowed sessions = " + maxActive_);
-//            }
-//            
-//            processExpires();
-//         }
-         
-         // BES 2007/08/01 DO NOT REJECT A SESSION HERE -- FAILOVER MUST WORK
-         
-//         // maxActive_ -1 is unlimited
-//         if (maxActive_ != -1 && sessions_.size() >= maxActive_)
-//         {
-//            // Exceeds limit. We need to reject it.
-//            rejectedCounter_++;
-//            // Catalina api does not specify what happens
-//            // but we will throw a runtime exception for now.
-//            String msgEnd = (realId == null) ? "" : " id " + realId;
-//            throw new IllegalStateException("JBossCacheManager.createSession(): number of " +
-//                   "active sessions exceeds the maximum limit: " +
-//                   maxActive_ + " when trying to load session" + msgEnd);
-//         }
-         
+      {                 
          // This is either the first time we've seen this session on this
          // server, or we previously expired it and have since gotten
          // a replication message from another server
@@ -1258,8 +1180,7 @@
 
       synchronized (session)
       {
-         boolean doTx = false;      
-         boolean pojoGravLocallyEnabled = establishPojoGravitation();
+         boolean doTx = false; 
          try
          {
             // We need transaction so any data gravitation replication 
@@ -1309,8 +1230,6 @@
                   endTransaction(realId);
             }
             finally {
-               if (pojoGravLocallyEnabled)
-                  resetPojoGravitation();
                SessionReplicationContext.finishCacheActivity();
             }
          }
@@ -1413,7 +1332,6 @@
          return;
       }
 
-
       try
       {
          if(tm.getTransaction().getStatus() != Status.STATUS_MARKED_ROLLBACK)
@@ -1451,20 +1369,9 @@
     */
    @Override
    protected void processExpires()
-   {
-      processExpires(true);
-   }
-   
-   private void processExpires(boolean cleanPojos)
-   {
+   {      
       boolean expire = maxInactiveInterval_ >= 0;
       boolean passivate = isPassivationEnabled();
-      if (cleanPojos && !expire && !passivate)
-      {
-         // Let the proxy clean up any pojos
-         proxy_.processEviction();
-         return;
-      }
       
       long passivationMax = passivationMaxIdleTime_ * 1000L;
       long passivationMin = passivationMinIdleTime_ * 1000L;
@@ -1612,10 +1519,6 @@
          log_.error("processExpires: failed with exception: " + ex, ex);
       }
       
-      // Finally, clean up the pojo region
-      if (cleanPojos)
-         proxy_.processEviction();
-      
       if (trace)
       { 
          log_.trace("processExpires(): Completed ...");
@@ -1719,6 +1622,7 @@
       // Correct for drift since we don't know the true passivation
       // count when we started.  We can get activations of sessions
       // we didn't know were passivated.
+      // FIXME -- is the above statement still correct? Is this needed?
       if (pc < 0) 
       {
          // Just reverse our decrement.
@@ -2183,19 +2087,7 @@
     * Add a JvmRouteValve and BatchReplicationClusteredSessionValve if needed.
     */
    private void installValves()
-   {           
-      // Turn on data gravitation for pojos
-      if (replicationGranularity_ == ReplicationGranularity.FIELD)
-      {
-         FieldBasedJBossCacheService fieldProxy = getPojoCacheService();
-         if (fieldProxy.isBuddyReplicationEnabled())
-         {
-            Valve pojoGrav = new PojoGravitationClusteredSessionValve(fieldProxy);
-            log_.debug("Adding PojoGravitationClusteredSessionValve for pojo data gravitation.");
-            installContextValve(pojoGrav);            
-         }
-      }
-      
+   {      
       // If JK usage wasn't explicitly configured, default to enabling
       // it if jvmRoute is set on our containing Engine
       if (useJK_ == null)
@@ -2339,29 +2231,6 @@
       }
    }
    
-   private boolean establishPojoGravitation()
-   {
-      boolean changed = false;
-      if (replicationGranularity_ == ReplicationGranularity.FIELD )
-      {
-         FieldBasedJBossCacheService pojoProxy = getPojoCacheService();
-         PojoCacheThreadContext ctx = pojoProxy.getPojoCacheThreadContext();
-         if (pojoProxy.isBuddyReplicationEnabled() && !ctx.isGravitationEnabled())
-         {
-            log_.trace("enabling pojo data gravitation");
-            ctx.setGravitationEnabled(true);
-            changed = true;
-         }
-      }
-      return changed;
-   }
-   
-   private void resetPojoGravitation()
-   {
-      log_.trace("disabling pojo data gravitation");
-      getPojoCacheService().getPojoCacheThreadContext().setGravitationEnabled(false);
-   }
-   
    public void releaseCacheToManager()
    {      
       try

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheService.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheService.java	2008-06-11 21:13:24 UTC (rev 74423)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossCacheService.java	2008-06-11 21:35:24 UTC (rev 74424)
@@ -586,11 +586,6 @@
    {
       return usePassivation_;      
    }
-   
-   public void processEviction()
-   {
-    
-   }
 
    protected Fqn getWebappFqn()
    {

Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUAlgorithm.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUAlgorithm.java	2008-06-11 21:13:24 UTC (rev 74423)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUAlgorithm.java	2008-06-11 21:35:24 UTC (rev 74424)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.session;
-
-import org.jboss.cache.Region;
-import org.jboss.cache.eviction.EvictionException;
-import org.jboss.cache.eviction.LRUAlgorithm;
-
-/**
- * Disables eviction management by the JBoss Cache eviction thread while
- * exposing a method to allow the JBoss Web background thread to 
- * process the evictions.
- * 
- * @author Brian Stansberry
- *
- */
-public class JBossWebManagedLRUAlgorithm extends LRUAlgorithm
-{
-   /**
-    * Turns this method into a no-op, thus disabling eviction
-    * management by the JBC eviction thread.
-    */
-   @Override
-   public void process(Region region) throws EvictionException
-   {
-      // no-op
-   }
-   
-   public void backgroundProcess(Region region) throws EvictionException
-   {
-      super.process(region);
-   }
-
-}

Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUConfiguration.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUConfiguration.java	2008-06-11 21:13:24 UTC (rev 74423)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUConfiguration.java	2008-06-11 21:35:24 UTC (rev 74424)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.session;
-
-import org.jboss.cache.eviction.LRUConfiguration;
-
-/**
- * @author Brian Stansberry
- *
- */
-public class JBossWebManagedLRUConfiguration extends LRUConfiguration
-{
-   /** The serialVersionUID */
-   private static final long serialVersionUID = 3373548962390320982L;
-
-   @Override
-   protected void setEvictionPolicyClassName()
-   {
-      setEvictionPolicyClass(JBossWebManagedLRUPolicy.class.getName());
-   }
-
-}

Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUPolicy.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUPolicy.java	2008-06-11 21:13:24 UTC (rev 74423)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/JBossWebManagedLRUPolicy.java	2008-06-11 21:35:24 UTC (rev 74424)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.session;
-
-import org.jboss.cache.eviction.LRUPolicy;
-
-/**
- * Disables eviction management by the JBoss Cache eviction thread while
- * exposing a method to allow the JBoss Web background thread to 
- * process the evictions.
- * 
- * @author Brian Stansberry
- */
-public class JBossWebManagedLRUPolicy extends LRUPolicy
-{
-
-   public JBossWebManagedLRUPolicy()
-   {
-      super();
-      this.algorithm = new JBossWebManagedLRUAlgorithm();
-   }   
-
-}

Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/PojoGravitationClusteredSessionValve.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/PojoGravitationClusteredSessionValve.java	2008-06-11 21:13:24 UTC (rev 74423)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/PojoGravitationClusteredSessionValve.java	2008-06-11 21:35:24 UTC (rev 74424)
@@ -1,120 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.web.tomcat.service.session;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.apache.catalina.util.LifecycleSupport;
-import org.apache.catalina.valves.ValveBase;
-import org.jboss.cache.pojo.PojoCacheThreadContext;
-import org.jboss.logging.Logger;
-
-/**
- * This Valve turns on PojoCache data gravitation for the span of the request.
- *
- * @author Brian Stansberry
- * @version $Revision: 60079 $
- */
-public class PojoGravitationClusteredSessionValve extends ValveBase implements Lifecycle
-{
-   private static final Logger log = Logger.getLogger(PojoGravitationClusteredSessionValve.class);
-   
-   // The info string for this Valve
-   private static final String info = "PojoGravitationClusteredSessionValve/1.0";
-
-   // Valve-lifecycle_ helper object
-   protected LifecycleSupport support = new LifecycleSupport(this);
-
-   protected FieldBasedJBossCacheService pojoSvc;
-
-   /**
-    * Create a new Valve.
-    *
-    */
-   public PojoGravitationClusteredSessionValve(FieldBasedJBossCacheService pojoSvc)
-   {
-      super();
-      this.pojoSvc = pojoSvc;
-   }
-
-   /**
-    * Get information about this Valve.
-    */
-   public String getInfo()
-   {
-      return info;
-   }
-
-   public void invoke(Request request, Response response) throws IOException, ServletException
-   {
-      PojoCacheThreadContext ctx = pojoSvc.getPojoCacheThreadContext();
-      boolean enabled = ctx.isGravitationEnabled();
-      try
-      {
-         if (!enabled)
-         {
-            log.trace("enabled pojo data gravitation");
-            ctx.setGravitationEnabled(true);
-         }
-         getNext().invoke(request, response);
-      }
-      finally
-      {         
-         if (!enabled)
-            ctx.setGravitationEnabled(false);
-      }
-   }
-
-   // Lifecycle-interface
-   public void addLifecycleListener(LifecycleListener listener)
-   {
-      support.addLifecycleListener(listener);
-   }
-
-   public void removeLifecycleListener(LifecycleListener listener)
-   {
-      support.removeLifecycleListener(listener);
-   }
-
-   public LifecycleListener[] findLifecycleListeners()
-   {
-      return support.findLifecycleListeners();
-   }
-
-   public void start() throws LifecycleException
-   {
-      support.fireLifecycleEvent(START_EVENT, this);
-   }
-
-   public void stop() throws LifecycleException
-   {
-      support.fireLifecycleEvent(STOP_EVENT, this);
-   }
-
-}




More information about the jboss-cvs-commits mailing list