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

Manik Surtani msurtani at jboss.com
Wed Jan 3 10:33:09 EST 2007


  User: msurtani
  Date: 07/01/03 10:33:09

  Modified:    src/org/jboss/cache      Region.java TransactionEntry.java
                        CacheImpl.java UnversionedNode.java
                        InvocationContext.java
  Log:
  Improved notification mechanism, added a notification interceptor
  
  Revision  Changes    Path
  1.10      +12 -13    JBossCache/src/org/jboss/cache/Region.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Region.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Region.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- Region.java	8 Dec 2006 18:49:17 -0000	1.9
  +++ Region.java	3 Jan 2007 15:33:09 -0000	1.10
  @@ -6,11 +6,11 @@
    */
   package org.jboss.cache;
   
  -import org.jboss.cache.eviction.EvictionPolicyConfig;
  +import org.jboss.cache.config.EvictionRegionConfig;
  +import org.jboss.cache.eviction.EvictedEventNode;
   import org.jboss.cache.eviction.EvictionPolicy;
  +import org.jboss.cache.eviction.EvictionPolicyConfig;
   import org.jboss.cache.eviction.LRUPolicy;
  -import org.jboss.cache.eviction.EvictedEventNode;
  -import org.jboss.cache.config.EvictionRegionConfig;
   
   /**
    * Represents a section of the cache, and characteristics such as class loading and activaton can be applied to regions.
  @@ -85,7 +85,6 @@
       * data is stored.
       * 
       * @param fqn Fqn of the node.
  -    * 
       * @see #unmarkNodeCurrentlyInUse(Fqn)
       */
      void markNodeCurrentlyInUse(Fqn fqn, long timeout);
  @@ -94,8 +93,7 @@
       * Add an event to the eviction queue indicating that a node is no longer in use.
       *
       * @param fqn Fqn of the node.
  -    * 
  -    * @see #markNodeCurrentlyInUse(Fqn, long)
  +    * @see #markNodeCurrentlyInUse(Fqn,long)
       */
      void unmarkNodeCurrentlyInUse(Fqn fqn);
   
  @@ -104,6 +102,7 @@
      /**
       * Sets this region as active - this only marks a flag and does not activate the region.  Use {@link #activate()}
       * and {@link #deactivate()} for the full process. 
  +    *
       * @param b
       */
      void setActive(boolean b);
  
  
  
  1.19      +11 -1     JBossCache/src/org/jboss/cache/TransactionEntry.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TransactionEntry.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TransactionEntry.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -b -r1.18 -r1.19
  --- TransactionEntry.java	30 Dec 2006 17:49:54 -0000	1.18
  +++ TransactionEntry.java	3 Jan 2007 15:33:09 -0000	1.19
  @@ -37,7 +37,7 @@
    * </ul>
    *
    * @author <a href="mailto:bela at jboss.org">Bela Ban</a> Apr 14, 2003
  - * @version $Revision: 1.18 $
  + * @version $Revision: 1.19 $
    */
   public class TransactionEntry
   {
  @@ -82,6 +82,7 @@
       * List<Fqn> of nodes that have been removed by the transaction
       */
      private List<Fqn> removedNodes = new LinkedList<Fqn>();
  +   private List<MethodCall> cacheListenerEvents = new LinkedList<MethodCall>();
   
      /**
       * Constructs a new TransactionEntry.
  @@ -360,4 +361,13 @@
         return this.option;
      }
   
  +   public void addCacheListenerEvents(List<MethodCall> cacheListenerEvents)
  +   {
  +      this.cacheListenerEvents.addAll(cacheListenerEvents);
  +   }
  +
  +   public List<MethodCall> getCacheListenerEvents()
  +   {
  +      return cacheListenerEvents;
  +   }
   }
  
  
  
  1.13      +28 -23    JBossCache/src/org/jboss/cache/CacheImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- CacheImpl.java	3 Jan 2007 03:11:26 -0000	1.12
  +++ CacheImpl.java	3 Jan 2007 15:33:09 -0000	1.13
  @@ -98,7 +98,7 @@
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    * @author Brian Stansberry
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Id: CacheImpl.java,v 1.12 2007/01/03 03:11:26 bstansberry Exp $
  + * @version $Id: CacheImpl.java,v 1.13 2007/01/03 15:33:09 msurtani Exp $
    *          <p/>
    * @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
    */
  @@ -804,7 +804,7 @@
            regionManager.startEvictionThread();
         }
   
  -      notifier.notifyCacheStarted(this);
  +      notifier.notifyCacheStarted(this, true);
         started = true;
         log.info("JBoss Cache version: " + getVersion());
      }
  @@ -856,7 +856,7 @@
   
         if (notifier != null)
         {
  -         notifier.notifyCacheStopped(this);
  +         notifier.notifyCacheStopped(this, true);
            notifier.removeAllCacheListeners();
            notifier.setEvictionPolicyListener(null);
         }
  @@ -1370,14 +1370,14 @@
            log.trace(new StringBuffer("_get(").append("\"").append(fqn).append("\", \"").append(key).append("\", \"").
                    append(sendNodeEvent).append("\")"));
         }
  -      if (sendNodeEvent) notifier.notifyNodeVisited(fqn, true);
  +      if (sendNodeEvent) notifier.notifyNodeVisited(fqn, true, true);
         Node n = findNode(fqn);
         if (n == null)
         {
            log.trace("node not found");
            return null;
         }
  -      if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false);
  +      if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false, true);
         return n.get(key);
      }
   
  @@ -2203,7 +2203,7 @@
   
         Node n = findNodeCheck(tx, fqn);
         Map rawData = n.getNodeSPI().getRawData();
  -      notifier.notifyNodeModified(fqn, true, rawData);
  +      notifier.notifyNodeModified(fqn, true, rawData, true);
   
         getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
   
  @@ -2221,7 +2221,7 @@
         if (erase_contents) n.clearData();
         n.put(data);
   
  -      notifier.notifyNodeModified(fqn, false, rawData);
  +      notifier.notifyNodeModified(fqn, false, rawData, true);
   
      }
   
  @@ -2258,7 +2258,7 @@
   
         Node n = findNodeCheck(tx, fqn);
         Map rawData = n.getNodeSPI().getRawData();
  -      notifier.notifyNodeModified(fqn, true, rawData);
  +      notifier.notifyNodeModified(fqn, true, rawData, true);
   
         getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
         Object old_value = n.put(key, value);
  @@ -2280,7 +2280,7 @@
            tx_table.addUndoOperation(tx, undo_op);
         }
   
  -      notifier.notifyNodeModified(fqn, false, rawData);
  +      notifier.notifyNodeModified(fqn, false, rawData, true);
         return old_value;
      }
   
  @@ -2403,11 +2403,11 @@
   
         if (eviction)
         {
  -         notifier.notifyNodeEvicted(fqn, true);
  +         notifier.notifyNodeEvicted(fqn, true, true);
         }
         else
         {
  -         notifier.notifyNodeRemoved(fqn, true, n.getNodeSPI().getRawData());
  +         notifier.notifyNodeRemoved(fqn, true, n.getNodeSPI().getRawData(), true);
         }
   
         parent_node = n.getParent();
  @@ -2442,11 +2442,11 @@
   
         if (eviction)
         {
  -         notifier.notifyNodeEvicted(fqn, false);
  +         notifier.notifyNodeEvicted(fqn, false, true);
         }
         else
         {
  -         notifier.notifyNodeRemoved(fqn, false, null);
  +         notifier.notifyNodeRemoved(fqn, false, null, true);
         }
      }
   
  @@ -2491,7 +2491,7 @@
            return null;
         }
   
  -      notifier.notifyNodeModified(fqn, true, n.getNodeSPI().getRawData());
  +      notifier.notifyNodeModified(fqn, true, n.getNodeSPI().getRawData(), true);
   
         getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
         old_value = n.remove(key);
  @@ -2505,7 +2505,7 @@
            tx_table.addUndoOperation(tx, undo_op);
         }
   
  -      notifier.notifyNodeModified(fqn, false, n.getNodeSPI().getRawData());
  +      notifier.notifyNodeModified(fqn, false, n.getNodeSPI().getRawData(), true);
   
         return old_value;
      }
  @@ -2583,11 +2583,11 @@
   
         if (eviction)
         {
  -         notifier.notifyNodeEvicted(fqn, true);
  +         notifier.notifyNodeEvicted(fqn, true, true);
         }
         else
         {
  -         notifier.notifyNodeModified(fqn, true, n.getNodeSPI().getRawData());
  +         notifier.notifyNodeModified(fqn, true, n.getNodeSPI().getRawData(), true);
         }
   
         Map raw = n.getNodeSPI().getRawData();
  @@ -2599,17 +2599,17 @@
   
         if (sendNodeEvent)
         {
  -         notifier.notifyNodeVisited(fqn, false);
  +         notifier.notifyNodeVisited(fqn, false, true);
         }
         else
         {// FIXME Bela did this so GUI view can refresh the view after node is evicted. But this breaks eviction policy, especially AOP!!!!
            if (eviction)
            {
  -            notifier.notifyNodeEvicted(fqn, false);
  +            notifier.notifyNodeEvicted(fqn, false, true);
            }
            else
            {
  -            notifier.notifyNodeModified(fqn, false, n.getData());
  +            notifier.notifyNodeModified(fqn, false, n.getData(), true);
            }
         }
   
  @@ -2716,7 +2716,7 @@
         }
   
         Fqn fqn = new Fqn(parent_fqn, child_name);
  -      notifier.notifyNodeCreated(fqn, true);
  +      notifier.notifyNodeCreated(fqn, true, true);
         parentNode.addChild(child_name, childNode);
   
         childNode.markAsDeleted(false, true);
  @@ -2727,7 +2727,7 @@
            tx_table.addUndoOperation(gtx, MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, gtx, fqn, false));
         }
   
  -      notifier.notifyNodeCreated(fqn, false);
  +      notifier.notifyNodeCreated(fqn, false, true);
      }
   
   
  @@ -3190,9 +3190,14 @@
   
         // parent pointer is calculated on the fly using Fqns.
   
  +      // notify
  +      notifier.notifyNodeMoved(nodeToMoveFqn, new Fqn(newParentFqn, nodeToMoveFqn.getLastElement()), true, true);
  +
         // now adjust Fqns of node and all children.
         moveFqns(node, newParent.getFqn());
   
  +      notifier.notifyNodeMoved(nodeToMoveFqn, new Fqn(newParentFqn, nodeToMoveFqn.getLastElement()), false, true);
  +
         // now register an undo op
         if (getInvocationContext().getTransaction() != null)
         {
  @@ -3575,7 +3580,7 @@
            coordinator = (members.size() != 0 && members.get(0).equals(getLocalAddress()));
   
            // now notify listeners - *after* updating the coordinator. - JBCACHE-662
  -         if (needNotification) notifier.notifyViewChange(new_view);
  +         if (needNotification) notifier.notifyViewChange(new_view, true);
   
            // Wake up any threads that are waiting to know who the members
            // are so they can figure out who the coordinator is
  
  
  
  1.8       +2 -2      JBossCache/src/org/jboss/cache/UnversionedNode.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UnversionedNode.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/UnversionedNode.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- UnversionedNode.java	2 Jan 2007 19:19:05 -0000	1.7
  +++ UnversionedNode.java	3 Jan 2007 15:33:09 -0000	1.8
  @@ -351,7 +351,7 @@
               child = children().get(child_name);
               if (child == null)
               {
  -               cache.getNotifier().notifyNodeCreated(child_fqn, true);
  +               cache.getNotifier().notifyNodeCreated(child_fqn, true, true);
                  child = newChild;
                  children.put(child_name, child);
                  if (gtx != null)
  @@ -373,7 +373,7 @@
               {
                  log.trace("created child: fqn=" + child_fqn);
               }
  -            cache.getNotifier().notifyNodeCreated(child_fqn, false);
  +            cache.getNotifier().notifyNodeCreated(child_fqn, false, true);
            }
         }
         return child;
  
  
  
  1.11      +34 -6     JBossCache/src/org/jboss/cache/InvocationContext.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: InvocationContext.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/InvocationContext.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- InvocationContext.java	29 Aug 2006 17:50:14 -0000	1.10
  +++ InvocationContext.java	3 Jan 2007 15:33:09 -0000	1.11
  @@ -7,8 +7,12 @@
   package org.jboss.cache;
   
   import org.jboss.cache.config.Option;
  +import org.jboss.cache.marshall.MethodCall;
   
   import javax.transaction.Transaction;
  +import java.util.ArrayList;
  +import java.util.LinkedList;
  +import java.util.List;
   
   /**
    * This context holds information specific to a method invocation.
  @@ -17,6 +21,7 @@
    */
   public class InvocationContext implements Cloneable
   {
  +   private transient List<MethodCall> cacheListenerEvents = new LinkedList<MethodCall>();
      private Transaction transaction;
      private GlobalTransaction globalTransaction;
      private Option optionOverrides;
  @@ -120,6 +125,28 @@
         this.originLocal = originLocal;
      }
   
  +   /**
  +    * @return a list of cache listener events set during the course of this invocation
  +    */
  +   public List<MethodCall> getCacheListenerEvents()
  +   {
  +      return new ArrayList<MethodCall>(cacheListenerEvents);
  +   }
  +
  +   /**
  +    * Adds a cache listener event to the list of events created by the current invocation.
  +    *
  +    * @param event
  +    */
  +   public void addCacheListenerEvent(MethodCall event)
  +   {
  +      cacheListenerEvents.add(event);
  +   }
  +
  +   public void clearCacheListenerEvents()
  +   {
  +      cacheListenerEvents.clear();
  +   }
   
      public String toString()
      {
  @@ -157,6 +184,7 @@
         optionOverrides = null;
         originLocal = true;
         txHasMods = false;
  +      cacheListenerEvents.clear();
      }
   
      public InvocationContext clone() throws CloneNotSupportedException
  
  
  



More information about the jboss-cvs-commits mailing list