[jbosscache-commits] JBoss Cache SVN: r5708 - in core/trunk/src/main/java/org/jboss/cache: commands/remote and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Apr 28 03:58:39 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-04-28 03:58:39 -0400 (Mon, 28 Apr 2008)
New Revision: 5708

Modified:
   core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
Log:
Fixed buddy transformer to use clone of ReplicateCommand


Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java	2008-04-28 07:47:45 UTC (rev 5707)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java	2008-04-28 07:58:39 UTC (rev 5708)
@@ -672,9 +672,10 @@
 
    public ReplicateCommand transformReplicateCommand(ReplicateCommand rc)
    {
+      ReplicateCommand clone = rc.clone();
       if (rc.isSingleCommand())
       {
-         return commandsFactory.buildReplicateCommand(transformFqns((VisitableCommand) rc.getSingleModification()));
+         clone.setSingleModification(transformFqns((VisitableCommand) rc.getSingleModification()));
       }
       else
       {
@@ -683,8 +684,10 @@
          {
             transformed.add(transformFqns((VisitableCommand) cmd));
          }
-         return commandsFactory.buildReplicateCommand(transformed);
+         clone.setModifications(transformed);
       }
+
+      return clone;
    }
 
    // -------------- internal helpers methods --------------------

Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java	2008-04-28 07:47:45 UTC (rev 5707)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java	2008-04-28 07:58:39 UTC (rev 5708)
@@ -65,6 +65,19 @@
       this.invoker = interceptorChain;
    }
 
+   public void setSingleModification(ReplicableCommand singleModification)
+   {
+      this.singleModification = singleModification;
+   }
+
+   public void setModifications(List<ReplicableCommand> modifications)
+   {
+      if (modifications != null && modifications.size() == 1)
+         singleModification = modifications.get(0);
+      else
+         this.modifications = modifications;
+   }
+
    public Object perform(InvocationContext ctx) throws Throwable
    {
       if (isSingleCommand()) return processSingleCommand(singleModification);
@@ -198,4 +211,26 @@
             "cmds=" + (isSingleCommand() ? singleModification : modifications) +
             '}';
    }
+
+   /**
+    * Clones this replicate command, but with an empty modification list.
+    *
+    * @return a clone
+    */
+   @Override
+   public ReplicateCommand clone()
+   {
+      ReplicateCommand clone = null;
+      try
+      {
+         clone = (ReplicateCommand) super.clone();
+         clone.initialize(invoker);
+      }
+      catch (CloneNotSupportedException e)
+      {
+         // should never get here
+      }
+
+      return clone;
+   }
 }
\ No newline at end of file




More information about the jbosscache-commits mailing list