[jbosscache-commits] JBoss Cache SVN: r7260 - core/trunk/src/main/java/org/jboss/cache/commands/write.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Dec 5 19:47:33 EST 2008


Author: genman
Date: 2008-12-05 19:47:32 -0500 (Fri, 05 Dec 2008)
New Revision: 7260

Modified:
   core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
Log:
JBCACHE-1442 - Add "setData()" call

Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java	2008-12-06 00:45:08 UTC (rev 7259)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java	2008-12-06 00:47:32 UTC (rev 7260)
@@ -53,6 +53,9 @@
 
    /* parameters*/
    protected Map data;
+   
+   /* true to erase existing data */
+   protected boolean erase;
 
    public PutDataMapCommand(GlobalTransaction globalTransaction, Fqn fqn, Map data)
    {
@@ -84,6 +87,10 @@
          notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_MAP, existingData == null ? Collections.emptyMap() : existingData, ctx);
       }
 
+      if (erase)
+      {
+	      nodeSPI.clearDataDirect();
+      }
       nodeSPI.putAllDirect(data);
       if (notifier.shouldNotifyOnNodeModified())
       {
@@ -111,11 +118,11 @@
    {
       if (isVersioned())
       {
-         return VERSIONED_METHOD_ID;
+         return erase ? ERASE_VERSIONED_METHOD_ID : VERSIONED_METHOD_ID;
       }
       else
       {
-         return METHOD_ID;
+         return erase ? ERASE_METHOD_ID : METHOD_ID;
       }
    }
 
@@ -151,6 +158,7 @@
       if (!super.equals(o)) return false;
       PutDataMapCommand that = (PutDataMapCommand) o;
       if (data != null ? !data.equals(that.data) : that.data != null) return false;
+      if (erase != that.erase) return false;
       if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
          return false;
 
@@ -163,9 +171,27 @@
       int result = super.hashCode();
       result = 31 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
       result = 31 * result + (data != null ? data.hashCode() : 0);
+      if (erase)
+	      result++;
       return result;
    }
 
+   /**
+    * Sets a flag indicating the node data should be erased.
+    */
+   public void setErase(boolean erase)
+   {
+      this.erase = erase;
+   }
+   
+   /**
+    * Returns a flag indicating the node data should be erased.
+    */
+   public boolean isErase()
+   {
+      return erase;
+   }
+
    @Override
    public String toString()
    {
@@ -174,6 +200,8 @@
             ", dataVersion=" + dataVersion +
             ", data=" + data +
             ", globalTransaction=" + globalTransaction +
+            ", erase=" + erase +
             '}';
    }
+
 }




More information about the jbosscache-commits mailing list