[jbosscache-commits] JBoss Cache SVN: r5039 - in core/trunk/src/main/java/org/jboss/cache: interceptors and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Jan 7 13:09:54 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-01-07 13:09:53 -0500 (Mon, 07 Jan 2008)
New Revision: 5039

Modified:
   core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
   core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
Log:
Suppress notifications for nodes created as a part of removeNode()

Modified: core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeSPI.java	2008-01-07 17:04:24 UTC (rev 5038)
+++ core/trunk/src/main/java/org/jboss/cache/NodeSPI.java	2008-01-07 18:09:53 UTC (rev 5039)
@@ -246,6 +246,19 @@
    NodeSPI<K, V> addChildDirect(Fqn childName);
 
    /**
+    * Same as {@link #addChildDirect(Fqn)} except that it optionally allows you to suppress notification events for
+    * the creation of this node.
+    *
+    * @param f      name of child
+    * @param notify if true, notification events are sent; if false, they are not
+    * @return child node
+    * @throws org.jboss.cache.lock.LockingException
+    *          if locking was not obtained
+    * @see #addChild(Fqn)
+    */
+   NodeSPI<K, V> addChildDirect(Fqn f, boolean notify);
+
+   /**
     * Directly adds the node passed in to the children map of the current node.  Will throw a CacheException if
     * <tt>child.getFqn().getParent().equals(getFqn())</tt> returns false.
     *
@@ -443,9 +456,9 @@
     * using special <tt>_JBOSS_INTERNAL_XXX</tt> Strings as keys.  Designed to be used by {@link org.jboss.cache.statetransfer.StateTransferGenerator}
     * and {@link org.jboss.cache.interceptors.CacheStoreInterceptor} which attempt to serialize nodes into a stream for storage or transfer.
     *
+    * @param onlyInternalState if true, the map will only contain internal state and no other data.
     * @return a map containing data as well as additional information about this node.
     * @since 2.1.0
-    * @param onlyInternalState if true, the map will only contain internal state and no other data.
     */
    Map getInternalState(boolean onlyInternalState);
 
@@ -463,7 +476,8 @@
    /**
     * Sets the validity of a node.  By default, all nodes are valid unless they are deleted, invalidated or moved, either
     * locally or remotely.  To be used in conjunction with {@link #isValid()}.
-    * @param valid if true, the node is marked as valid; if false, the node is invalid.
+    *
+    * @param valid     if true, the node is marked as valid; if false, the node is invalid.
     * @param recursive if true, the validity flag passed in is applied to all children as well.
     * @since 2.1.0
     */

Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2008-01-07 17:04:24 UTC (rev 5038)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2008-01-07 18:09:53 UTC (rev 5039)
@@ -248,12 +248,12 @@
       return data.put(key, value);
    }
 
-   public NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx)
+   public NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean notify)
    {
-      return getOrCreateChild(child_name, gtx, true);
+      return getOrCreateChild(child_name, gtx, true, notify);
    }
 
-   private NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean createIfNotExists)
+   private NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean createIfNotExists, boolean notify)
    {
 
       NodeSPI<K, V> child;
@@ -281,7 +281,7 @@
             child = (NodeSPI<K, V>) children().get(child_name);
             if (child == null)
             {
-               cache.getNotifier().notifyNodeCreated(child_fqn, true, ctx);
+               if (notify) cache.getNotifier().notifyNodeCreated(child_fqn, true, ctx);
                child = newChild;
                children.put(child_name, child);
                if (gtx != null)
@@ -303,7 +303,7 @@
             {
                log.trace("created child: fqn=" + child_fqn);
             }
-            cache.getNotifier().notifyNodeCreated(child_fqn, false, ctx);
+            if (notify) cache.getNotifier().notifyNodeCreated(child_fqn, false, ctx);
          }
       }
       return child;
@@ -456,10 +456,15 @@
 
    public NodeSPI<K, V> addChildDirect(Fqn f)
    {
+      return addChildDirect(f, true);
+   }
+
+   public NodeSPI<K, V> addChildDirect(Fqn f, boolean notify)
+   {
       if (f.size() == 1)
       {
          GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
-         return getOrCreateChild(f.getLastElement(), gtx);
+         return getOrCreateChild(f.getLastElement(), gtx, notify, notify);
       }
       else
       {

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-01-07 17:04:24 UTC (rev 5038)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-01-07 18:09:53 UTC (rev 5039)
@@ -390,7 +390,8 @@
          {
             if (createIfNotExists)
             {
-               currentNode = parent.addChildDirect(new Fqn(childName));
+               // if the new node is to be marked as deleted, do not notify!
+               currentNode = parent.addChildDirect(new Fqn(childName), !markNewNodesAsDeleted);
                created = true;
                if (trace) log.trace("Child node was null, so created child node " + childName);
                if (createdNodes != null) createdNodes.add(currentNode.getFqn());

Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java	2008-01-07 17:04:24 UTC (rev 5038)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java	2008-01-07 18:09:53 UTC (rev 5039)
@@ -77,7 +77,7 @@
 
    public NodeSPI<K, V> getOrCreateChild(Object name, GlobalTransaction tx)
    {
-      return node.getOrCreateChild(name, tx);
+      return node.getOrCreateChild(name, tx, true);
    }
 
    public NodeLock getLock()
@@ -155,6 +155,11 @@
       return node.addChildDirect(childName);
    }
 
+   public NodeSPI<K, V> addChildDirect(Fqn f, boolean notify)
+   {
+      return node.addChildDirect(f, notify);
+   }
+
    public void addChildDirect(NodeSPI<K, V> child)
    {
       node.addChildDirect(child);




More information about the jbosscache-commits mailing list