[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...

Manik Surtani msurtani at jboss.com
Wed Sep 6 12:42:58 EDT 2006


  User: msurtani
  Date: 06/09/06 12:42:58

  Modified:    src/org/jboss/cache/interceptors  
                        CacheLoaderInterceptor.java
                        CacheMgmtInterceptor.java
  Log:
  Cache mgmt interceptor now uses new CacheListener interface
  
  Revision  Changes    Path
  1.53      +4 -6      JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLoaderInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -b -r1.52 -r1.53
  --- CacheLoaderInterceptor.java	5 Sep 2006 18:09:56 -0000	1.52
  +++ CacheLoaderInterceptor.java	6 Sep 2006 16:42:58 -0000	1.53
  @@ -32,7 +32,7 @@
    * Loads nodes that don't exist at the time of the call into memory from the CacheLoader
    *
    * @author Bela Ban
  - * @version $Id: CacheLoaderInterceptor.java,v 1.52 2006/09/05 18:09:56 msurtani Exp $
  + * @version $Id: CacheLoaderInterceptor.java,v 1.53 2006/09/06 16:42:58 msurtani Exp $
    */
   public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
   {
  @@ -520,16 +520,14 @@
   
         if (nodeExists)
         {
  +         cache.getNotifier().notifyNodeLoaded(fqn, true, Collections.emptyMap());
  +         cache.getNotifier().notifyNodeLoaded(fqn, false, nodeData);
  +
            if (isActivation)
            {
               cache.getNotifier().notifyNodeActivated(fqn, true);
               cache.getNotifier().notifyNodeActivated(fqn, false);
            }
  -         else
  -         {
  -            cache.getNotifier().notifyNodeLoaded(fqn, true, Collections.emptyMap());
  -            cache.getNotifier().notifyNodeLoaded(fqn, false, nodeData);
  -         }
         }
   
         return nodeData;
  
  
  
  1.22      +52 -89    JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheMgmtInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptor.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- CacheMgmtInterceptor.java	6 Sep 2006 15:30:55 -0000	1.21
  +++ CacheMgmtInterceptor.java	6 Sep 2006 16:42:58 -0000	1.22
  @@ -43,44 +43,36 @@
    * Captures cache management statistics
    *
    * @author Jerry Gauthier
  - * @version $Id: CacheMgmtInterceptor.java,v 1.21 2006/09/06 15:30:55 msurtani Exp $
  + * @version $Id: CacheMgmtInterceptor.java,v 1.22 2006/09/06 16:42:58 msurtani Exp $
    */
   public class CacheMgmtInterceptor extends Interceptor implements CacheMgmtInterceptorMBean, NotificationBroadcaster
   {
  -
      // Notification Types
  -   public static final String NOTIF_CACHE_STARTED = "org.jboss.cache.CacheStarted";
  -   public static final String NOTIF_CACHE_STOPPED = "org.jboss.cache.CacheStopped";
  -   public static final String NOTIF_NODE_CREATED = "org.jboss.cache.NodeCreated";
  -   public static final String NOTIF_NODE_EVICTED = "org.jboss.cache.NodeEvicted";
  -   public static final String NOTIF_NODE_LOADED = "org.jboss.cache.NodeLoaded";
  -   public static final String NOTIF_NODE_MODIFIED = "org.jboss.cache.NodeModified";
  -   public static final String NOTIF_NODE_REMOVED = "org.jboss.cache.NodeRemoved";
  -   public static final String NOTIF_NODE_VISITED = "org.jboss.cache.NodeVisited";
  -   public static final String NOTIF_VIEW_CHANGE = "org.jboss.cache.ViewChange";
  -   public static final String NOTIF_NODE_ACTIVATE = "org.jboss.cache.NodeActivate";
  -   public static final String NOTIF_NODE_EVICT = "org.jboss.cache.NodeEvict";
  -   public static final String NOTIF_NODE_MODIFY = "org.jboss.cache.NodeModify";
  -   public static final String NOTIF_NODE_PASSIVATE = "org.jboss.cache.NodePassivate";
  -   public static final String NOTIF_NODE_REMOVE = "org.jboss.cache.NodeRemove";
  +   public static final String
  +           NOTIF_CACHE_STARTED = "org.jboss.cache.CacheStarted",
  +           NOTIF_CACHE_STOPPED = "org.jboss.cache.CacheStopped",
  +           NOTIF_NODE_CREATED = "org.jboss.cache.NodeCreated",
  +           NOTIF_NODE_MODIFIED = "org.jboss.cache.NodeModified",
  +           NOTIF_NODE_REMOVED = "org.jboss.cache.NodeRemoved",
  +           NOTIF_NODE_VISITED = "org.jboss.cache.NodeVisited",
  +           NOTIF_NODE_EVICTED = "org.jboss.cache.NodeEvicted",
  +           NOTIF_NODE_LOADED = "org.jboss.cache.NodeLoaded",
  +           NOTIF_NODE_ACTIVATED = "org.jboss.cache.NodeActivated",
  +           NOTIF_NODE_PASSIVATED = "org.jboss.cache.NodePassivated",
  +           NOTIF_VIEW_CHANGED = "org.jboss.cache.ViewChanged";
   
      // Notification Messages
      private static final String MSG_CACHE_STARTED = "Cache has been started.";
      private static final String MSG_CACHE_STOPPED = "Cache has been stopped.";
      private static final String MSG_NODE_CREATED = "Node has been created.";
  -   private static final String MSG_NODE_EVICTED = "Node has been evicted.";
  -   private static final String MSG_NODE_LOADED = "Node has been loaded.";
      private static final String MSG_NODE_MODIFIED = "Node has been modifed.";
      private static final String MSG_NODE_REMOVED = "Node has been removed.";
      private static final String MSG_NODE_VISITED = "Node has been visited.";
  -   private static final String MSG_VIEW_CHANGE = "Cache cluster view has changed.";
  -   private static final String MSG_NODE_ACTIVATE = "Node about to be activated.";
  +   private static final String MSG_NODE_EVICTED = "Node has been evicted.";
  +   private static final String MSG_NODE_LOADED = "Node has been loaded.";
      private static final String MSG_NODE_ACTIVATED = "Node has been activated.";
  -   private static final String MSG_NODE_EVICT = "Node about to be evicted.";
  -   private static final String MSG_NODE_MODIFY = "Node about to be modified.";
  -   private static final String MSG_NODE_PASSIVATE = "Node about to be passivated.";
      private static final String MSG_NODE_PASSIVATED = "Node has been passivated.";
  -   private static final String MSG_NODE_REMOVE = "Node about to be removed.";
  +   private static final String MSG_VIEW_CHANGED = "Cache cluster view has changed.";
   
      // Notification Info 
      private static final String NOTIFICATION_NAME = Notification.class.getName();
  @@ -311,11 +303,21 @@
   
      public MBeanNotificationInfo[] getNotificationInfo()
      {
  -      String[] types = new String[]{NOTIF_CACHE_STARTED, NOTIF_CACHE_STOPPED, NOTIF_NODE_CREATED,
  -              NOTIF_NODE_EVICTED, NOTIF_NODE_LOADED, NOTIF_NODE_MODIFIED,
  -              NOTIF_NODE_REMOVED, NOTIF_NODE_VISITED, NOTIF_VIEW_CHANGE,
  -              NOTIF_NODE_ACTIVATE, NOTIF_NODE_EVICT, NOTIF_NODE_MODIFY,
  -              NOTIF_NODE_PASSIVATE, NOTIF_NODE_REMOVE};
  +      String[] types = new String[]
  +              {
  +                      NOTIF_CACHE_STARTED,
  +                      NOTIF_CACHE_STOPPED,
  +                      NOTIF_NODE_CREATED,
  +                      NOTIF_NODE_EVICTED,
  +                      NOTIF_NODE_LOADED,
  +                      NOTIF_NODE_MODIFIED,
  +                      NOTIF_NODE_ACTIVATED,
  +                      NOTIF_NODE_PASSIVATED,
  +                      NOTIF_NODE_REMOVED,
  +                      NOTIF_NODE_VISITED,
  +                      NOTIF_VIEW_CHANGED
  +              };
  +
         MBeanNotificationInfo info = new MBeanNotificationInfo(types, NOTIFICATION_NAME, NOTIFICATION_DESCR);
         return new MBeanNotificationInfo[]{info};
      }
  @@ -337,10 +339,6 @@
      // Handler for TreeCache events
      private class CacheMgmtListener implements CacheListener
      {
  -      CacheMgmtListener()
  -      {
  -      }
  -
         private long seq()
         {
            return m_seq.increment();
  @@ -362,100 +360,65 @@
   
         public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
         {
  -         if (pre)
  -         {
               Notification n = new Notification(NOTIF_NODE_CREATED, this, seq(), MSG_NODE_CREATED);
  -            n.setUserData(fqn.toString());
  +         n.setUserData(new Object[]{fqn.toString(), pre, isLocal});
               m_broadcaster.sendNotification(n);
            }
  -      }
   
         public void nodeEvicted(Fqn fqn, boolean pre, boolean isLocal)
         {
  -         Notification n;
  -         if (pre)
  -            n = new Notification(NOTIF_NODE_EVICT, this, seq(), MSG_NODE_EVICT);
  -         else
  -            n = new Notification(NOTIF_NODE_EVICTED, this, seq(), MSG_NODE_EVICTED);
  -         n.setUserData(new Object[]{fqn.toString(), Boolean.valueOf(pre)});
  +         Notification n = new Notification(NOTIF_NODE_EVICTED, this, seq(), MSG_NODE_EVICTED);
  +         n.setUserData(new Object[]{fqn.toString(), pre, isLocal});
            m_broadcaster.sendNotification(n);
         }
   
         public void nodeLoaded(Fqn fqn, boolean pre, Map data)
         {
  -         if (!pre)
  -         {
               Notification n = new Notification(NOTIF_NODE_LOADED, this, seq(), MSG_NODE_LOADED);
  -            n.setUserData(fqn.toString());
  +         n.setUserData(new Object[]{fqn.toString(), pre});
               m_broadcaster.sendNotification(n);
            }
  -      }
   
         public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data)
         {
  -         Notification n;
  -         if (pre)
  -            n = new Notification(NOTIF_NODE_MODIFY, this, seq(), MSG_NODE_MODIFY);
  -         else
  -            n = new Notification(NOTIF_NODE_MODIFY, this, seq(), MSG_NODE_MODIFIED);
  -         n.setUserData(new Object[]{fqn.toString(), Boolean.valueOf(pre), Boolean.valueOf(isLocal)});
  +         Notification n = new Notification(NOTIF_NODE_MODIFIED, this, seq(), MSG_NODE_MODIFIED);
  +         n.setUserData(new Object[]{fqn.toString(), pre, isLocal});
            m_broadcaster.sendNotification(n);
   
         }
   
         public void nodeRemoved(Fqn fqn, boolean pre, boolean isLocal, Map data)
         {
  -         if (pre)
  -         {
  -            Notification n;
  -            n = new Notification(NOTIF_NODE_REMOVE, this, seq(), MSG_NODE_REMOVE);
  -            n.setUserData(new Object[]{fqn.toString(), Boolean.valueOf(pre), Boolean.valueOf(isLocal)});
  -            m_broadcaster.sendNotification(n);
  -         }
  -         else
  -         {
               Notification n = new Notification(NOTIF_NODE_REMOVED, this, seq(), MSG_NODE_REMOVED);
  -            n.setUserData(fqn.toString());
  +         n.setUserData(new Object[]{fqn.toString(), pre, isLocal});
               m_broadcaster.sendNotification(n);
            }
  -      }
   
         public void nodeVisited(Fqn fqn, boolean pre)
         {
  -         if (pre)
  -         {
               Notification n = new Notification(NOTIF_NODE_VISITED, this, seq(), MSG_NODE_VISITED);
  -            n.setUserData(fqn.toString());
  +         n.setUserData(new Object[]{fqn.toString(), pre});
               m_broadcaster.sendNotification(n);
            }
  -      }
   
         public void viewChange(View view)
         {
  -         Notification n = new Notification(NOTIF_VIEW_CHANGE, this, seq(), MSG_VIEW_CHANGE);
  +         Notification n = new Notification(NOTIF_VIEW_CHANGED, this, seq(), MSG_VIEW_CHANGED);
            n.setUserData(view.toString());
            m_broadcaster.sendNotification(n);
         }
   
         public void nodeActivated(Fqn fqn, boolean pre)
         {
  -         Notification n;
  -         if (pre)
  -            n = new Notification(NOTIF_NODE_ACTIVATE, this, seq(), MSG_NODE_ACTIVATE);
  -         else
  -            n = new Notification(NOTIF_NODE_ACTIVATE, this, seq(), MSG_NODE_ACTIVATED);
  -         n.setUserData(new Object[]{fqn.toString(), Boolean.valueOf(pre)});
  +         Notification n = new Notification(NOTIF_NODE_ACTIVATED, this, seq(), MSG_NODE_ACTIVATED);
  +         n.setUserData(new Object[]{fqn.toString(), pre});
            m_broadcaster.sendNotification(n);
         }
   
         public void nodePassivated(Fqn fqn, boolean pre)
         {
  -         Notification n;
  -         if (pre)
  -            n = new Notification(NOTIF_NODE_PASSIVATE, this, seq(), MSG_NODE_PASSIVATE);
  -         else
  -            n = new Notification(NOTIF_NODE_PASSIVATE, this, seq(), MSG_NODE_PASSIVATED);
  -         n.setUserData(new Object[]{fqn.toString(), Boolean.valueOf(pre)});
  +         Notification n = new Notification(NOTIF_NODE_PASSIVATED, this, seq(), MSG_NODE_PASSIVATED);
  +         n.setUserData(new Object[]{fqn.toString(), pre});
            m_broadcaster.sendNotification(n);
         }
      }
  
  
  



More information about the jboss-cvs-commits mailing list