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

Brian Stansberry brian.stansberry at jboss.com
Thu May 10 00:00:23 EDT 2007


  User: bstansberry
  Date: 07/05/10 00:00:23

  Modified:    src/org/jboss/cache/interceptors  
                        CacheMgmtInterceptorMBean.java
                        CacheMgmtInterceptor.java
  Log:
  [JBCACHE-855] CacheMgmtInterceptor no longer handles JMX notifications; CacheJmxWrapper does
  
  Revision  Changes    Path
  1.6       +2 -2      JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptorMBean.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheMgmtInterceptorMBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptorMBean.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- CacheMgmtInterceptorMBean.java	5 Jan 2007 14:27:15 -0000	1.5
  +++ CacheMgmtInterceptorMBean.java	10 May 2007 04:00:23 -0000	1.6
  @@ -27,9 +27,9 @@
    * Interface capturing basic cache management statistics
    *
    * @author Jerry Gauthier
  - * @version $Id: CacheMgmtInterceptorMBean.java,v 1.5 2007/01/05 14:27:15 msurtani Exp $
  + * @version $Id: CacheMgmtInterceptorMBean.java,v 1.6 2007/05/10 04:00:23 bstansberry Exp $
    */
  -public interface CacheMgmtInterceptorMBean extends InterceptorMBean, NotificationBroadcaster
  +public interface CacheMgmtInterceptorMBean extends InterceptorMBean
   {
      /**
       * Returns the number of cache attribute hits
  
  
  
  1.29      +33 -215   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.28
  retrieving revision 1.29
  diff -u -b -r1.28 -r1.29
  --- CacheMgmtInterceptor.java	19 Mar 2007 19:03:34 -0000	1.28
  +++ CacheMgmtInterceptor.java	10 May 2007 04:00:23 -0000	1.29
  @@ -21,67 +21,49 @@
    */
   package org.jboss.cache.interceptors;
   
  -import org.jboss.cache.CacheListener;
  +import java.util.HashMap;
  +import java.util.Map;
  +
   import org.jboss.cache.CacheSPI;
  -import org.jboss.cache.Fqn;
  +import org.jboss.cache.jmx.CacheNotificationBroadcaster;
   import org.jboss.cache.marshall.MethodCall;
   import org.jboss.cache.marshall.MethodDeclarations;
  -import org.jgroups.View;
  -
  -import javax.management.ListenerNotFoundException;
  -import javax.management.MBeanNotificationInfo;
  -import javax.management.Notification;
  -import javax.management.NotificationBroadcaster;
  -import javax.management.NotificationBroadcasterSupport;
  -import javax.management.NotificationFilter;
  -import javax.management.NotificationListener;
  -import java.util.HashMap;
  -import java.util.Map;
  -import java.util.concurrent.atomic.AtomicLong;
   
   /**
    * Captures cache management statistics
    *
    * @author Jerry Gauthier
  - * @version $Id: CacheMgmtInterceptor.java,v 1.28 2007/03/19 19:03:34 msurtani Exp $
  + * @version $Id: CacheMgmtInterceptor.java,v 1.29 2007/05/10 04:00:23 bstansberry Exp $
    */
  -public class CacheMgmtInterceptor extends Interceptor implements CacheMgmtInterceptorMBean, NotificationBroadcaster
  +public class CacheMgmtInterceptor 
  +   extends Interceptor 
  +   implements CacheMgmtInterceptorMBean
   {
  -   // Notification Types
  -   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_MOVED = "org.jboss.cache.NodeMoved",
  -           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_MODIFIED = "Node has been modifed.";
  -   private static final String MSG_NODE_REMOVED = "Node has been removed.";
  -   private static final String MSG_NODE_MOVED = "Node has been moved.";
  -   private static final String MSG_NODE_VISITED = "Node has been visited.";
  -   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_PASSIVATED = "Node has been passivated.";
  -   private static final String MSG_VIEW_CHANGED = "Cache cluster view has changed.";
  -
  -   // Notification Info 
  -   private static final String NOTIFICATION_NAME = Notification.class.getName();
  -   private static final String NOTIFICATION_DESCR = "JBossCache event notifications";
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_CACHE_STARTED = CacheNotificationBroadcaster.NOTIF_CACHE_STARTED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_CACHE_STOPPED = CacheNotificationBroadcaster.NOTIF_CACHE_STOPPED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_NODE_CREATED = CacheNotificationBroadcaster.NOTIF_NODE_CREATED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_NODE_MODIFIED = CacheNotificationBroadcaster.NOTIF_NODE_MODIFIED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_NODE_REMOVED = CacheNotificationBroadcaster.NOTIF_NODE_REMOVED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_NODE_MOVED = CacheNotificationBroadcaster.NOTIF_NODE_MOVED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_NODE_VISITED = CacheNotificationBroadcaster.NOTIF_NODE_VISITED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_NODE_EVICTED = CacheNotificationBroadcaster.NOTIF_NODE_EVICTED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_NODE_LOADED = CacheNotificationBroadcaster.NOTIF_NODE_LOADED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_NODE_ACTIVATED = CacheNotificationBroadcaster.NOTIF_NODE_ACTIVATED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_NODE_PASSIVATED = CacheNotificationBroadcaster.NOTIF_NODE_PASSIVATED;
  +   /** @deprecated use constants in {@link CacheNotificationBroadcaster} */
  +   public static final String NOTIF_VIEW_CHANGED = CacheNotificationBroadcaster.NOTIF_VIEW_CHANGED;
   
  -   private AtomicLong m_seq = new AtomicLong(0);
  -   private int m_listeners = 0;
      private long m_hit_times = 0;
      private long m_miss_times = 0;
      private long m_store_times = 0;
  @@ -91,13 +73,10 @@
      private long m_evictions = 0;
      private long m_start = System.currentTimeMillis();
      private long m_reset = m_start;
  -   private CacheMgmtListener m_listener = new CacheMgmtListener();
  -   private NotificationBroadcasterSupport m_broadcaster = null;
   
      public void setCache(CacheSPI cache)
      {
         super.setCache(cache);
  -      m_broadcaster = new NotificationBroadcasterSupport();
      }
   
      /**
  @@ -271,166 +250,5 @@
         m_store_times = 0;
         m_reset = System.currentTimeMillis();
      }
  -
  -   private synchronized void emitNotifications(boolean emit)
  -   {
  -      // This method adds and removes the CacheImpl listener.
  -      // The m_listeners counter is used to determine whether
  -      // we have any clients who are registered for notifications
  -      // from this mbean.  When the count is zero, we don't need to 
  -      // listen to cache events.  Note that a client who terminates
  -      // without unregistering for notifications will leave the count
  -      // greater than zero so we'll still listen in that case.
  -      if (emit)
  -      {
  -         m_listeners++;
  -         cache.addCacheListener(m_listener);
  -      }
  -      else
  -      {
  -         m_listeners--;
  -         if (m_listeners <= 0)
  -         {
  -            cache.removeCacheListener(m_listener);
  -         }
  -      }
  -   }
  -
  -   // NotificationBroadcaster interface
  -
  -   public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
  -           throws ListenerNotFoundException
  -   {
  -      m_broadcaster.removeNotificationListener(listener, filter, handback);
  -   }
  -
  -   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_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};
  -   }
  -
  -   public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
  -           throws IllegalArgumentException
  -   {
  -      m_broadcaster.addNotificationListener(listener, filter, handback);
  -      emitNotifications(true);
  -   }
  -
  -   public void removeNotificationListener(NotificationListener listener)
  -           throws ListenerNotFoundException
  -   {
  -      m_broadcaster.removeNotificationListener(listener);
  -      emitNotifications(false);
  -   }
  -
  -   // Handler for CacheImpl events
  -   private class CacheMgmtListener implements CacheListener
  -   {
  -      private long seq()
  -      {
  -         return m_seq.getAndIncrement();
  -      }
  -
  -      public void cacheStarted(CacheSPI cache)
  -      {
  -         Notification n = new Notification(NOTIF_CACHE_STARTED, this, seq(), MSG_CACHE_STARTED);
  -         n.setUserData(cache.getConfiguration().getServiceName());
  -         m_broadcaster.sendNotification(n);
  -      }
  -
  -      public void cacheStopped(CacheSPI cache)
  -      {
  -         Notification n = new Notification(NOTIF_CACHE_STOPPED, this, seq(), MSG_CACHE_STOPPED);
  -         n.setUserData(cache.getConfiguration().getServiceName());
  -         m_broadcaster.sendNotification(n);
  -      }
  -
  -      public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
  -      {
  -         Notification n = new Notification(NOTIF_NODE_CREATED, this, seq(), MSG_NODE_CREATED);
  -         n.setUserData(new Object[]{fqn.toString(), pre, isLocal});
  -         m_broadcaster.sendNotification(n);
  -      }
  -
  -      public void nodeEvicted(Fqn fqn, boolean pre, boolean isLocal)
  -      {
  -         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)
  -      {
  -         Notification n = new Notification(NOTIF_NODE_LOADED, this, seq(), MSG_NODE_LOADED);
  -         n.setUserData(new Object[]{fqn.toString(), pre});
  -         m_broadcaster.sendNotification(n);
  -      }
  -
  -      public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, ModificationType modType, Map data)
  -      {
  -         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)
  -      {
  -         Notification n = new Notification(NOTIF_NODE_REMOVED, this, seq(), MSG_NODE_REMOVED);
  -         n.setUserData(new Object[]{fqn.toString(), pre, isLocal});
  -         m_broadcaster.sendNotification(n);
  -      }
  -
  -      public void nodeMoved(Fqn from, Fqn to, boolean pre, boolean isLocal)
  -      {
  -         Notification n = new Notification(NOTIF_NODE_MOVED, this, seq(), MSG_NODE_MOVED);
  -         n.setUserData(new Object[]{from.toString(), to.toString(), pre});
  -         m_broadcaster.sendNotification(n);
  -      }
  -
  -      public void nodeVisited(Fqn fqn, boolean pre)
  -      {
  -         Notification n = new Notification(NOTIF_NODE_VISITED, this, seq(), MSG_NODE_VISITED);
  -         n.setUserData(new Object[]{fqn.toString(), pre});
  -         m_broadcaster.sendNotification(n);
  -      }
  -
  -      public void viewChange(View view)
  -      {
  -         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 = 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 = 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