[jboss-cvs] JBossAS SVN: r63977 - in trunk/tomcat/src/main/org/jboss/web/tomcat/service: sso and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 11 12:53:30 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-07-11 12:53:30 -0400 (Wed, 11 Jul 2007)
New Revision: 63977

Modified:
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/CacheListener.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java
Log:
[JBAS-4535] Convert to the notification API introduced in 2.0.0.CR3

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/CacheListener.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/CacheListener.java	2007-07-11 16:51:26 UTC (rev 63976)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/CacheListener.java	2007-07-11 16:53:30 UTC (rev 63977)
@@ -23,16 +23,20 @@
 
 import java.util.Map;
 
-import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.AbstractCacheListener;
-import org.jboss.cache.CacheListener.ModificationType;
 import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.notifications.annotation.CacheStarted;
+import org.jboss.cache.notifications.annotation.CacheStopped;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.event.CacheStartedEvent;
+import org.jboss.cache.notifications.event.CacheStoppedEvent;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.notifications.event.NodeRemovedEvent;
 import org.jboss.logging.Logger;
-import org.jgroups.View;
 
-
-public class CacheListener extends AbstractCacheListener
+ at org.jboss.cache.notifications.annotation.CacheListener
+public class CacheListener
 {
    // Element within an FQN that is JSESSION
    private static final int JSESSION_FQN_INDEX = 0;
@@ -56,7 +60,6 @@
    private static final int BUDDY_BACKUP_ROOT_OWNER_SIZE = BUDDY_BACKUP_ROOT_OWNER_INDEX + 1;
    
    private static Logger log_ = Logger.getLogger(CacheListener.class);
-   private JBossCacheWrapper cacheWrapper_;
    private JBossCacheManager manager_;
    private String webapp_;
    private String hostname_;
@@ -66,7 +69,6 @@
 
    CacheListener(JBossCacheWrapper wrapper, JBossCacheManager manager, String hostname, String webapp)
    {
-      cacheWrapper_ = wrapper;
       manager_ = manager;
       hostname_ = hostname;
       webapp_ =  webapp;
@@ -78,9 +80,14 @@
 
    // --------------- TreeCacheListener methods ------------------------------------
 
-   @Override
-   public void nodeRemoved(Fqn fqn, boolean pre, boolean isLocal, Map data)
+   @NodeRemoved
+   public void nodeRemoved(NodeRemovedEvent event)
    {
+      nodeRemoved(event.getFqn(), event.isPre(), event.isOriginLocal(), event.getData());
+   }
+   
+   private void nodeRemoved(Fqn fqn, boolean pre, boolean isLocal, Map data)
+   {
       if (pre || isLocal)
          return;
       
@@ -105,9 +112,14 @@
       }
    }
    
-   @Override
-   public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, ModificationType type, Map data)
+   @NodeModified
+   public void nodeModified(NodeModifiedEvent event)
    {
+      nodeModified(event.getFqn(), event.isPre(), event.isOriginLocal(), event.getData());
+   }
+   
+   private void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data)
+   {
       if (pre || isLocal)
          return;
       
@@ -181,55 +193,20 @@
       }
    }
 
-   @Override
-   public void cacheStarted(CacheSPI cache)
+   @CacheStarted
+   public void cacheStarted(CacheStartedEvent event)
    {
       // TODO will need to synchronize this with local sessions
+      // BES -- 2007/07/03 Not sure what this means
    }
 
-   @Override
-   public void cacheStopped(CacheSPI cache)
+   @CacheStopped
+   public void cacheStopped(CacheStoppedEvent event)
    {
       // TODO will need to synchronize this with local sessions
+      // BES -- 2007/07/03 Not sure what this means
    }
-
-   @Override
-   public void viewChange(View new_view)
-   {
-      // We don't care for this event.
-   }
    
-   @Override
-   public void nodeActivated(Fqn fqn, boolean pre, Map<Object, Object> data)
-   {
-      // we don't need to handle node activation notification since the 
-      // session manager will notify any servlet API listeners upon 
-      // loading the session from the distrubted store.
-   }
-   
-   // FIXME why would there be a notification of passivation on another node?
-   @Override
-   public void nodePassivated(Fqn fqn, boolean pre, Map<Object, Object> data)
-   {
-      if (!pre || SessionReplicationContext.isLocallyActive())
-         return;
-      
-      boolean isBuddy = isBuddyFqn(fqn);
-      
-      // We only deal with events for the root node of a session,
-      // so skip all others
-      if(isFqnSessionRootSized(fqn, isBuddy) 
-            && isFqnForOurWebapp(fqn, isBuddy))
-      {
-         // A session has been passivated on another node;
-         // need to inform the manager
-         String realId = getIdFromFqn(fqn, isBuddy);
-         String owner = isBuddy ? getBuddyOwner(fqn) : null;
-         manager_.processSessionPassivation(realId, owner);
-      }
-           
-   }
-   
    private boolean isFqnForOurWebapp(Fqn fqn, boolean isBuddy)
    {
       try

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java	2007-07-11 16:51:26 UTC (rev 63976)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java	2007-07-11 16:53:30 UTC (rev 63977)
@@ -35,7 +35,6 @@
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Session;
 import org.apache.catalina.util.LifecycleSupport;
-import org.jboss.cache.AbstractCacheListener;
 import org.jboss.cache.Cache;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
@@ -43,6 +42,11 @@
 import org.jboss.cache.RegionNotEmptyException;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.jmx.CacheJmxWrapperMBean;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.notifications.event.NodeRemovedEvent;
 import org.jboss.logging.Logger;
 import org.jboss.mx.util.MBeanProxyExt;
 import org.jboss.mx.util.MBeanServerLocator;
@@ -55,8 +59,8 @@
  * @author Brian E. Stansberry
  * @version $Revision: 59567 $ $Date: 2007-01-12 03:39:24 +0100 (ven., 12 janv. 2007) $
  */
+ at CacheListener
 public final class TreeCacheSSOClusterManager
-   extends AbstractCacheListener
    implements SSOClusterManager
 {
    // -------------------------------------------------------------  Constants
@@ -102,17 +106,17 @@
    /**
     * SSO id which the thread is currently storing to the cache
     */
-   private ThreadLocal beingLocallyAdded = new ThreadLocal();
+   private ThreadLocal<String> beingLocallyAdded = new ThreadLocal<String>();
 
    /**
     * SSO id which a thread is currently removing from the cache
     */
-   private ThreadLocal beingLocallyRemoved = new ThreadLocal();
+   private ThreadLocal<String> beingLocallyRemoved = new ThreadLocal<String>();
 
    /**
     * SSO id which the thread is deregistering due to removal on another node
     */
-   private ThreadLocal beingRemotelyRemoved = new ThreadLocal();
+   private ThreadLocal<String> beingRemotelyRemoved = new ThreadLocal<String>();
 
    /**
     * ObjectName of the TreeCache
@@ -612,10 +616,14 @@
     *
     * @param fqn the fully-qualified name of the node that was removed
     */
-   public void nodeRemoved(Fqn fqn)
+   @NodeRemoved
+   public void nodeRemoved(NodeRemovedEvent event)
    {
-      String ssoId = getIdFromFqn(fqn);
+      if (event.isPre())
+         return;
       
+      String ssoId = getIdFromFqn(event.getFqn());
+      
       if (ssoId == null)
          return;
 
@@ -658,8 +666,14 @@
     *
     * @param fqn the fully-qualified name of the node that was modified
     */
-   public void nodeModified(Fqn fqn)
+   @NodeModified
+   public void nodeModified(NodeModifiedEvent event)
    {
+      if (event.isPre())
+         return;
+      
+      Fqn fqn = event.getFqn();
+      
       // We are only interested in changes to the CREDENTIALS node
       if (CREDENTIALS.equals(getTypeFromFqn(fqn)) == false)
       {




More information about the jboss-cvs-commits mailing list