[jbosscache-commits] JBoss Cache SVN: r5698 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 22 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Apr 25 21:24:30 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-04-25 21:24:30 -0400 (Fri, 25 Apr 2008)
New Revision: 5698

Added:
   core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
   core/trunk/src/main/java/org/jboss/cache/commands/DataCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/ReversibleCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/VersionedDataCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java
   core/trunk/src/main/java/org/jboss/cache/commands/read/
   core/trunk/src/main/java/org/jboss/cache/commands/read/AbstractDataCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/read/RemoteExistsNodeCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/
   core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/CreateNodeCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/EvictNodeCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveDataCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
Removed:
   core/trunk/src/main/java/org/jboss/cache/commands/BaseCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java
   core/trunk/src/main/java/org/jboss/cache/commands/cachedata/
   core/trunk/src/main/java/org/jboss/cache/commands/channel/
   core/trunk/src/main/java/org/jboss/cache/commands/functional/
   core/trunk/src/main/java/org/jboss/cache/commands/remote/BaseDirectCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/DirectCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/GravitateDataCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/state/
   core/trunk/src/main/java/org/jboss/cache/commands/tx/BaseGlobalTransactionCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/visitors/
Modified:
   core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
   core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
   core/trunk/src/main/java/org/jboss/cache/RPCManager.java
   core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
   core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
   core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
   core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
   core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java
   core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingChainedInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
   core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
   core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java
   core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
   core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
   core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
   core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
   core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
   core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java
   core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java
   core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java
   core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
   core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
   core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java
   core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java
   core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
   core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
   core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java
   core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
   core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
   core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
   core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java
   core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java
Log:
First step in final naming and structure of commands

Modified: core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheSPI.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/CacheSPI.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -329,14 +329,4 @@
     * @return Set an unmodifiable set of children names, Object.
     */
    Set getChildrenNames(String fqn);
-
-   /**
-    * Blocks all broadcast network communications in the cluster.
-    */
-   void block();
-
-   /**
-    * Unblocks a previous block() call so broadcast network communications can resume.
-    */
-   void unblock();
 }

Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -8,8 +8,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.lock.NodeLock;
 import org.jboss.cache.marshall.MethodCall;
@@ -41,7 +40,7 @@
    @Deprecated
    private MethodCall methodCall;
    @Deprecated
-   private CacheCommand executingCommand;
+   private VisitableCommand command;
 
    // used to store cache peeks within the scope of a single context. Performing a cache peek can be a huge bottle neck.
    // See JBCACHE-811
@@ -294,7 +293,7 @@
       txHasMods = false;
       invocationLocks = null;
       methodCall = null;
-      executingCommand = null;
+      command = null;
    }
 
    @Override
@@ -369,17 +368,18 @@
     * @return the method call associated with this invocation
     */
    @Deprecated
+   @SuppressWarnings("deprecation")
    public MethodCall getMethodCall()
    {
       if (methodCall == null)
       {
-         methodCall = createMethodCall((MarshallableCommand) getExecutingCommand());
+         methodCall = createMethodCall();
       }
       return methodCall;
    }
 
    @SuppressWarnings("deprecation")
-   private MethodCall createMethodCall(MarshallableCommand command)
+   private MethodCall createMethodCall()
    {
       if (command == null) return null;
       MethodCall call = new MethodCall();
@@ -393,7 +393,7 @@
     * Sets the method call associated with this invocation.
     *
     * @param methodCall methodcall to set
-    * @deprecated not used anymore.  Interceptors will get a {@link org.jboss.cache.commands.CacheCommand} instance passed in along with an InvocationContext.
+    * @deprecated not used anymore.  Interceptors will get a {@link org.jboss.cache.commands.ReplicableCommand} instance passed in along with an InvocationContext.
     */
    @Deprecated
    public void setMethodCall(MethodCall methodCall)
@@ -434,18 +434,20 @@
     * handlers (handler = method in ChainedInterceptor class)
     */
    @Deprecated
-   public void setExecutingCommand(CacheCommand cacheCommand)
+   @SuppressWarnings("deprecation")
+   public void setCommand(VisitableCommand cacheCommand)
    {
-      this.executingCommand = cacheCommand;
+      this.command = cacheCommand;
    }
 
    /**
-    * @see #setExecutingCommand(org.jboss.cache.commands.CacheCommand)
+    * @see #setCommand(org.jboss.cache.commands.VisitableCommand)
     */
    @Deprecated
-   public CacheCommand getExecutingCommand()
+   @SuppressWarnings("deprecation")
+   public VisitableCommand getCommand()
    {
-      return executingCommand;
+      return command;
    }
 
    public boolean isValidTransaction()

Modified: core/trunk/src/main/java/org/jboss/cache/RPCManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManager.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManager.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,9 +1,9 @@
 package org.jboss.cache;
 
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jgroups.Address;
 import org.jgroups.Channel;
 import org.jgroups.blocks.RspFilter;
-import org.jboss.cache.commands.CacheCommand;
 
 import java.util.List;
 
@@ -54,13 +54,13 @@
     * @return a list of responses from each member contacted.
     * @throws Exception in the event of problems.
     */
-   List<Object> callRemoteMethods(List<Address> recipients, CacheCommand cacheCommand, int mode, boolean excludeSelf, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception;
+   List<Object> callRemoteMethods(List<Address> recipients, ReplicableCommand cacheCommand, int mode, boolean excludeSelf, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception;
 
    /**
     * Invokes an RPC call on other caches in the cluster.
     *
     * @param recipients          a list of Addresses to invoke the call on.  If this is null, the call is broadcast to the entire cluster.
-    * @param CacheCommand          the method call to invoke
+    * @param CacheCommand        the method call to invoke
     * @param mode                the group request mode to use.  See {@link org.jgroups.blocks.GroupRequest}.
     * @param excludeSelf         if true, the message is not looped back to the originator.
     * @param timeout             a timeout after which to throw a replication exception.
@@ -68,13 +68,13 @@
     * @return a list of responses from each member contacted.
     * @throws Exception in the event of problems.
     */
-   List<Object> callRemoteMethods(List<Address> recipients, CacheCommand cacheCommand, int mode, boolean excludeSelf, long timeout, boolean useOutOfBandMessage) throws Exception;
+   List<Object> callRemoteMethods(List<Address> recipients, ReplicableCommand cacheCommand, int mode, boolean excludeSelf, long timeout, boolean useOutOfBandMessage) throws Exception;
 
    /**
     * Invokes an RPC call on other caches in the cluster.
     *
     * @param recipients          a list of Addresses to invoke the call on.  If this is null, the call is broadcast to the entire cluster.
-    * @param CacheCommand          the method call to invoke
+    * @param CacheCommand        the method call to invoke
     * @param synchronous         if true, sets group request mode to {@link org.jgroups.blocks.GroupRequest#GET_ALL}, and if false sets it to {@link org.jgroups.blocks.GroupRequest#GET_NONE}.
     * @param excludeSelf         if true, the message is not looped back to the originator.
     * @param timeout             a timeout after which to throw a replication exception.
@@ -82,7 +82,7 @@
     * @return a list of responses from each member contacted.
     * @throws Exception in the event of problems.
     */
-   List<Object> callRemoteMethods(List<Address> recipients, CacheCommand cacheCommand, boolean synchronous, boolean excludeSelf, int timeout, boolean useOutOfBandMessage) throws Exception;
+   List<Object> callRemoteMethods(List<Address> recipients, ReplicableCommand cacheCommand, boolean synchronous, boolean excludeSelf, int timeout, boolean useOutOfBandMessage) throws Exception;
 
    /**
     * @return true if the current Channel is the coordinator of the cluster.

Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -8,8 +8,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.RuntimeConfig;
 import org.jboss.cache.factories.annotations.Inject;
@@ -375,22 +374,18 @@
 
    // ------------ START: RPC call methods ------------
 
-   public List<Object> callRemoteMethods(List<Address> recipients, CacheCommand command, int mode, boolean excludeSelf, long timeout, boolean useOutOfBandMessage) throws Exception
+   public List<Object> callRemoteMethods(List<Address> recipients, ReplicableCommand command, int mode, boolean excludeSelf, long timeout, boolean useOutOfBandMessage) throws Exception
    {
       return callRemoteMethods(recipients, command, mode, excludeSelf, timeout, null, useOutOfBandMessage);
    }
 
-   public List<Object> callRemoteMethods(List<Address> recipients, CacheCommand command, boolean synchronous, boolean excludeSelf, int timeout, boolean useOutOfBandMessage) throws Exception
+   public List<Object> callRemoteMethods(List<Address> recipients, ReplicableCommand command, boolean synchronous, boolean excludeSelf, int timeout, boolean useOutOfBandMessage) throws Exception
    {
       return callRemoteMethods(recipients, command, synchronous ? GroupRequest.GET_ALL : GroupRequest.GET_NONE, excludeSelf, timeout, useOutOfBandMessage);
    }
 
-   public List<Object> callRemoteMethods(List<Address> recipients, CacheCommand cmd, int mode, boolean excludeSelf, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception
+   public List<Object> callRemoteMethods(List<Address> recipients, ReplicableCommand command, int mode, boolean excludeSelf, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception
    {
-      if (!(cmd instanceof MarshallableCommand))
-         throw new IllegalArgumentException("Command " + cmd + " is not marshallable!");
-
-      MarshallableCommand command = (MarshallableCommand) cmd;
       int modeToUse = mode;
       int preferredMode;
       if ((preferredMode = spi.getInvocationContext().getOptionOverrides().getGroupRequestMode()) > -1)
@@ -662,9 +657,9 @@
       {
          flushBlockGate.close();
          if (log.isDebugEnabled()) log.debug("Block received at " + getLocalAddress());
+         notifier.notifyCacheBlocked(spi, true);
+         notifier.notifyCacheBlocked(spi, false);
 
-         spi.block();
-
          if (log.isDebugEnabled()) log.debug("Block processed at " + getLocalAddress());
       }
 
@@ -675,7 +670,8 @@
       {
          if (log.isDebugEnabled()) log.debug("UnBlock received at " + getLocalAddress());
 
-         spi.unblock();
+         notifier.notifyCacheUnblocked(spi, true);
+         notifier.notifyCacheUnblocked(spi, false);
 
          if (log.isDebugEnabled()) log.debug("UnBlock processed at " + getLocalAddress());
          flushBlockGate.open();

Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -10,7 +10,7 @@
 import org.apache.commons.logging.LogFactory;
 import static org.jboss.cache.AbstractNode.NodeFlags.*;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.CreateNodeCommand;
+import org.jboss.cache.commands.write.CreateNodeCommand;
 import org.jboss.cache.factories.annotations.CacheInjectionMethods;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.lock.IdentityLock;

Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -3,27 +3,32 @@
 import org.jboss.cache.CacheException;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.AbstractVisitor;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.functional.MarshallableCommand;
-import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
-import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
-import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
-import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.visitors.AbstractCommandsVisitor;
+import org.jboss.cache.commands.write.CreateNodeCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jgroups.Address;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 /**
@@ -33,7 +38,7 @@
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
-public class BuddyFqnTransformer extends AbstractCommandsVisitor
+public class BuddyFqnTransformer extends AbstractVisitor
 {
 
 
@@ -62,16 +67,7 @@
       return commitCommand;
    }
 
-   /**
-    * No fqn conversion for this one.
-    */
    @Override
-   public Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
-   {
-      return factory.buildDataGravitationCleanupCommand(command.getFqn(), command.getBackup());
-   }
-
-   @Override
    public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
    {
       Fqn transformed = getBackupFqn(command.getFqn());
@@ -184,8 +180,8 @@
    @Override
    public Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
    {
-      List<? extends CacheCommand> toTransform = command.getModifications();
-      List<? extends CacheCommand> transformedCommands = transformBatch(toTransform);
+      List<ReversibleCommand> toTransform = command.getModifications();
+      List<ReversibleCommand> transformedCommands = transformBatch(toTransform);
       return factory.buildPrepareCommand(command.getGlobalTransaction(), transformedCommands, command.getLocalAddress(), command.isOnePhaseCommit());
    }
 
@@ -198,49 +194,16 @@
    @Override
    public Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
    {
-      List<MarshallableCommand> transformed = transformBatch(command.getModifications());
+      List<ReversibleCommand> transformed = transformBatch(command.getModifications());
       return factory.buildOptimisticPrepareCommand(command.getGlobalTransaction(), transformed, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
    }
 
    @Override
-   public Object handleReplicateCommand(InvocationContext ctx, ReplicateCommand command) throws Throwable
-   {
-      List<MarshallableCommand> transformed = transformBatch(command.isSingleCommand() ? Collections.singletonList(command.getSingleModification()) : command.getModifications());
-      return factory.buildReplicateCommand(transformed);
-   }
-
-   @Override
-   public Object handleAnnounceBuddyPoolName(InvocationContext ctx, AnnounceBuddyPoolNameCommand command) throws Throwable
-   {
-      return factory.buildAnnounceBuddyPoolNameCommand(command.getAddress(), command.getBuddyPoolName());
-   }
-
-   @Override
-   public Object handleRemoveFromBuddyGroupCommand(InvocationContext ctx, RemoveFromBuddyGroupCommand command) throws Throwable
-   {
-      return factory.buildRemoveFromBuddyGroupCommand(command.getGroupName());
-   }
-
-   @Override
-   public Object handleAssignToBuddyGroupCommand(InvocationContext ctx, AssignToBuddyGroupCommand command) throws Throwable
-   {
-      return factory.buildAssignToBuddyGroupCommand(command.getGroup(), command.getState());
-   }
-
-   @Override
-   public Object handleClusteredGetCommand(InvocationContext ctx, ClusteredGetCommand command) throws Throwable
-   {
-      CacheDataCommand transformed = (CacheDataCommand) command.accept(ctx, this);
-      return factory.buildClusteredGetCommand(command.getSearchBackupSubtrees(), transformed);
-   }
-
-   @Override
    public Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
    {
       return factory.buildCreateNodeCommand(getBackupFqn(command.getFqn()));
    }
 
-
    /**
     * Assumes the backup Fqn if the current instance is the data owner.
     */
@@ -250,12 +213,12 @@
    }
 
 
-   public List<MarshallableCommand> transformBatch(List<? extends CacheCommand> toTransform) throws Throwable
+   public List<ReversibleCommand> transformBatch(List<ReversibleCommand> toTransform) throws Throwable
    {
-      List<MarshallableCommand> transformedCommands = new ArrayList<MarshallableCommand>(toTransform.size());
-      for (CacheCommand com : toTransform)
+      List<ReversibleCommand> transformedCommands = new ArrayList<ReversibleCommand>(toTransform.size());
+      for (ReversibleCommand com : toTransform)
       {
-         transformedCommands.add((MarshallableCommand) com.accept(null, this));
+         transformedCommands.add((ReversibleCommand) com.acceptVisitor(null, this));
       }
       return transformedCommands;
    }

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-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -15,12 +15,13 @@
 import org.jboss.cache.RPCManager;
 import org.jboss.cache.Region;
 import org.jboss.cache.RegionManager;
-import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
 import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
 import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ReplicateCommand;
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
 import org.jboss.cache.config.Configuration;
@@ -653,12 +654,12 @@
    /**
     * @see org.jboss.cache.buddyreplication.BuddyFqnTransformer
     */
-   public MarshallableCommand transformFqns(MarshallableCommand call)
+   public VisitableCommand transformFqns(VisitableCommand call)
    {
       try
       {
 
-         MarshallableCommand transformed = (MarshallableCommand) call.accept(null, fqnTransformer);
+         VisitableCommand transformed = (VisitableCommand) call.acceptVisitor(null, fqnTransformer);
          if (trace) log.trace("Transformed " + call + " to " + transformed);
          return transformed;
       }
@@ -669,6 +670,23 @@
       }
    }
 
+   public ReplicateCommand transformReplicateCommand(ReplicateCommand rc)
+   {
+      if (rc.isSingleCommand())
+      {
+         return commandsFactory.buildReplicateCommand(transformFqns((VisitableCommand) rc.getSingleModification()));
+      }
+      else
+      {
+         List<ReplicableCommand> transformed = new ArrayList<ReplicableCommand>(rc.getModifications().size());
+         for (ReplicableCommand cmd : rc.getModifications())
+         {
+            transformed.add(transformFqns((VisitableCommand) cmd));
+         }
+         return commandsFactory.buildReplicateCommand(transformed);
+      }
+   }
+
    // -------------- internal helpers methods --------------------
 
    private void removeFromGroup(List<Address> buddies)
@@ -946,7 +964,7 @@
       }
    }
 
-   private void makeRemoteCall(List<Address> recipients, CacheCommand call) throws Exception
+   private void makeRemoteCall(List<Address> recipients, ReplicableCommand call) throws Exception
    {
       // remove non-members from dest list
       if (recipients != null)

Modified: core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -4,7 +4,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.RPCManager;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.commands.remote.ReplicateCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.annotations.Inject;
@@ -41,7 +41,7 @@
    /**
     * Holds the replication jobs: LinkedList<MethodCall>
     */
-   final List<MarshallableCommand> elements = new LinkedList<MarshallableCommand>();
+   final List<ReplicableCommand> elements = new LinkedList<ReplicableCommand>();
 
    /**
     * For periodical replication
@@ -138,12 +138,12 @@
     */
    public void flush()
    {
-      List<MarshallableCommand> toReplicate;
+      List<ReplicableCommand> toReplicate;
       synchronized (elements)
       {
          if (log.isTraceEnabled())
             log.trace("flush(): flushing repl queue (num elements=" + elements.size() + ")");
-         toReplicate = new ArrayList<MarshallableCommand>(elements);
+         toReplicate = new ArrayList<ReplicableCommand>(elements);
          elements.clear();
       }
 

Copied: core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/visitors/AbstractCommandsVisitor.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,145 @@
+package org.jboss.cache.commands;
+
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.RemoteExistsNodeCommand;
+import org.jboss.cache.commands.tx.CommitCommand;
+import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
+import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.CreateNodeCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
+
+import java.util.Collection;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class AbstractVisitor implements Visitor
+{
+   public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleEvictFqnCommand(InvocationContext ctx, EvictNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
+   {
+      return null;
+   }
+
+   public void visitCollection(InvocationContext ctx, Collection<? extends VisitableCommand> toVisit) throws Throwable
+   {
+      for (VisitableCommand command : toVisit)
+      {
+         command.acceptVisitor(ctx, this);
+      }
+   }
+}

Deleted: core/trunk/src/main/java/org/jboss/cache/commands/BaseCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/BaseCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/BaseCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,26 +0,0 @@
-package org.jboss.cache.commands;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.commands.functional.MarshallableCommand;
-import org.jboss.cache.factories.annotations.CacheInjectionMethods;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.notifications.Notifier;
-
-/**
- * @author Mircea.Markus at jboss.com
- * @since 2.2
- */
- at CacheInjectionMethods
-public abstract class BaseCommand implements MarshallableCommand
-{
-   protected static final Object[] EMPTY_OBJECT_ARRAY = new Object[]{};
-   protected Notifier notifier;
-   protected CacheSPI spi;
-
-   @Inject
-   public void init(Notifier notifier, CacheSPI spi)
-   {
-      this.notifier = notifier;
-      this.spi = spi;
-   }
-}

Modified: core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -4,22 +4,32 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.RPCManager;
 import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.channel.BlockChannelCommand;
-import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
 import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
 import org.jboss.cache.commands.remote.ClusteredGetCommand;
 import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
-import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
 import org.jboss.cache.commands.remote.ReplicateCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.CreateNodeCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.factories.ComponentRegistry;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.transaction.GlobalTransaction;
@@ -77,26 +87,26 @@
       return command;
    }
 
-   public ReplicateCommand buildReplicateCommand(MarshallableCommand command)
+   public ReplicateCommand buildReplicateCommand(ReplicableCommand command)
    {
       ReplicateCommand cmd = new ReplicateCommand(command);
       registry.wireDependencies(cmd);
       return cmd;
    }
 
-   public ReplicateCommand buildReplicateCommand(List<MarshallableCommand> modifications)
+   public ReplicateCommand buildReplicateCommand(List<ReplicableCommand> modifications)
    {
       ReplicateCommand cmd = new ReplicateCommand(modifications);
       registry.wireDependencies(cmd);
       return cmd;
    }
 
-   public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, CacheCommand command, boolean onePhaseCommit)
+   public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, ReversibleCommand command, boolean onePhaseCommit)
    {
       return buildPrepareCommand(gtx, Collections.singletonList(command), rpcManager.getLocalAddress(), onePhaseCommit);
    }
 
-   public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Address address, boolean onePhaseCommit)
+   public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List<ReversibleCommand> modifications, Address address, boolean onePhaseCommit)
    {
       PrepareCommand cmd = new PrepareCommand(gtx, modifications, address, onePhaseCommit);
       registry.wireDependencies(cmd);
@@ -222,7 +232,7 @@
       return cmd;
    }
 
-   public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Map data, Address address, boolean onePhaseCommit)
+   public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, List<ReversibleCommand> modifications, Map data, Address address, boolean onePhaseCommit)
    {
       OptimisticPrepareCommand cmd = new OptimisticPrepareCommand(gtx, modifications, data, address, onePhaseCommit);
       registry.wireDependencies(cmd);
@@ -230,9 +240,9 @@
    }
 
 
-   public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, CacheCommand command)
+   public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, ReversibleCommand command)
    {
-      List<CacheCommand> list = command == null ? Collections.EMPTY_LIST : Collections.singletonList(command);
+      List<ReversibleCommand> list = (List<ReversibleCommand>) (command != null ? Collections.singletonList(command) : Collections.emptyList());
       return buildOptimisticPrepareCommand(gtx, list, null, null, false);
    }
 
@@ -257,27 +267,13 @@
       return command;
    }
 
-   public ClusteredGetCommand buildClusteredGetCommand(Boolean searchBackupSubtrees, CacheDataCommand cacheDataComand)
+   public ClusteredGetCommand buildClusteredGetCommand(Boolean searchBackupSubtrees, DataCommand cacheDataComand)
    {
       ClusteredGetCommand command = new ClusteredGetCommand(searchBackupSubtrees, cacheDataComand);
       registry.wireDependencies(command);
       return command;
    }
 
-   public BlockChannelCommand buildBlockChannelCommand()
-   {
-      BlockChannelCommand command = new BlockChannelCommand();
-      registry.wireDependencies(command);
-      return command;
-   }
-
-   public UnblockChannelCommand buildUnblockChannelCommand()
-   {
-      UnblockChannelCommand command = new UnblockChannelCommand();
-      registry.wireDependencies(command);
-      return command;
-   }
-
    public CreateNodeCommand buildCreateNodeCommand(Fqn fqn)
    {
       CreateNodeCommand cmd = new CreateNodeCommand(fqn);
@@ -292,10 +288,10 @@
     * @param parameters parameters attached to the command
     * @return a newly constructed cache command
     */
-   public CacheCommand fromStream(int id, Object[] parameters)
+   public ReplicableCommand fromStream(int id, Object[] parameters)
    {
       // todo: must be a better way to do this!!!
-      MarshallableCommand returnValue;
+      ReplicableCommand returnValue;
       switch (id)
       {
          case RemoteExistsNodeCommand.METHOD_ID:
@@ -413,7 +409,7 @@
             throw new CacheException("Unknown command id " + id + "!");
       }
 
-      returnValue.setState(id, parameters);
+      returnValue.setParameters(id, parameters);
       registry.wireDependencies(returnValue);
       return returnValue;
    }

Deleted: core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,213 +0,0 @@
-package org.jboss.cache.commands;
-
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.channel.BlockChannelCommand;
-import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
-import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
-import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
-import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ReplicateCommand;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-
-/**
- * @author Mircea.Markus at jboss.com
- * @since 2.2
- */
-public interface CommandsVisitor
-{
-
-//   put methods:
-//   putMethodIds.add(putDataMethodLocal_id);
-//         putMethodIds.add(putDataEraseMethodLocal_id);
-//         putMethodIds.add(putKeyValMethodLocal_id);
-//         putMethodIds.add(putDataEraseVersionedMethodLocal_id);
-//         putMethodIds.add(putDataVersionedMethodLocal_id);
-//         putMethodIds.add(putKeyValVersionedMethodLocal_id);
-//         putMethodIds.add(putForExternalReadMethodLocal_id);
-//         putMethodIds.add(putForExternalReadVersionedMethodLocal_id);
-//   crudMethods
-//   crudMethodIds.addAll(putMethodIds);
-//         crudMethodIds.add(removeNodeMethodLocal_id);
-//         crudMethodIds.add(removeKeyMethodLocal_id);
-//         crudMethodIds.add(removeDataMethodLocal_id);
-//         crudMethodIds.add(dataGravitationCleanupMethod_id);
-//         crudMethodIds.add(moveMethodLocal_id);
-//         crudMethodIds.add(removeNodeVersionedMethodLocal_id);
-//         crudMethodIds.add(removeKeyVersionedMethodLocal_id);
-//         crudMethodIds.add(removeDataVersionedMethodLocal_id);
-
-   /*
-   equiv of old:
-     1 - putDataEraseMethodLocal_id
-     2 - putDataMethodLocal_id
-     3 - putDataEraseVersionedMethodLocal_id
-     4 - putDataVersionedMethodLocal_id
-   */
-
-   Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable;
-
-   /*
-     equiv of old:
-       1 - putKeyValMethodLocal_id
-       2 - putKeyValVersionedMethodLocal_id
-       3 - putForExternalReadMethodLocal_id
-       4 - putForExternalReadVersionedMethodLocal_id
-    */
-   Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand putKeyValueCommand) throws Throwable;
-
-   /*
-    equiv of old:
-       1 - removeNodeMethodLocal_id
-       2 - removeNodeVersionedMethodLocal_id
-    */
-   Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand removeNodeCommand) throws Throwable;
-
-   /*
-     equiv of old:
-       1 - removeDataMethodLocal_id
-       2 - removeDataVersionedMethodLocal_id
-    */
-   Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand removeDataCommand) throws Throwable;
-
-   /*
-     equiv of old:
-       1 - evictNodeMethodLocal_id
-       2 - evictVersionedNodeMethodLocal_id
-    */
-   Object handleEvictFqnCommand(InvocationContext ctx, EvictNodeCommand evictFqnCommand) throws Throwable;
-
-   /*
-     equiv of old:
-        1 - invalidateMethodLocal_id
-    */
-   Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand invalidateCommand) throws Throwable;
-
-   /*
-     equiv of old:
-        1 - removeKeyMethodLocal_id
-        1 - removeKeyVersionedMethodLocal_id
-    */
-   Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand removeKeyCommand) throws Throwable;
-
-   /*
-     equiv of old:
-        1 - getDataMapMethodLocal_id
-    */
-   Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand getDataMapCommand) throws Throwable;
-
-   /*
-     equiv of old:
-        1 - existsMethod_id
-    */
-   Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand existsNodeCommand) throws Throwable;
-
-   /*
-     equiv of old:
-        1 - getKeyValueMethodLocal_id
-    */
-   Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand getKeyValueCommand) throws Throwable;
-
-   /*
-     equiv of old:
-        1 - getNodeMethodLocal_id
-    */
-   Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand getNodeCommand) throws Throwable;
-
-   /*
-        equiv of old:
-        1 - getKeysMethodLocal_id
-    */
-   Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand getKeysCommand) throws Throwable;
-
-   /*
-        equiv of old:
-        1 - getChildrenNamesMethodLocal_id
-    */
-   Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand getChildrenNamesCacheCommand) throws Throwable;
-
-   /*
-        equiv of old:
-        1 - moveMethodLocal_id
-    */
-   Object handleMoveCommand(InvocationContext ctx, MoveCommand moveCommand) throws Throwable;
-
-   /*
-        equiv of old:
-        1 - dataGravitationMethod_id
-    */
-   Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand gravitateDataCommand) throws Throwable;
-
-   /*
-      prepareMethod_id
-    */
-   Object handlePrepareCommand(InvocationContext ctx, PrepareCommand prepareCommand) throws Throwable;
-
-   /*
-      rollbackMethod_id
-    */
-   Object handleRollbackCommand(InvocationContext ctx, RollbackCommand rollbackCommand) throws Throwable;
-
-   /*
-      commitMethod_id
-    */
-   Object handleCommitCommand(InvocationContext ctx, CommitCommand commitCommand) throws Throwable;
-
-   /*
-      optimisticPrepareMethod_id
-    */
-   Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand optimisticPrepareCommand) throws Throwable;
-
-   /*
-        equiv of old:
-        1 - replicateMethod_id
-        2 - replicateAllMethod_id
-    */
-   Object handleReplicateCommand(InvocationContext ctx, ReplicateCommand replicateSingleCommand) throws Throwable;
-
-   /*
-        equiv of old:
-        1 - remoteAnnounceBuddyPoolNameMethod_id
-    */
-   Object handleAnnounceBuddyPoolName(InvocationContext ctx, AnnounceBuddyPoolNameCommand announceBuddyPoolNameCommand) throws Throwable;
-
-   /*
-        equiv of old:
-        1 - remoteRemoveFromBuddyGroupMethod_id
-    */
-   Object handleRemoveFromBuddyGroupCommand(InvocationContext ctx, RemoveFromBuddyGroupCommand removeFromBuddyGroupCommand) throws Throwable;
-
-   /*
-        1 - remoteAssignToBuddyGroupMethod_id
-    */
-   Object handleAssignToBuddyGroupCommand(InvocationContext ctx, AssignToBuddyGroupCommand assignToBuddyGroupCommand) throws Throwable;
-
-   /*
-        1 - dataGravitationCleanupMethod_id
-    */
-   Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand dataGravitationCleanupCommand) throws Throwable;
-
-   /*
-        1 - clusteredGetMethod_id
-    */
-   Object handleClusteredGetCommand(InvocationContext ctx, ClusteredGetCommand clusteredGetCommand) throws Throwable;
-
-   /*
-    blockChannelMethodLocal_id
-    */
-   Object handleBlockChannelCommand(InvocationContext ctx, BlockChannelCommand blockChannelCommand) throws Throwable;
-
-   /*
-   unblockChannelMethodLocal_id
-   */
-   Object handleUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand unblockChannelCommand) throws Throwable;
-
-   Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable;
-}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/DataCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/CacheDataCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/DataCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/DataCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,19 @@
+package org.jboss.cache.commands;
+
+import org.jboss.cache.Fqn;
+
+/**
+ * Commands of this type manipulate data in the cache.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public interface DataCommand extends VisitableCommand
+{
+   /**
+    * Returns the Fqn of the node on which this command operates.
+    *
+    * @return an Fqn
+    */
+   Fqn getFqn();
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/CacheCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,45 @@
+package org.jboss.cache.commands;
+
+import org.jboss.cache.InvocationContext;
+
+/**
+ * The core of the command-based cache framework.  Commands correspond to specific areas of functionality in the cache,
+ * and can be replicated using the {@link org.jboss.cache.marshall.Marshaller} framework.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @author Manik Surtani
+ * @since 2.2.0
+ */
+public interface ReplicableCommand extends Cloneable
+{
+   /**
+    * Performs the primary function of the command.
+    *
+    * @param ctx invocation context
+    * @return arbitrary return value generated by performing this command
+    * @throws Throwable in the event of problems.
+    */
+   Object perform(InvocationContext ctx) throws Throwable;
+
+   /**
+    * Used by marshallers to convert this command into an id for streaming.
+    *
+    * @return the method id of this command.  This is compatible with pre-2.2.0 MethodCall ids.
+    */
+   int getCommandId();
+
+   /**
+    * Used by marshallers to stream this command across a network
+    *
+    * @return an object array of arguments, compatible with pre-2.2.0 MethodCall args.
+    */
+   Object[] getParameters();
+
+   /**
+    * Used by the {@link org.jboss.cache.commands.CommandsFactory} to create a command from raw data read off a stream.
+    *
+    * @param commandId  command id to set.  This is usually unused but *could* be used in the event of a command having multiple IDs, such as {@link org.jboss.cache.commands.write.PutKeyValueCommand}.
+    * @param parameters object array of args
+    */
+   void setParameters(int commandId, Object[] parameters);
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/ReversibleCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/functional/TxCacheCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/ReversibleCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/ReversibleCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,21 @@
+package org.jboss.cache.commands;
+
+import org.jboss.cache.transaction.GlobalTransaction;
+
+/**
+ * A reversible command is one that can be rolled back.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2.0
+ */
+public interface ReversibleCommand extends DataCommand
+{
+   /**
+    * Reverses a command that has already been invoked.
+    */
+   void rollback();
+
+   GlobalTransaction getGlobalTransaction();
+
+   void setGlobalTransaction(GlobalTransaction gtx);
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/VersionedDataCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/state/DataVersionCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/VersionedDataCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/VersionedDataCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,31 @@
+package org.jboss.cache.commands;
+
+import org.jboss.cache.optimistic.DataVersion;
+
+/**
+ * Just like a {@link org.jboss.cache.commands.DataCommand}, except that these are versioned.  And reversible too.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2.0
+ */
+public interface VersionedDataCommand extends ReversibleCommand
+{
+   /**
+    * @return the DataVersion pertaining to this command.
+    */
+   DataVersion getDataVersion();
+
+   /**
+    * Sets the DataVersion pertaining to this command.
+    *
+    * @param dataVersion to set
+    */
+   void setDataVersion(DataVersion dataVersion);
+
+   /**
+    * Has data version set? (i.e. not null)
+    *
+    * @return true if getDataVersion() would not return null; false otherwise.
+    */
+   boolean isVersioned();
+}

Added: core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,22 @@
+package org.jboss.cache.commands;
+
+import org.jboss.cache.InvocationContext;
+
+/**
+ * A type of command that can accept visitors, such as interceptors.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.2.0
+ */
+public interface VisitableCommand extends ReplicableCommand
+{
+   /**
+    * Accept a visitor, and return the result of accepting this visitor.
+    *
+    * @param ctx     invocation context
+    * @param visitor visitor to accept
+    * @return arbitrary return value
+    * @throws Throwable in the event of problems
+    */
+   Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable;
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,155 @@
+package org.jboss.cache.commands;
+
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.RemoteExistsNodeCommand;
+import org.jboss.cache.commands.tx.CommitCommand;
+import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
+import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.CreateNodeCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public interface Visitor
+{
+
+   /*
+   equiv of old:
+     1 - putDataEraseMethodLocal_id
+     2 - putDataMethodLocal_id
+     3 - putDataEraseVersionedMethodLocal_id
+     4 - putDataVersionedMethodLocal_id
+   */
+
+   Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable;
+
+   /*
+     equiv of old:
+       1 - putKeyValMethodLocal_id
+       2 - putKeyValVersionedMethodLocal_id
+       3 - putForExternalReadMethodLocal_id
+       4 - putForExternalReadVersionedMethodLocal_id
+    */
+   Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand putKeyValueCommand) throws Throwable;
+
+   /*
+    equiv of old:
+       1 - removeNodeMethodLocal_id
+       2 - removeNodeVersionedMethodLocal_id
+    */
+   Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand removeNodeCommand) throws Throwable;
+
+   /*
+     equiv of old:
+       1 - removeDataMethodLocal_id
+       2 - removeDataVersionedMethodLocal_id
+    */
+   Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand removeDataCommand) throws Throwable;
+
+   /*
+     equiv of old:
+       1 - evictNodeMethodLocal_id
+       2 - evictVersionedNodeMethodLocal_id
+    */
+   Object handleEvictFqnCommand(InvocationContext ctx, EvictNodeCommand evictFqnCommand) throws Throwable;
+
+   /*
+     equiv of old:
+        1 - invalidateMethodLocal_id
+    */
+   Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand invalidateCommand) throws Throwable;
+
+   /*
+     equiv of old:
+        1 - removeKeyMethodLocal_id
+        1 - removeKeyVersionedMethodLocal_id
+    */
+   Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand removeKeyCommand) throws Throwable;
+
+   /*
+     equiv of old:
+        1 - getDataMapMethodLocal_id
+    */
+   Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand getDataMapCommand) throws Throwable;
+
+   /*
+     equiv of old:
+        1 - existsMethod_id
+    */
+   Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand existsNodeCommand) throws Throwable;
+
+   /*
+     equiv of old:
+        1 - getKeyValueMethodLocal_id
+    */
+   Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand getKeyValueCommand) throws Throwable;
+
+   /*
+     equiv of old:
+        1 - getNodeMethodLocal_id
+    */
+   Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand getNodeCommand) throws Throwable;
+
+   /*
+        equiv of old:
+        1 - getKeysMethodLocal_id
+    */
+   Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand getKeysCommand) throws Throwable;
+
+   /*
+        equiv of old:
+        1 - getChildrenNamesMethodLocal_id
+    */
+   Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand getChildrenNamesCacheCommand) throws Throwable;
+
+   /*
+        equiv of old:
+        1 - moveMethodLocal_id
+    */
+   Object handleMoveCommand(InvocationContext ctx, MoveCommand moveCommand) throws Throwable;
+
+   /*
+        equiv of old:
+        1 - dataGravitationMethod_id
+    */
+   Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand gravitateDataCommand) throws Throwable;
+
+   /*
+      prepareMethod_id
+    */
+   Object handlePrepareCommand(InvocationContext ctx, PrepareCommand prepareCommand) throws Throwable;
+
+   /*
+      rollbackMethod_id
+    */
+   Object handleRollbackCommand(InvocationContext ctx, RollbackCommand rollbackCommand) throws Throwable;
+
+   /*
+      commitMethod_id
+    */
+   Object handleCommitCommand(InvocationContext ctx, CommitCommand commitCommand) throws Throwable;
+
+   /*
+      optimisticPrepareMethod_id
+    */
+   Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand optimisticPrepareCommand) throws Throwable;
+
+
+   Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable;
+}

Added: core/trunk/src/main/java/org/jboss/cache/commands/read/AbstractDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/AbstractDataCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/AbstractDataCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,66 @@
+package org.jboss.cache.commands.read;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.commands.DataCommand;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.invocation.CacheData;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.2.0
+ */
+public abstract class AbstractDataCommand implements DataCommand
+{
+   protected Fqn fqn;
+   protected CacheData cacheData;
+
+   @Inject
+   public void initialize(CacheData cacheData)
+   {
+      this.cacheData = cacheData;
+   }
+
+   public Fqn getFqn()
+   {
+      return fqn;
+   }
+
+   /**
+    * Basic versions of these methods
+    */
+   public Object[] getParameters()
+   {
+      return new Object[]{fqn};
+   }
+
+   /**
+    * Basic versions of these methods
+    */
+   public void setParameters(int commandId, Object[] args)
+   {
+      fqn = (Fqn) args[0];
+   }
+
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      AbstractDataCommand that = (AbstractDataCommand) o;
+
+      return !(fqn != null ? !fqn.equals(that.fqn) : that.fqn != null);
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result;
+      result = (fqn != null ? fqn.hashCode() : 0);
+      result = 31 * result + getClass().hashCode();
+      return result;
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetChildrenNamesCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,70 @@
+package org.jboss.cache.commands.read;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class GetChildrenNamesCommand extends AbstractDataCommand
+{
+   public static final int METHOD_ID = 23;
+
+   public GetChildrenNamesCommand()
+   {
+   }
+
+   public GetChildrenNamesCommand(Fqn fqn)
+   {
+      this.fqn = fqn;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      NodeSPI n = cacheData.findNode(fqn);
+      if (n == null) return null;
+      Set childNames = new HashSet();
+      Map childrenMap = n.getChildrenMapDirect();
+      if (childrenMap == null || childrenMap.isEmpty()) return Collections.emptySet();
+      Collection s = childrenMap.values();
+      // prune deleted children - JBCACHE-1136
+      for (Object c : s)
+      {
+         NodeSPI child = (NodeSPI) c;
+         if (!child.isDeleted())
+         {
+            Object e = child.getFqn().getLastElement();
+            childNames.add(e);
+         }
+      }
+      return childNames;
+   }
+
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleGetChildrenNamesCommand(ctx, this);
+   }
+
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "GetChildrenNamesCommand{" +
+            "fqn=" + fqn +
+            "}";
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetDataMapCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,54 @@
+package org.jboss.cache.commands.read;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+
+import java.util.Collections;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#getData(org.jboss.cache.Fqn)}
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class GetDataMapCommand extends AbstractDataCommand
+{
+   public static final int METHOD_ID = 24;
+
+   public GetDataMapCommand()
+   {
+   }
+
+   public GetDataMapCommand(Fqn fqn)
+   {
+      this.fqn = fqn;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      NodeSPI n = cacheData.findNode(fqn);
+      if (n == null) return null;
+      return Collections.unmodifiableMap(n.getDataDirect());
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleGetDataMapCommand(ctx, this);
+   }
+
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "GetDataMapCommand{" +
+            "cacheData=" + cacheData +
+            ", fqn=" + fqn +
+            '}';
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeyValueCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,138 @@
+package org.jboss.cache.commands.read;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.notifications.Notifier;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.CacheSPI#get(String, Object)}
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class GetKeyValueCommand extends AbstractDataCommand
+{
+   public static final int METHOD_ID = 26;
+   private static final Log log = LogFactory.getLog(GetKeyValueCommand.class);
+   private static boolean trace;
+   private Notifier notifier;
+
+   private Object key;
+   boolean sendNodeEvent;
+
+   public GetKeyValueCommand()
+   {
+      trace = log.isTraceEnabled();
+   }
+
+   public GetKeyValueCommand(Fqn<?> fqn, Object key, boolean sendNodeEvent)
+   {
+      this();
+      this.fqn = fqn;
+      this.key = key;
+      this.sendNodeEvent = sendNodeEvent;
+   }
+
+   @Inject
+   public void injectDependencies(Notifier notifier)
+   {
+      this.notifier = notifier;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      if (trace)
+      {
+         log.trace(new StringBuffer("_get(").append("\"").append(fqn).append("\", \"").append(key).append("\", \"").
+               append(sendNodeEvent).append("\")"));
+      }
+      if (sendNodeEvent) notifier.notifyNodeVisited(fqn, true, ctx);
+      NodeSPI n = cacheData.findNode(fqn);
+      if (n == null)
+      {
+         log.trace("node not found");
+         return null;
+      }
+      if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false, ctx);
+      return n.getDirect(key);
+   }
+
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleGetKeyValueCommand(ctx, this);
+   }
+
+   public Object getKey()
+   {
+      return key;
+   }
+
+   public boolean isSendNodeEvent()
+   {
+      return sendNodeEvent;
+   }
+
+   public void setKey(Object key)
+   {
+      this.key = key;
+   }
+
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   @Override
+   public Object[] getParameters()
+   {
+      return new Object[]{fqn, key, sendNodeEvent};
+   }
+
+   @Override
+   public void setParameters(int commandId, Object[] args)
+   {
+      fqn = (Fqn) args[0];
+      key = args[1];
+      sendNodeEvent = (Boolean) args[2];
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      if (!super.equals(o)) return false;
+
+      GetKeyValueCommand that = (GetKeyValueCommand) o;
+
+      if (sendNodeEvent != that.sendNodeEvent) return false;
+      if (key != null ? !key.equals(that.key) : that.key != null) return false;
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + (key != null ? key.hashCode() : 0);
+      result = 31 * result + (sendNodeEvent ? 1 : 0);
+      return result;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "GetKeyValueCommand{" +
+            "fqn=" + fqn +
+            ", key=" + key +
+            ", sendNodeEvent=" + sendNodeEvent +
+            '}';
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeysCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,58 @@
+package org.jboss.cache.commands.read;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#getKeys(org.jboss.cache.Fqn)}
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class GetKeysCommand extends AbstractDataCommand
+{
+   public static final int METHOD_ID = 25;
+
+   public GetKeysCommand()
+   {
+   }
+
+   public GetKeysCommand(Fqn fqn)
+   {
+      this.fqn = fqn;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      NodeSPI n = cacheData.findNode(fqn);
+      if (n == null)
+      {
+         return null;
+      }
+      Set keys = n.getKeysDirect();
+      return new HashSet(keys);
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleGetKeysCommand(ctx, this);
+   }
+
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "GetKeysCommand{" +
+            "fqn=" + fqn +
+            "}";
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetNodeCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,48 @@
+package org.jboss.cache.commands.read;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.Visitor;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#getNode(org.jboss.cache.Fqn)}
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class GetNodeCommand extends AbstractDataCommand
+{
+   public static final int METHOD_ID = 31;
+
+   public GetNodeCommand()
+   {
+   }
+
+   public GetNodeCommand(Fqn fqn)
+   {
+      this.fqn = fqn;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      return cacheData.findNode(fqn);
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleGetNodeCommand(ctx, this);
+   }
+
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "GetNodeCommand{" +
+            "fqn=" + fqn +
+            "}";
+   }
+}

Added: core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,220 @@
+package org.jboss.cache.commands.read;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.RPCManager;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.GravitateResult;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.marshall.NodeData;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * Used with buddy replication's data gravitation interceptor.  If marshalling is necessary, ensure that the cache is
+ * configured to use {@link org.jboss.cache.config.Configuration#useRegionBasedMarshalling} and the {@link org.jboss.cache.Region}
+ * pertaining to the Fqn passed in is activated, and has an appropriate ClassLoader.
+ */
+public class GravitateDataCommand extends AbstractDataCommand
+{
+   public static final int METHOD_ID = 35;
+
+   /* dependencies */
+   private RPCManager rpcManager;
+   private CacheSPI spi;
+
+   /* parametres */
+   private boolean searchSubtrees;
+
+   private static final Log log = LogFactory.getLog(GravitateDataCommand.class);
+   private static boolean trace;
+
+   public GravitateDataCommand()
+   {
+      trace = log.isTraceEnabled();
+   }
+
+   public GravitateDataCommand(Fqn fqn, boolean searchSubtrees)
+   {
+      this();
+      this.fqn = fqn;
+      this.searchSubtrees = searchSubtrees;
+   }
+
+   @Inject
+   public void initialize(RPCManager manager, CacheSPI spi)
+   {
+      this.rpcManager = manager;
+      this.spi = spi;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      // for now, perform a very simple series of getData calls.
+      if (trace) log.trace("Caller is asking for " + fqn);
+      try
+      {
+         ctx.setOriginLocal(false);
+         // use a get() call into the cache to make sure cache loading takes place.
+         // no need to cache the original skipDataGravitation setting here - it will always be false of we got here!!
+         ctx.getOptionOverrides().setSkipDataGravitation(true);
+         Node actualNode = spi.getNode(fqn);
+         ctx.getOptionOverrides().setSkipDataGravitation(false);
+
+         if (trace) log.trace("In local tree, this is " + actualNode);
+
+         Fqn backupNodeFqn = null;
+         if (actualNode == null && searchSubtrees)
+         {
+            log.trace("Looking at backup trees.");
+            NodeSPI backupSubtree = cacheData.findNode(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
+            if (backupSubtree != null)
+            {
+               // need to loop through backupSubtree's children
+               Set childNames = backupSubtree.getChildrenNamesDirect();
+               if (childNames != null)
+               {
+                  for (Object childName : childNames)
+                  {
+                     // childName is the name of a buddy group since all child names in this
+                     // collection are direct children of BUDDY_BACKUP_SUBTREE_FQN
+                     Fqn backupRoot = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, childName);
+                     if (BuddyFqnTransformer.isDeadBackupRoot(backupRoot))
+                     {
+                        //actualNode = searchDeadRoot(backupRoot, fqn);
+                        Set<Integer> deadChildNames = new TreeSet<Integer>(spi.getChildrenNames(backupRoot));
+                        Integer[] elems = deadChildNames.toArray(new Integer[]{});
+
+                        // these are integers.  we need to start with the highest/most recent.
+                        for (int i = elems.length - 1; i > -1; i--)
+                        {
+                           Integer versionOfDefunctData = elems[i];
+                           backupNodeFqn = Fqn.fromRelativeFqn(Fqn.fromRelativeElements(backupRoot, versionOfDefunctData), fqn);
+
+                           // use a get() call into the cache to make sure cache loading takes place.
+                           ctx.getOptionOverrides().setSkipDataGravitation(true);
+                           actualNode = spi.peek(backupNodeFqn, false);
+                           ctx.getOptionOverrides().setSkipDataGravitation(false);
+
+                           // break out of the inner loop searching through the dead node's various backups
+                           if (actualNode != null) break;
+                        }
+                     }
+                     else
+                     {
+                        backupNodeFqn = Fqn.fromRelativeFqn(backupRoot, fqn);
+                        // use a get() call into the cache to make sure cache loading takes place.
+                        ctx.getOptionOverrides().setSkipDataGravitation(true);
+                        actualNode = spi.getNode(backupNodeFqn);
+                        ctx.getOptionOverrides().setSkipDataGravitation(false);
+                     }
+
+                     if (trace)
+                        log.trace("Looking for " + backupNodeFqn + ". Search result: " + actualNode);
+
+                     // break out of outer loop searching through all available backups.
+                     if (actualNode != null) break;
+                  }
+               }
+            }
+         }
+
+         if (actualNode == null)
+         {
+            return GravitateResult.noDataFound();
+         }
+         else
+         {
+            // make sure we LOAD data for this node!!
+            actualNode.getData();
+         }
+
+         if (backupNodeFqn == null && searchSubtrees)
+         {
+            backupNodeFqn = BuddyFqnTransformer.getBackupFqn(BuddyFqnTransformer.getGroupNameFromAddress(rpcManager.getLocalAddress()), fqn);
+         }
+
+         List<NodeData> list = cacheData.getNodeData(new LinkedList<NodeData>(), (NodeSPI) actualNode);
+
+         return GravitateResult.subtreeResult(list, backupNodeFqn);
+      }
+      catch (RuntimeException re)
+      {
+         if (trace) log.trace("Caught throwable", re);
+         throw re;
+      }
+      finally
+      {
+         ctx.setOriginLocal(true);
+      }
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleGravitateDataCommand(ctx, this);
+   }
+
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   public boolean isSearchSubtrees()
+   {
+      return searchSubtrees;
+   }
+
+   @Override
+   public Object[] getParameters()
+   {
+      return new Object[]{fqn, searchSubtrees};
+   }
+
+   @Override
+   public void setParameters(int commandId, Object[] args)
+   {
+      fqn = (Fqn) args[0];
+      searchSubtrees = (Boolean) args[1];
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      if (!super.equals(o)) return false;
+
+      GravitateDataCommand that = (GravitateDataCommand) o;
+
+      if (searchSubtrees != that.searchSubtrees) return false;
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + (searchSubtrees ? 1 : 0);
+      return result;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "GravitateDataCommand{" +
+            "rpcManager=" + rpcManager +
+            ", searchSubtrees=" + searchSubtrees +
+            '}';
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/read/RemoteExistsNodeCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoteExistsNodeCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/RemoteExistsNodeCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/RemoteExistsNodeCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,52 @@
+package org.jboss.cache.commands.read;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.commands.Visitor;
+
+/**
+ * Checks whether a given node exists in current in-memory state of the cache.
+ * Does not acquire any locks in doing so (result may be dirty read). Does
+ * not attempt to load nodes from a cache loader (may return false if a
+ * node has been evicted).
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ *        todo - this is only used when remote cache calls exists, nut sure it is necessary to have it as a command
+ */
+public class RemoteExistsNodeCommand extends AbstractDataCommand
+{
+   public static final int METHOD_ID = 16;
+
+   public RemoteExistsNodeCommand()
+   {
+   }
+
+   public RemoteExistsNodeCommand(Fqn fqn)
+   {
+      this.fqn = fqn;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      Node n = cacheData.peek(fqn, false);
+      return n != null;
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleExistsNodeCommand(ctx, this);
+   }
+
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "RemoteExistsNodeCommand{}";
+   }
+}

Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -4,7 +4,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.commands.CommandsVisitor;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jgroups.Address;
 
@@ -12,7 +12,7 @@
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
-public class AnnounceBuddyPoolNameCommand extends BaseDirectCommand
+public class AnnounceBuddyPoolNameCommand implements ReplicableCommand
 {
    public static final int METHOD_ID = 28;
    private static final Log log = LogFactory.getLog(AnnounceBuddyPoolNameCommand.class);
@@ -40,8 +40,7 @@
       this.buddyManager = buddyManager;
    }
 
-
-   public Object performDirectly()
+   public Object perform(InvocationContext ctx) throws Throwable
    {
       if (buddyManager != null)
          buddyManager.handlePoolNameBroadcast(address, buddyPoolName);
@@ -51,11 +50,6 @@
       return null;
    }
 
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
-   {
-      return handler.handleAnnounceBuddyPoolName(ctx, this);
-   }
-
    public int getCommandId()
    {
       return METHOD_ID;
@@ -76,7 +70,7 @@
       return new Object[]{address, buddyPoolName};
    }
 
-   public void setState(int commandId, Object[] args)
+   public void setParameters(int commandId, Object[] args)
    {
       address = (Address) args[0];
       buddyPoolName = (String) args[1];

Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -4,7 +4,7 @@
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.buddyreplication.BuddyGroup;
 import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.commands.CommandsVisitor;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.factories.annotations.Inject;
 
 import java.util.Arrays;
@@ -14,7 +14,7 @@
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
-public class AssignToBuddyGroupCommand extends BaseDirectCommand
+public class AssignToBuddyGroupCommand implements ReplicableCommand
 {
    public static final int METHOD_ID = 29;
 
@@ -40,7 +40,7 @@
       this.buddyManager = manager;
    }
 
-   public Object performDirectly() throws Exception
+   public Object perform(InvocationContext ctx) throws Throwable
    {
       if (buddyManager != null)
          buddyManager.handleAssignToBuddyGroup(group, state);
@@ -48,11 +48,6 @@
       return null;
    }
 
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
-   {
-      return handler.handleAssignToBuddyGroupCommand(ctx, this);
-   }
-
    public int getCommandId()
    {
       return METHOD_ID;
@@ -74,7 +69,7 @@
    }
 
    @SuppressWarnings("unchecked")
-   public void setState(int commandId, Object[] args)
+   public void setParameters(int commandId, Object[] args)
    {
       group = (BuddyGroup) args[0];
       state = (Map) args[1];

Deleted: core/trunk/src/main/java/org/jboss/cache/commands/remote/BaseDirectCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/BaseDirectCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/BaseDirectCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,18 +0,0 @@
-package org.jboss.cache.commands.remote;
-
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.BaseCommand;
-
-/**
- * Base class that implements DirectCommand
- *
- * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
- * @since 2.2.0
- */
-public abstract class BaseDirectCommand extends BaseCommand implements DirectCommand
-{
-   public final Object perform(InvocationContext ctx)
-   {
-      throw new UnsupportedOperationException("Direct commands are not meant to be passed up the interceptor chain!");
-   }
-}

Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -3,10 +3,11 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CommandsVisitor;
-import org.jboss.cache.commands.cachedata.CacheDataCommand;
-import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
-import org.jboss.cache.commands.cachedata.GetDataMapCommand;
+import org.jboss.cache.commands.DataCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.RemoteExistsNodeCommand;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.invocation.CacheData;
 import org.jboss.cache.invocation.InterceptorChain;
@@ -19,11 +20,11 @@
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
-public class ClusteredGetCommand extends BaseDirectCommand
+public class ClusteredGetCommand implements ReplicableCommand
 {
    public static final int METHOD_ID = 22;
 
-   private CacheDataCommand cacheDataComand;
+   private DataCommand cacheDataComand;
    private Boolean searchBackupSubtrees;
    private CacheData cacheData;
    private InterceptorChain interceptorChain;
@@ -36,7 +37,7 @@
       trace = log.isTraceEnabled();
    }
 
-   public ClusteredGetCommand(Boolean searchBackupSubtrees, CacheDataCommand cacheDataComand)
+   public ClusteredGetCommand(Boolean searchBackupSubtrees, DataCommand cacheDataComand)
    {
       this();
       this.searchBackupSubtrees = searchBackupSubtrees;
@@ -56,7 +57,7 @@
     * @return a List containing 2 elements: (true or false) and a value (Object).  If buddy replication
     *         is used one further element is added - an Fqn of the backup subtree in which this node may be found.
     */
-   public Object performDirectly() throws Throwable
+   public Object perform(InvocationContext context) throws Throwable
    {
       if (trace)
          log.trace("Clustered Get called with params: " + cacheDataComand + ", " + searchBackupSubtrees);
@@ -92,12 +93,6 @@
       return results;
    }
 
-
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
-   {
-      return handler.handleClusteredGetCommand(ctx, this);
-   }
-
    public int getCommandId()
    {
       return METHOD_ID;
@@ -132,7 +127,7 @@
       return searchBackupSubtrees;
    }
 
-   public CacheDataCommand getCacheDataComand()
+   public DataCommand getCacheDataComand()
    {
       return cacheDataComand;
    }
@@ -142,9 +137,9 @@
       return new Object[]{cacheDataComand, searchBackupSubtrees};  //To change body of implemented methods use File | Settings | File Templates.
    }
 
-   public void setState(int commandId, Object[] args)
+   public void setParameters(int commandId, Object[] args)
    {
-      cacheDataComand = (CacheDataCommand) args[0];
+      cacheDataComand = (DataCommand) args[0];
       searchBackupSubtrees = (Boolean) args[1];
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -8,13 +8,11 @@
 import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
 import org.jboss.cache.buddyreplication.BuddyManager;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.CommandsVisitor;
-import org.jboss.cache.commands.cachedata.EvictNodeCommand;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
-import org.jboss.cache.commands.functional.TxCacheCommand;
-import org.jboss.cache.commands.state.BaseCacheDataCommand;
-import org.jboss.cache.commands.state.GlobalTransactionCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.invocation.CacheData;
 import org.jboss.cache.invocation.CacheTransactionHelper;
 import org.jboss.cache.invocation.InterceptorChain;
 import org.jboss.cache.transaction.GlobalTransaction;
@@ -26,10 +24,8 @@
  *
  * @author Mircea.Markus at jboss.com
  * @since 2.2
- *        todo this calls other commands through the invocation chain, check wheter direct call is not okay
- *        todo it is not natural for this command to extend TxCC, revisit
  */
-public class DataGravitationCleanupCommand extends BaseCacheDataCommand implements TxCacheCommand, GlobalTransactionCommand, DirectCommand
+public class DataGravitationCleanupCommand implements ReplicableCommand
 {
    public static final int METHOD_ID = 34;
 
@@ -38,14 +34,17 @@
    private CacheTransactionHelper transactionHelper;
    private InterceptorChain invoker;
    private CommandsFactory commandsFactory;
+   private CacheData cacheData;
 
    private static final Log log = LogFactory.getLog(DataGravitationCleanupCommand.class);
    private static boolean trace;
 
    /* parameters */
    private GlobalTransaction globalTransaction;
+   private Fqn fqn;
    private Fqn backup;
 
+
    public DataGravitationCleanupCommand()
    {
       trace = log.isTraceEnabled();
@@ -60,12 +59,13 @@
 
    @Inject
    public void initialize(BuddyManager buddyManager, InterceptorChain invoker, CacheTransactionHelper transactionHelper,
-                          CommandsFactory commandsFactory)
+                          CommandsFactory commandsFactory, CacheData cacheData)
    {
       this.buddyManager = buddyManager;
       this.invoker = invoker;
       this.transactionHelper = transactionHelper;
       this.commandsFactory = commandsFactory;
+      this.cacheData = cacheData;
    }
 
    public Object perform(InvocationContext ctx)
@@ -158,21 +158,11 @@
       }
    }
 
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
-   {
-      return handler.handleDataGravitationCleanupCommand(ctx, this);
-   }
-
    public int getCommandId()
    {
       return METHOD_ID;
    }
 
-   public void rollback()
-   {
-      //nothing
-   }
-
    public Fqn getBackup()
    {
       return backup;
@@ -188,14 +178,17 @@
       this.globalTransaction = gtx;
    }
 
-   @Override
+   public Fqn getFqn()
+   {
+      return fqn;
+   }
+
    public Object[] getParameters()
    {
       return new Object[]{fqn, backup};  //To change body of implemented methods use File | Settings | File Templates.
    }
 
-   @Override
-   public void setState(int commandId, Object[] args)
+   public void setParameters(int commandId, Object[] args)
    {
       fqn = (Fqn) args[0];
       backup = (Fqn) args[1];

Deleted: core/trunk/src/main/java/org/jboss/cache/commands/remote/DirectCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/DirectCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DirectCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,20 +0,0 @@
-package org.jboss.cache.commands.remote;
-
-import org.jboss.cache.commands.functional.MarshallableCommand;
-
-/**
- * Commands implementing this interface will not be passed up the interceptor chain and instead will be executed directly.
- *
- * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
- * @since 2.2.0
- */
-public interface DirectCommand extends MarshallableCommand
-{
-   /**
-    * Performs this command directly, with no invocation context.
-    *
-    * @return an object if this call was to return values, otherwise null.
-    * @throws Throwable if something goes wrong
-    */
-   Object performDirectly() throws Throwable;
-}

Deleted: core/trunk/src/main/java/org/jboss/cache/commands/remote/GravitateDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/GravitateDataCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/GravitateDataCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,220 +0,0 @@
-package org.jboss.cache.commands.remote;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.RPCManager;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CommandsVisitor;
-import org.jboss.cache.commands.state.BaseCacheDataCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.marshall.NodeData;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Used with buddy replication's data gravitation interceptor.  If marshalling is necessary, ensure that the cache is
- * configured to use {@link org.jboss.cache.config.Configuration#useRegionBasedMarshalling} and the {@link org.jboss.cache.Region}
- * pertaining to the Fqn passed in is activated, and has an appropriate ClassLoader.
- * todo - this should not be a command as none relally visits it. It was inherited this way from old CacheImpl
- */
-public class GravitateDataCommand extends BaseCacheDataCommand implements CacheCommand
-{
-   public static final int METHOD_ID = 35;
-
-   /* dependencies */
-   private RPCManager rpcManager;
-
-   /* parametres */
-   private boolean searchSubtrees;
-
-   private static final Log log = LogFactory.getLog(GravitateDataCommand.class);
-   private static boolean trace;
-
-   public GravitateDataCommand()
-   {
-      trace = log.isTraceEnabled();
-   }
-
-   public GravitateDataCommand(Fqn fqn, boolean searchSubtrees)
-   {
-      this();
-      this.fqn = fqn;
-      this.searchSubtrees = searchSubtrees;
-   }
-
-   @Inject
-   public void initialize(RPCManager manager)
-   {
-      this.rpcManager = manager;
-   }
-
-   public Object perform(InvocationContext ctx)
-   {
-      // for now, perform a very simple series of getData calls.
-      if (trace) log.trace("Caller is asking for " + fqn);
-      try
-      {
-         ctx.setOriginLocal(false);
-         // use a get() call into the cache to make sure cache loading takes place.
-         // no need to cache the original skipDataGravitation setting here - it will always be false of we got here!!
-         ctx.getOptionOverrides().setSkipDataGravitation(true);
-         Node actualNode = spi.getNode(fqn);
-         ctx.getOptionOverrides().setSkipDataGravitation(false);
-
-         if (trace) log.trace("In local tree, this is " + actualNode);
-
-         Fqn backupNodeFqn = null;
-         if (actualNode == null && searchSubtrees)
-         {
-            log.trace("Looking at backup trees.");
-            NodeSPI backupSubtree = cacheData.findNode(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
-            if (backupSubtree != null)
-            {
-               // need to loop through backupSubtree's children
-               Set childNames = backupSubtree.getChildrenNamesDirect();
-               if (childNames != null)
-               {
-                  for (Object childName : childNames)
-                  {
-                     // childName is the name of a buddy group since all child names in this
-                     // collection are direct children of BUDDY_BACKUP_SUBTREE_FQN
-                     Fqn backupRoot = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, childName);
-                     if (BuddyFqnTransformer.isDeadBackupRoot(backupRoot))
-                     {
-                        //actualNode = searchDeadRoot(backupRoot, fqn);
-                        Set<Integer> deadChildNames = new TreeSet<Integer>(spi.getChildrenNames(backupRoot));
-                        Integer[] elems = deadChildNames.toArray(new Integer[]{});
-
-                        // these are integers.  we need to start with the highest/most recent.
-                        for (int i = elems.length - 1; i > -1; i--)
-                        {
-                           Integer versionOfDefunctData = elems[i];
-                           backupNodeFqn = Fqn.fromRelativeFqn(Fqn.fromRelativeElements(backupRoot, versionOfDefunctData), fqn);
-
-                           // use a get() call into the cache to make sure cache loading takes place.
-                           ctx.getOptionOverrides().setSkipDataGravitation(true);
-                           actualNode = spi.peek(backupNodeFqn, false);
-                           ctx.getOptionOverrides().setSkipDataGravitation(false);
-
-                           // break out of the inner loop searching through the dead node's various backups
-                           if (actualNode != null) break;
-                        }
-                     }
-                     else
-                     {
-                        backupNodeFqn = Fqn.fromRelativeFqn(backupRoot, fqn);
-                        // use a get() call into the cache to make sure cache loading takes place.
-                        ctx.getOptionOverrides().setSkipDataGravitation(true);
-                        actualNode = spi.getNode(backupNodeFqn);
-                        ctx.getOptionOverrides().setSkipDataGravitation(false);
-                     }
-
-                     if (trace)
-                        log.trace("Looking for " + backupNodeFqn + ". Search result: " + actualNode);
-
-                     // break out of outer loop searching through all available backups.
-                     if (actualNode != null) break;
-                  }
-               }
-            }
-         }
-
-         if (actualNode == null)
-         {
-            return GravitateResult.noDataFound();
-         }
-         else
-         {
-            // make sure we LOAD data for this node!!
-            actualNode.getData();
-         }
-
-         if (backupNodeFqn == null && searchSubtrees)
-         {
-            backupNodeFqn = BuddyFqnTransformer.getBackupFqn(BuddyFqnTransformer.getGroupNameFromAddress(rpcManager.getLocalAddress()), fqn);
-         }
-
-         List<NodeData> list = cacheData.getNodeData(new LinkedList<NodeData>(), (NodeSPI) actualNode);
-
-         return GravitateResult.subtreeResult(list, backupNodeFqn);
-      }
-      catch (RuntimeException re)
-      {
-         if (trace) log.trace("Caught throwable", re);
-         throw re;
-      }
-      finally
-      {
-         ctx.setOriginLocal(true);
-      }
-   }
-
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
-   {
-      return handler.handleGravitateDataCommand(ctx, this);
-   }
-
-   public int getCommandId()
-   {
-      return METHOD_ID;
-   }
-
-   public boolean isSearchSubtrees()
-   {
-      return searchSubtrees;
-   }
-
-   @Override
-   public Object[] getParameters()
-   {
-      return new Object[]{fqn, searchSubtrees};
-   }
-
-   @Override
-   public void setState(int commandId, Object[] args)
-   {
-      fqn = (Fqn) args[0];
-      searchSubtrees = (Boolean) args[1];
-   }
-
-   @Override
-   public boolean equals(Object o)
-   {
-      if (this == o) return true;
-      if (o == null || getClass() != o.getClass()) return false;
-      if (!super.equals(o)) return false;
-
-      GravitateDataCommand that = (GravitateDataCommand) o;
-
-      if (searchSubtrees != that.searchSubtrees) return false;
-
-      return true;
-   }
-
-   @Override
-   public int hashCode()
-   {
-      int result = super.hashCode();
-      result = 31 * result + (searchSubtrees ? 1 : 0);
-      return result;
-   }
-
-   @Override
-   public String toString()
-   {
-      return "GravitateDataCommand{" +
-            "rpcManager=" + rpcManager +
-            ", searchSubtrees=" + searchSubtrees +
-            '}';
-   }
-}

Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -2,14 +2,14 @@
 
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.commands.CommandsVisitor;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.factories.annotations.Inject;
 
 /**
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
-public class RemoveFromBuddyGroupCommand extends BaseDirectCommand
+public class RemoveFromBuddyGroupCommand implements ReplicableCommand
 {
    public static final int METHOD_ID = 30;
 
@@ -32,18 +32,13 @@
       this.buddyManager = buddyManager;
    }
 
-   public Object performDirectly()
+   public Object perform(InvocationContext ctx)
    {
       if (buddyManager != null)
          buddyManager.handleRemoveFromBuddyGroup(groupName);
       return null;
    }
 
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
-   {
-      return handler.handleRemoveFromBuddyGroupCommand(ctx, this);
-   }
-
    public int getCommandId()
    {
       return METHOD_ID;
@@ -59,7 +54,7 @@
       return new Object[]{groupName};
    }
 
-   public void setState(int commandId, Object[] args)
+   public void setParameters(int commandId, Object[] args)
    {
       groupName = (String) args[0];
    }

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-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -3,10 +3,10 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CommandsVisitor;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.invocation.InterceptorChain;
 
@@ -18,7 +18,7 @@
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
-public class ReplicateCommand extends BaseDirectCommand
+public class ReplicateCommand implements ReplicableCommand
 {
    public static final int SINGLE_METHOD_ID = 13;
    public static final int MULTIPLE_METHOD_ID = 14;
@@ -32,15 +32,15 @@
     * optimisation - rather than constructing a new list each for scenarios where a single modification needs
     * to be replicated rather use this instance.
     */
-   private MarshallableCommand singleModification;
-   private List<MarshallableCommand> modifications;
+   private ReplicableCommand singleModification;
+   private List<ReplicableCommand> modifications;
 
    public ReplicateCommand()
    {
       trace = log.isTraceEnabled();
    }
 
-   public ReplicateCommand(List<MarshallableCommand> modifications)
+   public ReplicateCommand(List<ReplicableCommand> modifications)
    {
       this();
       if (modifications != null && modifications.size() == 1)
@@ -53,7 +53,7 @@
       }
    }
 
-   public ReplicateCommand(MarshallableCommand command)
+   public ReplicateCommand(ReplicableCommand command)
    {
       this();
       this.singleModification = command;
@@ -65,14 +65,14 @@
       this.invoker = interceptorChain;
    }
 
-   public Object performDirectly() throws Throwable
+   public Object perform(InvocationContext ctx) throws Throwable
    {
       if (isSingleCommand()) return processSingleCommand(singleModification);
-      for (MarshallableCommand command : modifications) processSingleCommand(command);
+      for (ReplicableCommand command : modifications) processSingleCommand(command);
       return null;
    }
 
-   private Object processSingleCommand(MarshallableCommand cacheCommand)
+   private Object processSingleCommand(ReplicableCommand cacheCommand)
          throws Throwable
    {
       Object result;
@@ -80,13 +80,9 @@
       {
          if (trace) log.trace("Invoking command " + cacheCommand + ", with originLocal flag set to false.");
 
-         if (cacheCommand instanceof DirectCommand)
+         if (cacheCommand instanceof VisitableCommand)
          {
-            result = ((DirectCommand) cacheCommand).performDirectly();
-         }
-         else
-         {
-            Object retVal = invoker.invokeRemote(cacheCommand);
+            Object retVal = invoker.invokeRemote((VisitableCommand) cacheCommand);
             // we only need to return values for a set of remote calls; not every call.
             if (returnValueForRemoteCall(cacheCommand))
             {
@@ -97,6 +93,10 @@
                result = null;
             }
          }
+         else
+         {
+            result = cacheCommand.perform(null);
+         }
       }
       catch (Throwable ex)
       {
@@ -114,34 +114,29 @@
       return result;
    }
 
-   private boolean isPutForExternalRead(CacheCommand cacheCommand)
+   private boolean isPutForExternalRead(ReplicableCommand cacheCommand)
    {
       if (!(cacheCommand instanceof PutKeyValueCommand)) return false;
       PutKeyValueCommand pkvCommand = (PutKeyValueCommand) cacheCommand;
       return pkvCommand.isPutForExternalRead();
    }
 
-   private boolean returnValueForRemoteCall(CacheCommand cacheCommand)
+   private boolean returnValueForRemoteCall(ReplicableCommand cacheCommand)
    {
       return cacheCommand instanceof GravitateDataCommand || cacheCommand instanceof ClusteredGetCommand;
    }
 
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
-   {
-      return handler.handleReplicateCommand(ctx, this);
-   }
-
    public int getCommandId()
    {
       return isSingleCommand() ? SINGLE_METHOD_ID : MULTIPLE_METHOD_ID;
    }
 
-   public List<MarshallableCommand> getModifications()
+   public List<ReplicableCommand> getModifications()
    {
       return modifications;
    }
 
-   public MarshallableCommand getSingleModification()
+   public ReplicableCommand getSingleModification()
    {
       return singleModification;
    }
@@ -155,15 +150,15 @@
    }
 
    @SuppressWarnings("unchecked")
-   public void setState(int commandId, Object[] args)
+   public void setParameters(int commandId, Object[] args)
    {
       if (commandId == SINGLE_METHOD_ID)
       {
-         singleModification = (MarshallableCommand) args[0];
+         singleModification = (ReplicableCommand) args[0];
       }
       else
       {
-         modifications = (List<MarshallableCommand>) args[0];
+         modifications = (List<ReplicableCommand>) args[0];
       }
    }
 

Copied: core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/tx/BaseGlobalTransactionCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,74 @@
+package org.jboss.cache.commands.tx;
+
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+/**
+ * Base class for transaction boundary commands that deal with global transactions
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.2.0
+ */
+public abstract class AbstractTransactionCommand implements VisitableCommand
+{
+   protected GlobalTransaction globalTransaction;
+
+   /**
+    * Default implementation which is a no-op.
+    *
+    * @return null
+    */
+   public Object perform(InvocationContext ctx)
+   {
+      return null;
+   }
+
+   public GlobalTransaction getGlobalTransaction()
+   {
+      return globalTransaction;
+   }
+
+   public void setGlobalTransaction(GlobalTransaction gtx)
+   {
+      this.globalTransaction = gtx;
+   }
+
+   public Object[] getParameters()
+   {
+      return new Object[]{globalTransaction};
+   }
+
+   public void setParameters(int commandId, Object[] args)
+   {
+      globalTransaction = (GlobalTransaction) args[0];
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      AbstractTransactionCommand that = (AbstractTransactionCommand) o;
+
+      if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
+         return false;
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return (globalTransaction != null ? globalTransaction.hashCode() : 0);
+   }
+
+   @Override
+   public String toString()
+   {
+      return getClass().getSimpleName() + "{" +
+            "gtx=" + globalTransaction +
+            '}';
+   }
+}

Deleted: core/trunk/src/main/java/org/jboss/cache/commands/tx/BaseGlobalTransactionCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/BaseGlobalTransactionCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/BaseGlobalTransactionCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,75 +0,0 @@
-package org.jboss.cache.commands.tx;
-
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.BaseCommand;
-import org.jboss.cache.commands.state.GlobalTransactionCommand;
-import org.jboss.cache.transaction.GlobalTransaction;
-
-/**
- * Base class for transaction boundary commands that deal with global transactions
- *
- * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
- * @since 2.2.0
- */
-public abstract class BaseGlobalTransactionCommand extends BaseCommand implements GlobalTransactionCommand
-{
-   protected GlobalTransaction globalTransaction;
-
-   /**
-    * Default implementation which is a no-op.
-    *
-    * @return null
-    */
-   public Object perform(InvocationContext ctx)
-   {
-      return null;
-   }
-
-   public GlobalTransaction getGlobalTransaction()
-   {
-      return globalTransaction;
-   }
-
-   public void setGlobalTransaction(GlobalTransaction gtx)
-   {
-      this.globalTransaction = gtx;
-   }
-
-   public Object[] getParameters()
-   {
-      return new Object[]{globalTransaction};
-   }
-
-   public void setState(int commandId, Object[] args)
-   {
-      globalTransaction = (GlobalTransaction) args[0];
-   }
-
-   @Override
-   public boolean equals(Object o)
-   {
-      if (this == o) return true;
-      if (o == null || getClass() != o.getClass()) return false;
-
-      BaseGlobalTransactionCommand that = (BaseGlobalTransactionCommand) o;
-
-      if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
-         return false;
-
-      return true;
-   }
-
-   @Override
-   public int hashCode()
-   {
-      return (globalTransaction != null ? globalTransaction.hashCode() : 0);
-   }
-
-   @Override
-   public String toString()
-   {
-      return getClass().getSimpleName() + "{" +
-            "gtx=" + globalTransaction +
-            '}';
-   }
-}

Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,14 +1,14 @@
 package org.jboss.cache.commands.tx;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CommandsVisitor;
+import org.jboss.cache.commands.Visitor;
 import org.jboss.cache.transaction.GlobalTransaction;
 
 /**
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
-public class CommitCommand extends BaseGlobalTransactionCommand
+public class CommitCommand extends AbstractTransactionCommand
 {
    public static final int METHOD_ID = 11;
 
@@ -21,9 +21,9 @@
       this.globalTransaction = globalTransaction;
    }
 
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
    {
-      return handler.handleCommitCommand(ctx, this);
+      return visitor.handleCommitCommand(ctx, this);
    }
 
    public int getCommandId()

Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,8 +1,8 @@
 package org.jboss.cache.commands.tx;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CommandsVisitor;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.Visitor;
 import org.jboss.cache.transaction.GlobalTransaction;
 import org.jgroups.Address;
 
@@ -22,16 +22,16 @@
    {
    }
 
-   public OptimisticPrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Map data, Address address, boolean onePhaseCommit)
+   public OptimisticPrepareCommand(GlobalTransaction gtx, List<ReversibleCommand> modifications, Map data, Address address, boolean onePhaseCommit)
    {
       super(gtx, modifications, address, onePhaseCommit);
       this.data = data;
    }
 
    @Override
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
    {
-      return handler.handleOptimisticPrepareCommand(ctx, this);
+      return visitor.handleOptimisticPrepareCommand(ctx, this);
    }
 
    public Map getData()
@@ -53,10 +53,10 @@
 
    @Override
    @SuppressWarnings("unchecked")
-   public void setState(int commandId, Object[] args)
+   public void setParameters(int commandId, Object[] args)
    {
       globalTransaction = (GlobalTransaction) args[0];
-      modifications = (List<? extends CacheCommand>) args[1];
+      modifications = (List<ReversibleCommand>) args[1];
       data = (Map) args[2];
       localAddress = (Address) args[3];
       onePhaseCommit = (Boolean) args[4];

Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,8 +1,8 @@
 package org.jboss.cache.commands.tx;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CommandsVisitor;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.Visitor;
 import org.jboss.cache.transaction.GlobalTransaction;
 import org.jgroups.Address;
 
@@ -14,11 +14,11 @@
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
-public class PrepareCommand extends BaseGlobalTransactionCommand
+public class PrepareCommand extends AbstractTransactionCommand
 {
    public static final int METHOD_ID = 10;
 
-   protected List<? extends CacheCommand> modifications;
+   protected List<ReversibleCommand> modifications;
    protected Address localAddress;
    protected boolean onePhaseCommit;
 
@@ -26,7 +26,7 @@
    {
    }
 
-   public PrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Address localAddress, boolean onePhaseCommit)
+   public PrepareCommand(GlobalTransaction gtx, List<ReversibleCommand> modifications, Address localAddress, boolean onePhaseCommit)
    {
       this.globalTransaction = gtx;
       this.modifications = modifications;
@@ -34,12 +34,12 @@
       this.onePhaseCommit = onePhaseCommit;
    }
 
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
    {
-      return handler.handlePrepareCommand(ctx, this);
+      return visitor.handlePrepareCommand(ctx, this);
    }
 
-   public List<? extends CacheCommand> getModifications()
+   public List<ReversibleCommand> getModifications()
    {
       return modifications;
    }
@@ -77,10 +77,10 @@
 
    @Override
    @SuppressWarnings("unchecked")
-   public void setState(int commandId, Object[] args)
+   public void setParameters(int commandId, Object[] args)
    {
       globalTransaction = (GlobalTransaction) args[0];
-      modifications = (List<? extends CacheCommand>) args[1];
+      modifications = (List<ReversibleCommand>) args[1];
       localAddress = (Address) args[2];
       onePhaseCommit = (Boolean) args[3];
    }

Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,14 +1,14 @@
 package org.jboss.cache.commands.tx;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CommandsVisitor;
+import org.jboss.cache.commands.Visitor;
 import org.jboss.cache.transaction.GlobalTransaction;
 
 /**
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
-public class RollbackCommand extends BaseGlobalTransactionCommand
+public class RollbackCommand extends AbstractTransactionCommand
 {
    public static final int METHOD_ID = 12;
 
@@ -21,9 +21,9 @@
       this.globalTransaction = globalTransaction;
    }
 
-   public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
    {
-      return handler.handleRollbackCommand(ctx, this);
+      return visitor.handleRollbackCommand(ctx, this);
    }
 
    public int getCommandId()

Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/state/BaseDataVersionCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,87 @@
+package org.jboss.cache.commands.write;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.commands.VersionedDataCommand;
+import org.jboss.cache.commands.read.AbstractDataCommand;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.notifications.Notifier;
+import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+/**
+ * Base version of {@link org.jboss.cache.commands.DataCommand} which handles common behaviour
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.2.0
+ */
+public abstract class AbstractVersionedDataCommand extends AbstractDataCommand implements VersionedDataCommand
+{
+   protected DataVersion dataVersion;
+   protected Notifier notifier;
+   protected GlobalTransaction globalTransaction;
+
+   @Inject
+   public void injectNotifier(Notifier notifier)
+   {
+      this.notifier = notifier;
+   }
+
+   public DataVersion getDataVersion()
+   {
+      return dataVersion;
+   }
+
+   public void setDataVersion(DataVersion dataVersion)
+   {
+      this.dataVersion = dataVersion;
+   }
+
+   public GlobalTransaction getGlobalTransaction()
+   {
+      return globalTransaction;
+   }
+
+   public void setGlobalTransaction(GlobalTransaction globalTransaction)
+   {
+      this.globalTransaction = globalTransaction;
+   }
+
+   public boolean isVersioned()
+   {
+      return dataVersion != null;
+   }
+
+   // basic implementations
+   @Override
+   public Object[] getParameters()
+   {
+      if (isVersioned())
+         return new Object[]{fqn, dataVersion};
+      else
+         return new Object[]{fqn};
+   }
+
+   // basic implementations
+   @Override
+   public void setParameters(int commandId, Object[] args)
+   {
+      fqn = (Fqn) args[0];
+      if (isVersionedId(commandId)) dataVersion = (DataVersion) args[1];
+   }
+
+   protected abstract boolean isVersionedId(int id);
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (!super.equals(o)) return false;
+      AbstractVersionedDataCommand that = (AbstractVersionedDataCommand) o;
+      return !(fqn != null ? !fqn.equals(that.fqn) : that.fqn != null);
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return 31 * super.hashCode() + (dataVersion != null ? dataVersion.hashCode() : 0);
+   }
+}
\ No newline at end of file

Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/CreateNodeCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/CreateNodeCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/CreateNodeCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/CreateNodeCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,90 @@
+package org.jboss.cache.commands.write;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.commands.read.AbstractDataCommand;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Command that creates a node.  Primarily to be used as an undo command for removing nodes.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.2.0
+ */
+public class CreateNodeCommand extends AbstractDataCommand implements ReversibleCommand
+{
+   public static final int METHOD_ID = 48;
+   private final List<Fqn> newlyCreated = new LinkedList<Fqn>();
+
+   public CreateNodeCommand()
+   {
+   }
+
+   public CreateNodeCommand(Fqn fqn)
+   {
+      this.fqn = fqn;
+      newlyCreated.add(fqn);
+   }
+
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   public void setGlobalTransaction(GlobalTransaction gtx)
+   {
+      // no op
+   }
+
+   public GlobalTransaction getGlobalTransaction()
+   {
+      return null;
+   }
+
+   public Object perform(InvocationContext ctx) throws Throwable
+   {
+      Object[] results = cacheData.createNodes(fqn);
+      List<NodeSPI> created = (List<NodeSPI>) results[0];
+
+      boolean foundFqn = false;
+      if (!created.isEmpty())
+      {
+         for (NodeSPI n : created)
+         {
+            if (fqn.equals(n.getFqn())) foundFqn = true;
+            newlyCreated.add(n.getFqn());
+         }
+      }
+      if (!foundFqn) newlyCreated.remove(fqn);
+
+      return results[1];
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleCreateNodeCommand(ctx, this);
+   }
+
+   public void rollback()
+   {
+      if (newlyCreated != null)
+      {
+         for (Fqn f : newlyCreated) cacheData.realRemove(f, true);
+      }
+   }
+
+   @Override
+   public String toString()
+   {
+      return "CreateNodeCommand{" +
+            "fqn=" + fqn +
+            ", newlyCreated=" + newlyCreated +
+            '}';
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/EvictNodeCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/EvictNodeCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/EvictNodeCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/EvictNodeCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,60 @@
+package org.jboss.cache.commands.write;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.Visitor;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.CacheSPI#evict(org.jboss.cache.Fqn)}
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class EvictNodeCommand extends AbstractVersionedDataCommand
+{
+   public static final int METHOD_ID = 8;
+   public static final int VERSIONED_METHOD_ID = 9;
+
+   public EvictNodeCommand(Fqn fqn)
+   {
+      this.fqn = fqn;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      notifier.notifyNodeEvicted(fqn, true, ctx);
+      boolean evicted = cacheData.evict(fqn);
+      notifier.notifyNodeEvicted(fqn, false, ctx);
+      return evicted;
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleEvictFqnCommand(ctx, this);
+   }
+
+   public int getCommandId()
+   {
+      return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
+   }
+
+   @Override
+   protected boolean isVersionedId(int id)
+   {
+      return VERSIONED_METHOD_ID == id;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "EvictNodeCommand{" +
+            "fqn=" + fqn +
+            ", dataVersion=" + dataVersion +
+            "}";
+   }
+
+   public void rollback()
+   {
+      // this is a no-op.
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,188 @@
+package org.jboss.cache.commands.write;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.factories.annotations.Inject;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Very much like an evict(), except that regardless of whether there is a child present, this call will never
+ * remove the node from memory - just remove its contents.
+ * <p/>
+ * Also, potentially throws a cache exception if data versioning is used and the node in memory has a newer data
+ * version than what is passed in.
+ * <p/>
+ * Finally, the data version of the in-memory node is updated to the version being evicted to prevent versions
+ * going out of sync.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class InvalidateCommand extends EvictNodeCommand
+{
+   public static final int METHOD_ID = 47;
+   private static final Log log = LogFactory.getLog(InvalidateCommand.class);
+   private static boolean trace;
+
+   /* dependencies*/
+   private boolean isOptimisticLocking;
+   private TransactionManager transactionManager;
+   private CacheSPI spi;
+
+   public InvalidateCommand()
+   {
+      super(null);
+      trace = log.isTraceEnabled();
+   }
+
+   public InvalidateCommand(Fqn fqn)
+   {
+      super(fqn);
+      trace = log.isTraceEnabled();
+   }
+
+   @Inject
+   public void initialize(TransactionManager txManager, Configuration configuration, CacheSPI spi)
+   {
+      this.transactionManager = txManager;
+      this.spi = spi;
+      this.isOptimisticLocking = configuration.isNodeLockingOptimistic();
+   }
+
+   @Override
+   public Object perform(InvocationContext ctx)
+   {
+      //todo - rather than using CacheSPI this can rely in cache loader directly to load data
+      Node node = spi.getNode(fqn); // force interceptor chain, load if necessary from cache loader.
+
+      if (trace) log.trace("Invalidating fqn:" + fqn);
+      if (node == null)
+      {
+         // if pessimistic locking, just return.
+         if (!isOptimisticLocking) return null;
+
+         // check if a tombstone already exists
+         NodeSPI nodeSPI = cacheData.peek(fqn, false, true);
+         if (nodeSPI == null)
+         {
+            if (dataVersion == null)
+            {
+               if (trace)
+                  log.trace("Would have created a tombstone since the node doesn't exist, but the version to invalidate is null and hence cannot create a tombstone!");
+               return null;
+            }
+            if (trace)
+               log.trace("Node doesn't exist; creating a tombstone with data version " + dataVersion);
+            // create the node we need.
+            Map m = Collections.emptyMap();
+            InvocationContext ic = spi.getInvocationContext();
+            Option o = ic.getOptionOverrides();
+            boolean origCacheModeLocal = o.isCacheModeLocal();
+            o.setCacheModeLocal(true);
+            o.setDataVersion(dataVersion);
+            // if we are in a tx this call should happen outside of any tx
+            try
+            {
+               Transaction suspended = null;
+               if (transactionManager != null)
+               {
+                  suspended = transactionManager.suspend();
+               }
+               spi.put(fqn, m);
+               if (suspended != null) transactionManager.resume(suspended);
+               ic.getOptionOverrides().setCacheModeLocal(origCacheModeLocal);
+            }
+            catch (Exception e)
+            {
+               log.error("Unable to create tombstone!", e);
+            }
+            nodeSPI = (NodeSPI) cacheData.getRoot().getChild(fqn);
+         }
+         node = nodeSPI;
+      }
+
+      if (isOptimisticLocking)
+         removeData();
+      else
+         super.perform(ctx);
+
+      // mark the node to be removed (and all children) as invalid so anyone holding a direct reference to it will
+      // be aware that it is no longer valid.
+      ((NodeSPI) node).setValid(false, true);
+
+      if (dataVersion != null)
+      {
+         NodeSPI n = cacheData.peek(fqn, false, true);
+         n.setVersion(dataVersion);
+      }
+      return null;
+   }
+
+   private void removeData()
+         throws CacheException
+   {
+      // Find the node. This will lock it (if <tt>locking</tt> is true) and
+      // add the temporarily created parent nodes to the TX's node list if tx != null)
+      NodeSPI n = cacheData.findNode(fqn, dataVersion);
+      if (n == null)
+      {
+         log.warn("node " + fqn + " not found");
+         return;
+      }
+      InvocationContext ctx = spi.getInvocationContext();
+      notifier.notifyNodeEvicted(fqn, true, ctx);
+      n.clearDataDirect();
+      n.setDataLoaded(false);
+
+      // FIXME Bela did this so GUI view can refresh the view after node is evicted. But this breaks eviction policy, especially AOP!!!!
+      notifier.notifyNodeEvicted(fqn, false, ctx);
+   }
+
+   @Override
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleInvalidateCommand(ctx, this);
+   }
+
+   @Override
+   public boolean isVersioned()
+   {
+      // invalidate commands are *always* versioned.
+      return true;
+   }
+
+   @Override
+   protected boolean isVersionedId(int id)
+   {
+      // invalidate commands are *always* versioned.
+      return true;
+   }
+
+   @Override
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "InvalidateCommand{" +
+            "fqn=" + fqn +
+            ", dataVersion=" + dataVersion +
+            '}';
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,168 @@
+package org.jboss.cache.commands.write;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeNotExistsException;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.commands.read.AbstractDataCommand;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.notifications.Notifier;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#move(org.jboss.cache.Fqn, org.jboss.cache.Fqn)}
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class MoveCommand extends AbstractDataCommand implements ReversibleCommand
+{
+   public static final int METHOD_ID = 36;
+
+   /* params */
+   private Fqn to;
+   private Notifier notifier;
+   private GlobalTransaction globalTransaction;
+
+   @Inject
+   public void injectNotifier(Notifier notifier)
+   {
+      this.notifier = notifier;
+   }
+
+   public MoveCommand()
+   {
+   }
+
+   public MoveCommand(Fqn from, Fqn to)
+   {
+      this.fqn = from;
+      this.to = to;
+   }
+
+   public GlobalTransaction getGlobalTransaction()
+   {
+      return globalTransaction;
+   }
+
+   public void setGlobalTransaction(GlobalTransaction globalTransaction)
+   {
+      this.globalTransaction = globalTransaction;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      _move(fqn, to, false, ctx);
+      return null;
+   }
+
+   public void rollback()
+   {
+      _move(Fqn.fromRelativeElements(to, fqn.getLastElement()), fqn.getParent(), true, null);
+   }
+
+
+   private void moveFqns(NodeSPI node, Fqn newBase)
+   {
+      Fqn newFqn = Fqn.fromRelativeElements(newBase, node.getFqn().getLastElement());
+      node.setFqn(newFqn);
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleMoveCommand(ctx, this);
+   }
+
+   public void _move(Fqn nodeToMoveFqn, Fqn newParentFqn, boolean skipNotifications, InvocationContext ctx)
+   {
+      // the actual move algorithm.
+      NodeSPI newParent = cacheData.findNode(newParentFqn);
+
+      if (newParent == null)
+      {
+         throw new NodeNotExistsException("New parent node " + newParentFqn + " does not exist when attempting to move node!!");
+      }
+
+      NodeSPI node = cacheData.findNode(nodeToMoveFqn);
+
+      if (node == null)
+      {
+         throw new NodeNotExistsException("Node " + nodeToMoveFqn + " does not exist when attempting to move node!!");
+      }
+
+      NodeSPI oldParent = node.getParent();
+      Object nodeName = nodeToMoveFqn.getLastElement();
+
+      // now that we have the parent and target nodes:
+      // first correct the pointers at the pruning point
+      oldParent.removeChildDirect(nodeName);
+      newParent.addChild(nodeName, node);
+      // parent pointer is calculated on the fly using Fqns.
+
+      // notify
+      if (!skipNotifications)
+         notifier.notifyNodeMoved(nodeToMoveFqn, Fqn.fromRelativeElements(newParentFqn, nodeToMoveFqn.getLastElement()), true, ctx);
+
+      // now adjust Fqns of node and all children.
+      moveFqns(node, newParent.getFqn());
+
+      if (!skipNotifications)
+         notifier.notifyNodeMoved(nodeToMoveFqn, Fqn.fromRelativeElements(newParentFqn, nodeToMoveFqn.getLastElement()), false, ctx);
+   }
+
+   public Fqn getTo()
+   {
+      return to;
+   }
+
+   public int getCommandId()
+   {
+      return METHOD_ID;
+   }
+
+   @Override
+   public Object[] getParameters()
+   {
+      return new Object[]{fqn, to};
+   }
+
+   @Override
+   public void setParameters(int commandId, Object[] args)
+   {
+      fqn = (Fqn) args[0];
+      to = (Fqn) args[1];
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      if (!super.equals(o)) return false;
+
+      MoveCommand that = (MoveCommand) o;
+
+      if (to != null ? !to.equals(that.to) : that.to != null) return false;
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + (to != null ? to.hashCode() : 0);
+      return result;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "MoveCommand{" +
+            "fqn=" + fqn +
+            "to=" + to +
+            '}';
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutDataMapCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,191 @@
+package org.jboss.cache.commands.write;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.CacheSPI#put(String, java.util.Map)}
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class PutDataMapCommand extends AbstractVersionedDataCommand
+{
+   public static final int METHOD_ID = 1;
+   public static final int ERASE_METHOD_ID = 2;
+   public static final int VERSIONED_METHOD_ID = 37;
+   public static final int ERASE_VERSIONED_METHOD_ID = 38;
+
+   private static final Log log = LogFactory.getLog(PutDataMapCommand.class);
+   private static boolean trace;
+
+   /* parameters*/
+   private Map data;
+   boolean createUndoOps;
+   private boolean eraseContents;
+   private Map oldData;
+
+   public PutDataMapCommand()
+   {
+      trace = log.isTraceEnabled();
+   }
+
+   public PutDataMapCommand(GlobalTransaction globalTransaction, Fqn fqn, Map data, boolean createUndoOps, boolean eraseContents)
+   {
+      this();
+      this.globalTransaction = globalTransaction;
+      this.fqn = fqn;
+      this.data = data;
+      this.createUndoOps = createUndoOps;
+      this.eraseContents = eraseContents;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      if (trace)
+      {
+         log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", " + data + " undo=" + createUndoOps + " erase=" + eraseContents + ")");
+      }
+      NodeSPI nodeSPI = cacheData.findNodeCheck(globalTransaction, fqn, false);
+      Map dataDirect = nodeSPI.getDataDirect();
+      if (!dataDirect.isEmpty())
+      {
+         oldData = new HashMap(dataDirect); // defensive copy
+      }
+      notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_MAP, oldData == null ? Collections.emptyMap() : oldData, ctx);
+
+      if (eraseContents) nodeSPI.clearDataDirect();
+
+      nodeSPI.putAllDirect(data);
+      notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.PUT_MAP, nodeSPI.getDataDirect(), ctx);
+      return null;
+   }
+
+   public void rollback()
+   {
+      if (trace) log.trace("rollback(" + globalTransaction + ", " + fqn + ", " + data + ")");
+
+      NodeSPI n = cacheData.findNode(fqn, null, true);
+      if (n != null)
+      {
+         n.clearDataDirect();
+         if (oldData != null) n.putAllDirect(oldData);
+      }
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handlePutDataMapCommand(ctx, this);
+   }
+
+   public Map getData()
+   {
+      return data;
+   }
+
+   public boolean isEraseContents()
+   {
+      return eraseContents;
+   }
+
+   public boolean isCreateUndoOps()
+   {
+      return createUndoOps;
+   }
+
+   public void setData(Map data)
+   {
+      this.data = data;
+   }
+
+   public int getCommandId()
+   {
+      if (isVersioned())
+      {
+         return eraseContents ? ERASE_VERSIONED_METHOD_ID : VERSIONED_METHOD_ID;
+      }
+      else
+      {
+         return eraseContents ? ERASE_METHOD_ID : METHOD_ID;
+      }
+   }
+
+   @Override
+   public Object[] getParameters()
+   {
+      if (isVersioned())
+         return new Object[]{globalTransaction, fqn, data, createUndoOps, dataVersion};
+      else
+         return new Object[]{globalTransaction, fqn, data, createUndoOps};
+   }
+
+   @Override
+   public void setParameters(int commandId, Object[] args)
+   {
+      globalTransaction = (GlobalTransaction) args[0];
+      fqn = (Fqn) args[1];
+      data = (Map) args[2];
+      createUndoOps = (Boolean) args[3];
+      eraseContents = commandId == ERASE_METHOD_ID;
+      if (isVersionedId(commandId)) dataVersion = (DataVersion) args[4];
+   }
+
+   @Override
+   protected boolean isVersionedId(int id)
+   {
+      return id == VERSIONED_METHOD_ID || id == ERASE_VERSIONED_METHOD_ID;
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      if (!super.equals(o)) return false;
+
+      PutDataMapCommand that = (PutDataMapCommand) o;
+
+      if (createUndoOps != that.createUndoOps) return false;
+      if (eraseContents != that.eraseContents) return false;
+      if (data != null ? !data.equals(that.data) : that.data != null) return false;
+      if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
+         return false;
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
+      result = 31 * result + (data != null ? data.hashCode() : 0);
+      result = 31 * result + (createUndoOps ? 1 : 0);
+      result = 31 * result + (eraseContents ? 1 : 0);
+      return result;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "PutDataMapCommand{" +
+            "fqn=" + fqn +
+            ", eraseContents=" + eraseContents +
+            ", createUndoOps=" + createUndoOps +
+            ", dataVersion=" + dataVersion +
+            ", data=" + data +
+            ", globalTransaction=" + globalTransaction +
+            '}';
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,211 @@
+package org.jboss.cache.commands.write;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.CacheSPI#put(org.jboss.cache.Fqn, Object, Object)}.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class PutKeyValueCommand extends AbstractVersionedDataCommand
+{
+   public static final int METHOD_ID = 3;
+   public static final int VERSIONED_METHOD_ID = 39;
+   public static final int PUT_FOR_EXT_READ_METHOD_ID = 45;
+   public static final int PUT_FOR_EXT_READ_VERSIONED_METHOD_ID = 46;
+
+   private static final Log log = LogFactory.getLog(PutKeyValueCommand.class);
+   private static boolean trace;
+
+   /* parametres */
+   private Object key;
+   private Object value;
+   private boolean createUndoOps;
+   private boolean isPutForExternalRead;
+   private Object oldValue;
+
+   public PutKeyValueCommand()
+   {
+      trace = log.isTraceEnabled();
+   }
+
+   public PutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps, boolean isPutForExternalRead)
+   {
+      this();
+      this.globalTransaction = gtx;
+      this.fqn = fqn;
+      this.key = key;
+      this.value = value;
+      this.createUndoOps = createUndoOps;
+      this.isPutForExternalRead = isPutForExternalRead;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      if (trace)
+      {
+         log.trace(new StringBuffer("perform(").append(globalTransaction).append(", \"").
+               append(fqn).append("\", k=").append(key).append(", v=").append(value).append(")"));
+      }
+      // if this is a rollback then don't fire notifications.
+      boolean isRollback = false;
+
+      NodeSPI n = cacheData.findNodeCheck(globalTransaction, fqn, isRollback);
+      Map rawData = n.getDataDirect();
+      notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_DATA, rawData, ctx);
+      oldValue = n.putDirect(key, value);
+
+      Map newData = Collections.singletonMap(key, value);
+      notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.PUT_DATA, newData, ctx);
+      return oldValue;
+   }
+
+   public void rollback()
+   {
+      if (this.oldValue == null)
+      {
+         NodeSPI n = cacheData.findNode(fqn);
+         if (n == null) throw new CacheException("node " + fqn + " not found for rollback!");
+         n.removeDirect(key);
+      }
+      else
+      {
+         log.trace("Rolling back, setting the old value : " + oldValue);
+         NodeSPI n = cacheData.findNodeCheck(globalTransaction, fqn, false);
+         n.putDirect(key, oldValue);
+      }
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handlePutKeyValueCommand(ctx, this);
+   }
+
+   public boolean isPutForExternalRead()
+   {
+      return isPutForExternalRead;
+   }
+
+   public Object getKey()
+   {
+      return key;
+   }
+
+   public Object getValue()
+   {
+      return value;
+   }
+
+   public boolean isCreateUndoOps()
+   {
+      return createUndoOps;
+   }
+
+   public void setKey(Object key)
+   {
+      this.key = key;
+   }
+
+   public void setValue(Object value)
+   {
+      this.value = value;
+   }
+
+   public int getCommandId()
+   {
+      if (isVersioned())
+      {
+         return isPutForExternalRead ? PUT_FOR_EXT_READ_VERSIONED_METHOD_ID : VERSIONED_METHOD_ID;
+      }
+      else
+      {
+         return isPutForExternalRead ? PUT_FOR_EXT_READ_METHOD_ID : METHOD_ID;
+      }
+   }
+
+   @Override
+   public Object[] getParameters()
+   {
+      if (isVersioned())
+         return new Object[]{globalTransaction, fqn, key, value, createUndoOps, dataVersion};
+      else
+         return new Object[]{globalTransaction, fqn, key, value, createUndoOps};
+   }
+
+   @Override
+   public void setParameters(int commandId, Object[] args)
+   {
+      globalTransaction = (GlobalTransaction) args[0];
+      fqn = (Fqn) args[1];
+      key = args[2];
+      value = args[3];
+      createUndoOps = (Boolean) args[4];
+      isPutForExternalRead = (commandId == PUT_FOR_EXT_READ_METHOD_ID || commandId == PUT_FOR_EXT_READ_VERSIONED_METHOD_ID);
+      if (isVersionedId(commandId)) dataVersion = (DataVersion) args[5];
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      if (!super.equals(o)) return false;
+
+      PutKeyValueCommand that = (PutKeyValueCommand) o;
+
+      if (createUndoOps != that.createUndoOps) return false;
+      if (isPutForExternalRead != that.isPutForExternalRead) return false;
+      if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
+         return false;
+      if (key != null ? !key.equals(that.key) : that.key != null) return false;
+      if (value != null ? !value.equals(that.value) : that.value != null) return false;
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
+      result = 31 * result + (key != null ? key.hashCode() : 0);
+      result = 31 * result + (value != null ? value.hashCode() : 0);
+      result = 31 * result + (createUndoOps ? 1 : 0);
+      result = 31 * result + (isPutForExternalRead ? 1 : 0);
+      return result;
+   }
+
+   @Override
+   protected boolean isVersionedId(int commandId)
+   {
+      return commandId == PUT_FOR_EXT_READ_VERSIONED_METHOD_ID || commandId == VERSIONED_METHOD_ID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "PutKeyValueCommand{" +
+            "fqn=" + fqn +
+            ", dataVersion=" + dataVersion +
+            ", globalTransaction=" + globalTransaction +
+            ", key=" + key +
+            ", value=" + value +
+            ", createUndoOps=" + createUndoOps +
+            ", isPutForExternalRead=" + isPutForExternalRead +
+            ", oldValue=" + oldValue +
+            '}';
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveDataCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveDataCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveDataCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveDataCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,212 @@
+package org.jboss.cache.commands.write;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#remove(String, Object)}
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class RemoveDataCommand extends AbstractVersionedDataCommand
+{
+   public static final int METHOD_ID = 7;
+   public static final int VERSIONED_METHOD_ID = 42;
+
+   private static final Log log = LogFactory.getLog(RemoveDataCommand.class);
+   private static boolean trace;
+
+   /* parameters*/
+   private boolean createUndoops;
+   private boolean sendNodeEvent;
+   private boolean eviction;
+   private HashMap originalData;
+
+   public RemoveDataCommand()
+   {
+      trace = log.isTraceEnabled();
+   }
+
+   public RemoveDataCommand(GlobalTransaction gtx, Fqn fqn, boolean createUndoops, boolean sendNodeEvent, boolean eviction)
+   {
+      this();
+      this.globalTransaction = gtx;
+      this.fqn = fqn;
+      this.createUndoops = createUndoops;
+      this.sendNodeEvent = sendNodeEvent;
+      this.eviction = eviction;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      if (trace) log.trace("perform(" + globalTransaction + ", \"" + fqn + "\")");
+      NodeSPI targetNode = cacheData.findNode(fqn, dataVersion);
+      if (targetNode == null)
+      {
+         log.warn("node " + fqn + " not found");
+         return null;
+      }
+
+      Map data = targetNode.getDataDirect();
+      prepareDataForRollback(data);
+
+      notifyBefore(data, ctx);
+
+      targetNode.clearDataDirect();
+      if (eviction) targetNode.setDataLoaded(false);
+
+      notifyAfter(data, ctx);
+
+      return null;
+   }
+
+   private void prepareDataForRollback(Map data)
+   {
+      if (globalTransaction != null && createUndoops && !eviction && !data.isEmpty())
+      {
+         originalData = new HashMap(data);
+      }
+   }
+
+   private void notifyAfter(Map data, InvocationContext ctx)
+   {
+      if (sendNodeEvent)
+      {
+         notifier.notifyNodeVisited(fqn, false, ctx);
+      }
+      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, ctx);
+         }
+         else
+         {
+            notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.REMOVE_DATA, data, ctx);
+         }
+      }
+   }
+
+   private void notifyBefore(Map data, InvocationContext ctx)
+   {
+      if (eviction)
+      {
+         notifier.notifyNodeEvicted(fqn, true, ctx);
+      }
+      else
+      {
+         notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.REMOVE_DATA, data, ctx);
+      }
+   }
+
+   public void rollback()
+   {
+      if (trace) log.trace("rollback(" + globalTransaction + ", \"" + fqn + "\", " + originalData + ")");
+      boolean isRollback = true;
+      NodeSPI nodeSPI = cacheData.findNodeCheck(globalTransaction, fqn, isRollback);
+      nodeSPI.putAllDirect(originalData);
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleRemoveDataCommand(ctx, this);
+   }
+
+   public boolean isEviction()
+   {
+      return eviction;
+   }
+
+   public boolean isSendNodeEvent()
+   {
+      return sendNodeEvent;
+   }
+
+   public boolean isCreateUndoops()
+   {
+      return createUndoops;
+   }
+
+   public int getCommandId()
+   {
+      return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
+   }
+
+   @Override
+   public Object[] getParameters()
+   {
+      if (isVersioned())
+         return new Object[]{globalTransaction, fqn, createUndoops, dataVersion};
+      else
+         return new Object[]{globalTransaction, fqn, createUndoops};
+   }
+
+   @Override
+   public void setParameters(int commandId, Object[] args)
+   {
+      globalTransaction = (GlobalTransaction) args[0];
+      fqn = (Fqn) args[1];
+      createUndoops = (Boolean) args[2];
+      if (isVersionedId(commandId)) dataVersion = (DataVersion) args[3];
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      if (!super.equals(o)) return false;
+
+      RemoveDataCommand that = (RemoveDataCommand) o;
+
+      if (createUndoops != that.createUndoops) return false;
+      if (eviction != that.eviction) return false;
+      if (sendNodeEvent != that.sendNodeEvent) return false;
+      if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
+         return false;
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
+      result = 31 * result + (createUndoops ? 1 : 0);
+      result = 31 * result + (sendNodeEvent ? 1 : 0);
+      result = 31 * result + (eviction ? 1 : 0);
+      return result;
+   }
+
+   @Override
+   protected boolean isVersionedId(int id)
+   {
+      return id == VERSIONED_METHOD_ID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "RemoveDataCommand{" +
+            "fqn=" + fqn +
+            ", dataVersion=" + dataVersion +
+            ", globalTransaction=" + globalTransaction +
+            ", createUndoops=" + createUndoops +
+            ", sendNodeEvent=" + sendNodeEvent +
+            ", eviction=" + eviction +
+            ", originalData=" + originalData +
+            '}';
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveKeyCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,163 @@
+package org.jboss.cache.commands.write;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#remove(org.jboss.cache.Fqn, Object)}
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class RemoveKeyCommand extends AbstractVersionedDataCommand
+{
+   public static final int METHOD_ID = 6;
+   public static final int VERSIONED_METHOD_ID = 41;
+
+   private static final Log log = LogFactory.getLog(RemoveKeyCommand.class);
+   private static boolean trace;
+
+   /* parameters */
+   private Object key;
+   private boolean createUndoOps;
+   private Object oldValue;
+
+   public RemoveKeyCommand()
+   {
+      trace = log.isTraceEnabled();
+   }
+
+   public RemoveKeyCommand(GlobalTransaction gtx, Fqn fqn, Object key, boolean createUndoOps)
+   {
+      this();
+      this.globalTransaction = gtx;
+      this.fqn = fqn;
+      this.key = key;
+      this.createUndoOps = createUndoOps;
+   }
+
+   public Object perform(InvocationContext ctx)
+   {
+      if (trace) log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", key=" + key + ")");
+
+      NodeSPI n = cacheData.findNode(fqn);
+      if (n == null)
+      {
+         log.warn("node " + fqn + " not found");
+         return null;
+      }
+      notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.REMOVE_DATA, n.getDataDirect(), ctx);
+
+      this.oldValue = n.removeDirect(key);
+
+      Map removedData = Collections.singletonMap(key, oldValue);
+      notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.REMOVE_DATA, removedData, ctx);
+      return oldValue;
+   }
+
+   public void rollback()
+   {
+      NodeSPI targetNode = cacheData.findNodeCheck(globalTransaction, fqn, true);
+      targetNode.putDirect(key, oldValue);
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleRemoveKeyCommand(ctx, this);
+   }
+
+   public Object getKey()
+   {
+      return key;
+   }
+
+   public boolean isCreateUndoOps()
+   {
+      return createUndoOps;
+   }
+
+   public void setKey(Object key)
+   {
+      this.key = key;
+   }
+
+   public int getCommandId()
+   {
+      return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
+   }
+
+   @Override
+   public Object[] getParameters()
+   {
+      if (isVersioned())
+         return new Object[]{globalTransaction, fqn, key, createUndoOps, dataVersion};
+      else
+         return new Object[]{globalTransaction, fqn, key, createUndoOps};
+   }
+
+   @Override
+   public void setParameters(int commandId, Object[] args)
+   {
+      globalTransaction = (GlobalTransaction) args[0];
+      fqn = (Fqn) args[1];
+      key = args[2];
+      createUndoOps = (Boolean) args[3];
+      if (isVersionedId(commandId)) dataVersion = (DataVersion) args[4];
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      if (!super.equals(o)) return false;
+
+      RemoveKeyCommand that = (RemoveKeyCommand) o;
+
+      if (createUndoOps != that.createUndoOps) return false;
+      if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
+         return false;
+      if (key != null ? !key.equals(that.key) : that.key != null) return false;
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
+      result = 31 * result + (key != null ? key.hashCode() : 0);
+      result = 31 * result + (createUndoOps ? 1 : 0);
+      return result;
+   }
+
+   @Override
+   protected boolean isVersionedId(int id)
+   {
+      return id == VERSIONED_METHOD_ID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "RemoveKeyCommand{" +
+            "fqn=" + fqn +
+            ", dataVersion=" + dataVersion +
+            ", globalTransaction=" + globalTransaction +
+            ", key=" + key +
+            ", createUndoOps=" + createUndoOps +
+            ", oldValue=" + oldValue +
+            '}';
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java (from rev 5697, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveNodeCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -0,0 +1,271 @@
+package org.jboss.cache.commands.write;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.CacheSPI#removeNode(org.jboss.cache.Fqn)}
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public class RemoveNodeCommand extends AbstractVersionedDataCommand
+{
+   public static final int METHOD_ID = 5;
+   public static final int VERSIONED_METHOD_ID = 40;
+   private static final Log log = LogFactory.getLog(RemoveNodeCommand.class);
+   private static boolean trace;
+
+   private boolean isOptimistic;
+
+   /*parameters*/
+   private boolean createUndoOps;
+   private boolean skipSendingNodeEvents;
+   private boolean eviction;
+   private Fqn parentFqn;
+   private NodeSPI targetNode;
+   private Map originalData;
+
+   public RemoveNodeCommand()
+   {
+      trace = log.isTraceEnabled();
+   }
+
+   public RemoveNodeCommand(GlobalTransaction globalTransaction, Fqn fqn, boolean createUndoOps, boolean skipSendingNodeEvents, boolean eviction)
+   {
+      this();
+      this.globalTransaction = globalTransaction;
+      this.fqn = fqn;
+      this.createUndoOps = createUndoOps;
+      this.skipSendingNodeEvents = skipSendingNodeEvents;
+      this.eviction = eviction;
+   }
+
+   @Inject
+   public void initialize(Configuration configuration)
+   {
+      this.isOptimistic = configuration.isNodeLockingOptimistic();
+   }
+
+   //todo - why is this method using optimisticLocking param, as it NEVER gets called in an optimistic cache as it is intercepted
+   public Object perform(InvocationContext ctx)
+   {
+      NodeSPI parentNode;
+      if (trace)
+         log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", undo=" + createUndoOps + ")");
+
+      // Find the node. This will add the temporarily created parent nodes to the TX's node list if globalTransaction != null)
+      targetNode = cacheData.findNode(fqn, dataVersion, true);
+      if (targetNode == null)
+      {
+         if (trace) log.trace("node " + fqn + " not found");
+         return false;
+      }
+
+      notifyBeforeEviction(targetNode, ctx);
+
+      parentNode = targetNode.getParent();
+      boolean found;
+
+      // remove subtree from parent
+      if (eviction || isOptimistic)
+      {
+         // if there is no parent node and the fqn is root, found == true otherwise found == false.
+         found = targetNode.isValid() && parentNode == null ? fqn.isRoot() : parentNode.removeChildDirect(targetNode.getFqn().getLastElement());
+      }
+      else
+      {
+         found = targetNode.isValid() && !targetNode.isDeleted();
+         targetNode.markAsDeleted(true, true);
+      }
+
+      if (eviction && parentNode != null)
+      {
+         parentNode.setChildrenLoaded(false);
+      }
+
+      // create a compensating method call (reverting the effect of
+      // this modification) and put it into the TX's undo list.
+      if (globalTransaction != null && createUndoOps && !eviction && found)
+      {
+         parentFqn = parentNode.getFqn();
+         Map targetData = targetNode.getDataDirect();
+         if (!targetData.isEmpty())
+         {
+            originalData = new HashMap(targetNode.getDataDirect());
+         }
+      }
+
+      notifyAfterEviction(ctx);
+      return found;
+   }
+
+   private void notifyAfterEviction(InvocationContext ctx)
+   {
+      if (!skipSendingNodeEvents)
+      {
+         if (eviction)
+         {
+            notifier.notifyNodeEvicted(fqn, false, ctx);
+         }
+         else
+         {
+            notifier.notifyNodeRemoved(fqn, false, null, ctx);
+         }
+      }
+   }
+
+   private void notifyBeforeEviction(NodeSPI n, InvocationContext ctx)
+   {
+      if (!skipSendingNodeEvents)
+      {
+         if (eviction)
+         {
+            notifier.notifyNodeEvicted(fqn, true, ctx);
+         }
+         else
+         {
+            notifier.notifyNodeRemoved(fqn, true, n.getDataDirect(), ctx);
+         }
+      }
+   }
+
+   public void rollback()
+   {
+      if (targetNode != null)
+      {
+         Object childName = targetNode.getFqn().getLastElement();
+         if (trace)
+         {
+            log.trace("rollback(parent: " + parentFqn + ", child: " + childName + ", node=" + targetNode + ")");
+         }
+
+         if (parentFqn == null || childName == null)
+         {
+            log.error("parent fqn or childName or childNode was null");
+            return;
+         }
+         NodeSPI parentNode = cacheData.findNode(parentFqn);
+         if (parentNode == null)
+         {
+            log.warn("node " + parentFqn + " not found");
+            return;
+         }
+         parentNode.addChild(childName, targetNode);
+         targetNode.markAsDeleted(false, true);
+         targetNode.clearDataDirect();
+         if (originalData != null) targetNode.putAllDirect(originalData);
+         targetNode.setValid(true, true);
+      }
+   }
+
+   public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+   {
+      return visitor.handleRemoveNodeCommand(ctx, this);
+   }
+
+   public boolean isSkipSendingNodeEvents()
+   {
+      return skipSendingNodeEvents;
+   }
+
+   public boolean isCreateUndoOps()
+   {
+      return createUndoOps;
+   }
+
+   public boolean isEviction()
+   {
+      return eviction;
+   }
+
+   public int getCommandId()
+   {
+      return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
+   }
+
+   @Override
+   public Object[] getParameters()
+   {
+      if (isVersioned())
+         return new Object[]{globalTransaction, fqn, createUndoOps, skipSendingNodeEvents, dataVersion};
+      else
+         return new Object[]{globalTransaction, fqn, createUndoOps, skipSendingNodeEvents};
+   }
+
+   @Override
+   public void setParameters(int commandId, Object[] args)
+   {
+      globalTransaction = (GlobalTransaction) args[0];
+      fqn = (Fqn) args[1];
+      createUndoOps = (Boolean) args[2];
+      skipSendingNodeEvents = (Boolean) args[3];
+      if (isVersionedId(commandId)) dataVersion = (DataVersion) args[4];
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      if (!super.equals(o)) return false;
+
+      RemoveNodeCommand that = (RemoveNodeCommand) o;
+
+      if (createUndoOps != that.createUndoOps) return false;
+      if (eviction != that.eviction) return false;
+      if (skipSendingNodeEvents != that.skipSendingNodeEvents) return false;
+      if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
+         return false;
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
+      result = 31 * result + (createUndoOps ? 1 : 0);
+      result = 31 * result + (skipSendingNodeEvents ? 1 : 0);
+      result = 31 * result + (eviction ? 1 : 0);
+      return result;
+   }
+
+   @Override
+   protected boolean isVersionedId(int id)
+   {
+      return id == VERSIONED_METHOD_ID;
+   }
+
+   public void setSkipSendingNodeEvents(boolean skipSendingNodeEvents)
+   {
+      this.skipSendingNodeEvents = skipSendingNodeEvents;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "RemoveNodeCommand{" +
+            "fqn=" + fqn +
+            ", dataVersion=" + dataVersion +
+            ", globalTransaction=" + globalTransaction +
+            ", createUndoOps=" + createUndoOps +
+            ", skipSendingNodeEvents=" + skipSendingNodeEvents +
+            ", eviction=" + eviction +
+            ", parentFqn=" + parentFqn +
+            ", targetNode=" + targetNode +
+            '}';
+   }
+}

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -4,18 +4,18 @@
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.Modification;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
-import org.jboss.cache.commands.cachedata.GetKeysCommand;
-import org.jboss.cache.commands.cachedata.GetNodeCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.RemoveDataCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
+import org.jboss.cache.commands.AbstractVisitor;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.visitors.AbstractCommandsVisitor;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.invocation.CacheData;
 import org.jboss.cache.loader.CacheLoader;
@@ -266,7 +266,7 @@
       }
    }
 
-   public static class ActivationModificationsBuilder extends AbstractCommandsVisitor
+   public static class ActivationModificationsBuilder extends AbstractVisitor
    {
 
       private List<Modification> cacheLoaderModifications = new ArrayList<Modification>();

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -7,9 +7,9 @@
 import org.jboss.cache.RPCManager;
 import org.jboss.cache.buddyreplication.BuddyManager;
 import org.jboss.cache.cluster.ReplicationQueue;
-import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Configuration.CacheMode;
 import org.jboss.cache.config.Option;
@@ -21,7 +21,6 @@
 import org.jgroups.Address;
 
 import javax.transaction.Transaction;
-import java.io.NotSerializableException;
 import java.util.List;
 
 /**
@@ -79,17 +78,17 @@
       }
    }
 
-   protected void replicateCall(InvocationContext ctx, CacheCommand call, boolean sync, Option o, boolean useOutOfBandMessage) throws Throwable
+   protected void replicateCall(InvocationContext ctx, ReplicableCommand call, boolean sync, Option o, boolean useOutOfBandMessage) throws Throwable
    {
       replicateCall(ctx, null, call, sync, o, useOutOfBandMessage);
    }
 
-   protected void replicateCall(InvocationContext ctx, CacheCommand call, boolean sync, Option o) throws Throwable
+   protected void replicateCall(InvocationContext ctx, ReplicableCommand call, boolean sync, Option o) throws Throwable
    {
       replicateCall(ctx, null, call, sync, o, false);
    }
 
-   protected void replicateCall(InvocationContext ctx, List<Address> recipients, CacheCommand c, boolean sync, Option o, boolean useOutOfBandMessage) throws Throwable
+   protected void replicateCall(InvocationContext ctx, List<Address> recipients, ReplicableCommand c, boolean sync, Option o, boolean useOutOfBandMessage) throws Throwable
    {
       long syncReplTimeout = config.getSyncReplTimeout();
 
@@ -118,48 +117,39 @@
       replicateCall(recipients, c, sync, true, useOutOfBandMessage, false, (int) syncReplTimeout);
    }
 
-   protected void replicateCall(List<Address> recipients, CacheCommand c, boolean sync, boolean wrapCacheCommandInReplicateMethod, boolean useOutOfBandMessage, boolean isBroadcast, int timeout) throws Throwable
+   protected void replicateCall(List<Address> recipients, ReplicableCommand call, boolean sync, boolean wrapCacheCommandInReplicateMethod, boolean useOutOfBandMessage, boolean isBroadcast, int timeout) throws Throwable
    {
-      if (c instanceof MarshallableCommand)
+      if (trace) log.trace("Broadcasting call " + call + " to recipient list " + recipients);
+
+      if (!sync && replicationQueue != null && !usingBuddyReplication)
       {
-         MarshallableCommand call = (MarshallableCommand) c;
-         if (trace) log.trace("Broadcasting call " + call + " to recipient list " + recipients);
+         if (log.isDebugEnabled()) log.debug("Putting call " + call + " on the replication queue.");
+         replicationQueue.add(commandsFactory.buildReplicateCommand(call));
+      }
+      else
+      {
+         if (usingBuddyReplication && !isBroadcast) call = buddyManager.transformFqns((VisitableCommand) call);
 
-         if (!sync && replicationQueue != null && !usingBuddyReplication)
+         List<Address> callRecipients = recipients;
+         if (callRecipients == null)
          {
-            if (log.isDebugEnabled()) log.debug("Putting call " + call + " on the replication queue.");
-            replicationQueue.add(commandsFactory.buildReplicateCommand(call));
+            callRecipients = usingBuddyReplication && !isBroadcast ? buddyManager.getBuddyAddresses() : rpcManager.getMembers();
+            if (trace)
+               log.trace("Setting call recipients to " + callRecipients + " since the original list of recipients passed in is null.");
          }
-         else
-         {
-            if (usingBuddyReplication && !isBroadcast) call = buddyManager.transformFqns(call);
 
-            List<Address> callRecipients = recipients;
-            if (callRecipients == null)
-            {
-               callRecipients = usingBuddyReplication && !isBroadcast ? buddyManager.getBuddyAddresses() : rpcManager.getMembers();
-               if (trace)
-                  log.trace("Setting call recipients to " + callRecipients + " since the original list of recipients passed in is null.");
-            }
+         ReplicableCommand toCall = wrapCacheCommandInReplicateMethod ? commandsFactory.buildReplicateCommand(call) : call;
 
-            CacheCommand toCall = wrapCacheCommandInReplicateMethod ? commandsFactory.buildReplicateCommand(call) : call;
-
-            List rsps = rpcManager.callRemoteMethods(callRecipients,
-                  toCall,
-                  sync, // is synchronised?
-                  true, // ignore self?
-                  timeout,
-                  useOutOfBandMessage
-            );
-            if (trace) log.trace("responses=" + rsps);
-            if (sync) checkResponses(rsps);
-         }
+         List rsps = rpcManager.callRemoteMethods(callRecipients,
+               toCall,
+               sync, // is synchronised?
+               true, // ignore self?
+               timeout,
+               useOutOfBandMessage
+         );
+         if (trace) log.trace("responses=" + rsps);
+         if (sync) checkResponses(rsps);
       }
-      else
-      {
-         throw new NotSerializableException("The command is of type " + c.getClass().getName() + ", and is not an instance of " + MarshallableCommand.class.getName());
-      }
-
    }
 
    /**

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -4,8 +4,18 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.cachedata.*;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Configuration;
 import static org.jboss.cache.config.Configuration.CacheMode;
 import org.jboss.cache.factories.annotations.Inject;

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -22,10 +22,10 @@
 package org.jboss.cache.interceptors;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.cachedata.EvictNodeCommand;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.interceptors.base.ChainedInterceptor;
 import org.jboss.cache.invocation.CacheData;

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -5,18 +5,18 @@
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.Modification;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.cachedata.MoveCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.RemoveDataCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
-import org.jboss.cache.commands.functional.TxCacheCommand;
+import org.jboss.cache.commands.AbstractVisitor;
+import org.jboss.cache.commands.ReversibleCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.visitors.AbstractCommandsVisitor;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.annotations.Inject;
@@ -214,9 +214,6 @@
       return invokeNextInterceptor(ctx, command);
    }
 
-   /**
-    * @see #handleRemoveFqnCommand(org.jboss.cache.InvocationContext, org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, boolean)
-    */
    @Override
    public Object executeRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
    {
@@ -229,9 +226,6 @@
       return invokeNextInterceptor(ctx, command);
    }
 
-   /**
-    * @see #handleRemoveFqnCommand(org.jboss.cache.InvocationContext, org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, boolean)
-    */
    @Override
    public Object executeRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
    {
@@ -370,7 +364,7 @@
       {
          throw new Exception("entry for transaction " + gtx + " not found in transaction table");
       }
-      List<TxCacheCommand> modifications = entry.getCacheLoaderModifications();
+      List<ReversibleCommand> modifications = entry.getCacheLoaderModifications();
       if (modifications.size() == 0)
       {
          if (trace) log.trace("Transaction has not logged any modifications!");
@@ -379,9 +373,9 @@
       if (trace) log.trace("Cache loader modification list: " + modifications);
       boolean statsEnabled = configuration.getExposeManagementStatistics() && getStatisticsEnabled();
       StoreModificationsBuilder modsBuilder = new StoreModificationsBuilder(statsEnabled);
-      for (TxCacheCommand cacheCommand : modifications)
+      for (ReversibleCommand cacheCommand : modifications)
       {
-         cacheCommand.accept(null, modsBuilder);
+         cacheCommand.acceptVisitor(null, modsBuilder);
       }
       if (trace)
       {
@@ -399,7 +393,7 @@
       }
    }
 
-   public static class StoreModificationsBuilder extends AbstractCommandsVisitor
+   public static class StoreModificationsBuilder extends AbstractVisitor
    {
       boolean generateStatistics;
       int putCount;

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,18 +1,19 @@
 package org.jboss.cache.interceptors;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.MoveCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.RemoveDataCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
-import org.jboss.cache.commands.functional.TxCacheCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.factories.annotations.Inject;
@@ -87,13 +88,13 @@
    }
 
    @Override
-   public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+   public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
       if (trace) log.trace("Executing command: " + command.getClass().getSimpleName() + ".");
       return invokeCommand(ctx, command);
    }
 
-   private Object invokeCommand(InvocationContext ctx, CacheCommand command)
+   private Object invokeCommand(InvocationContext ctx, ReplicableCommand command)
          throws Throwable
    {
       Object retval;
@@ -155,7 +156,7 @@
     * in case a method has been invoked that the OptimisticNodeInterceptor knows nothing about, it will
     * filter down here.
     */
-   private Object handleAlterCacheMethod(InvocationContext ctx, TxCacheCommand command)
+   private Object handleAlterCacheMethod(InvocationContext ctx, ReversibleCommand command)
          throws Throwable
    {
       Object result = invokeCommand(ctx, command);

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -13,17 +13,17 @@
 import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
 import org.jboss.cache.buddyreplication.BuddyManager;
 import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.CacheDataCommand;
-import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
-import org.jboss.cache.commands.cachedata.GetDataMapCommand;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
-import org.jboss.cache.commands.cachedata.GetKeysCommand;
-import org.jboss.cache.commands.cachedata.GetNodeCommand;
+import org.jboss.cache.commands.DataCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
-import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
 import org.jboss.cache.config.Configuration;
@@ -72,7 +72,7 @@
     * Map that contains commands that need cleaning up.  This is keyed on global transaction, and contains a list of
     * cleanup commands corresponding to all gravitate calls made during the course of the transaction in question.
     */
-   private Map<GlobalTransaction, List<CacheCommand>> cleanupCommands = new ConcurrentHashMap<GlobalTransaction, List<CacheCommand>>();
+   private Map<GlobalTransaction, List<ReplicableCommand>> cleanupCommands = new ConcurrentHashMap<GlobalTransaction, List<ReplicableCommand>>();
    private CacheData cacheData;
    private Configuration config;
    private CommandsFactory commandsFactory;
@@ -158,7 +158,7 @@
       }
    }
 
-   private Object handleGetMethod(InvocationContext ctx, CacheDataCommand command) throws Throwable
+   private Object handleGetMethod(InvocationContext ctx, DataCommand command) throws Throwable
    {
       if (isGravitationEnabled(ctx))
       {
@@ -229,7 +229,7 @@
       {
          if (trace) log.trace("Broadcasting cleanup commands for gtx " + gtx);
 
-         for (CacheCommand command : cleanupCommands.get(gtx))
+         for (ReplicableCommand command : cleanupCommands.get(gtx))
          {
             try
             {
@@ -281,14 +281,14 @@
       {
          if (trace)
             log.trace("Data gravitation performed under global transaction " + gtx + ".  Not broadcasting cleanups until the tx commits.  Recording cleanup command for later use.");
-         List<CacheCommand> commands;
+         List<ReplicableCommand> commands;
          if (cleanupCommands.containsKey(gtx))
          {
             commands = cleanupCommands.get(gtx);
          }
          else
          {
-            commands = new LinkedList<CacheCommand>();
+            commands = new LinkedList<ReplicableCommand>();
          }
 
          commands.add(cleanupCommand);
@@ -296,7 +296,7 @@
       }
    }
 
-   private void doCleanup(CacheCommand cleanupCommand) throws Throwable
+   private void doCleanup(ReplicableCommand cleanupCommand) throws Throwable
    {
       // cleanup commands are always ASYNCHRONOUS and is broadcast to *everyone* (even members of the current buddy
       // group as they may be members of > 1 buddy group)

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -12,15 +12,15 @@
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.Region;
 import org.jboss.cache.RegionManager;
-import org.jboss.cache.commands.cachedata.EvictNodeCommand;
-import org.jboss.cache.commands.cachedata.GetDataMapCommand;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
-import org.jboss.cache.commands.cachedata.GetNodeCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.RemoveDataCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.eviction.EvictedEventNode;
 import org.jboss.cache.eviction.NodeEventType;
 import org.jboss.cache.factories.annotations.Inject;

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -26,7 +26,7 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.factories.annotations.Start;
@@ -145,7 +145,8 @@
    }
 
    @Override
-   public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+   @SuppressWarnings("deprecation")
+   public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
       if (command != null) //call originated from a command's accept() method.
       {
@@ -153,7 +154,7 @@
       }
 
       //this means that another Interceptor called this method, we have to dispatch the call to the appropriate method.  Probably called directly using super.invoke().
-      command = ctx.getExecutingCommand();
-      return command.accept(ctx, getNext());
+      command = ctx.getCommand();
+      return command.acceptVisitor(ctx, getNext());
    }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -11,22 +11,21 @@
 import org.jboss.cache.RPCManager;
 import org.jboss.cache.buddyreplication.BuddyManager;
 import org.jboss.cache.cluster.ReplicationQueue;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.AbstractVisitor;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.InvalidateCommand;
-import org.jboss.cache.commands.cachedata.MoveCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.RemoveDataCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
-import org.jboss.cache.commands.functional.TxCacheCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.visitors.AbstractCommandsVisitor;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.factories.annotations.Inject;
@@ -66,7 +65,7 @@
 {
    private long invalidations = 0;
    protected TransactionTable txTable;
-   protected Map<GlobalTransaction, List<TxCacheCommand>> txMods;
+   protected Map<GlobalTransaction, List<ReversibleCommand>> txMods;
    protected boolean optimistic;
    private CommandsFactory commandsFactory;
 
@@ -77,7 +76,7 @@
    {
       super.injectComponents(rpcManager, buddyManager, replicationQueue, config, txTable, commandsFactory);
       optimistic = config.isNodeLockingOptimistic();
-      if (optimistic) txMods = new ConcurrentHashMap<GlobalTransaction, List<TxCacheCommand>>();
+      if (optimistic) txMods = new ConcurrentHashMap<GlobalTransaction, List<ReversibleCommand>>();
       this.commandsFactory = commandsFactory;
    }
 
@@ -103,44 +102,38 @@
    @Override
    public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
    {
-      return handleCrudMethod(ctx, command.getFqn(), null, command);
+      return handleWriteMethod(ctx, command.getFqn(), null, command);
    }
 
    @Override
    public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
    {
       if (command.isPutForExternalRead()) return invokeNextInterceptor(ctx, command);
-      return handleCrudMethod(ctx, command.getFqn(), null, command);
+      return handleWriteMethod(ctx, command.getFqn(), null, command);
    }
 
    @Override
    public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
    {
-      return handleCrudMethod(ctx, command.getFqn(), null, command);
+      return handleWriteMethod(ctx, command.getFqn(), null, command);
    }
 
    @Override
    public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
    {
-      return handleCrudMethod(ctx, command.getFqn(), null, command);
+      return handleWriteMethod(ctx, command.getFqn(), null, command);
    }
 
    @Override
-   public Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
-   {
-      return handleCrudMethod(ctx, command.getFqn(), null, command);
-   }
-
-   @Override
    public Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
    {
-      return handleCrudMethod(ctx, command.getTo(), command.getFqn(), command);
+      return handleWriteMethod(ctx, command.getTo(), command.getFqn(), command);
    }
 
    @Override
    public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
    {
-      return handleCrudMethod(ctx, command.getFqn(), null, command);
+      return handleWriteMethod(ctx, command.getFqn(), null, command);
    }
 
    @Override
@@ -155,7 +148,7 @@
          GlobalTransaction gtx = ctx.getGlobalTransaction();
          TransactionEntry entry = txTable.get(gtx);
          if (entry == null) throw new IllegalStateException("cannot find transaction entry for " + gtx);
-         List<TxCacheCommand> modifications = new LinkedList<TxCacheCommand>(entry.getModifications());
+         List<ReversibleCommand> modifications = new LinkedList<ReversibleCommand>(entry.getModifications());
          if (modifications.size() > 0)
          {
             broadcastInvalidate(modifications, gtx, tx, ctx);
@@ -179,7 +172,7 @@
          GlobalTransaction gtx = ctx.getGlobalTransaction();
          TransactionEntry entry = txTable.get(gtx);
          if (entry == null) throw new IllegalStateException("cannot find transaction entry for " + gtx);
-         List<TxCacheCommand> modifications = new LinkedList<TxCacheCommand>(entry.getModifications());
+         List<ReversibleCommand> modifications = new LinkedList<ReversibleCommand>(entry.getModifications());
          if (modifications.size() > 0)
          {
             txMods.put(gtx, modifications);
@@ -196,7 +189,7 @@
       if (tx != null && optimistic)
       {
          GlobalTransaction gtx = ctx.getGlobalTransaction();
-         List<TxCacheCommand> modifications = txMods.remove(gtx);
+         List<ReversibleCommand> modifications = txMods.remove(gtx);
          broadcastInvalidate(modifications, gtx, tx, ctx);
          log.debug("Committing.  Broadcasting invalidations.");
       }
@@ -221,7 +214,7 @@
     * @param from    is only present for move operations, else pass it in as null
     * @param command
     */
-   private Object handleCrudMethod(InvocationContext ctx, Fqn targetFqn, Fqn from, CacheCommand command)
+   private Object handleWriteMethod(InvocationContext ctx, Fqn targetFqn, Fqn from, VisitableCommand command)
          throws Throwable
    {
       Object retval = invokeNextInterceptor(ctx, command);
@@ -247,7 +240,7 @@
       return retval;
    }
 
-   private void broadcastInvalidate(List<TxCacheCommand> modifications, GlobalTransaction gtx, Transaction tx, InvocationContext ctx) throws Throwable
+   private void broadcastInvalidate(List<ReversibleCommand> modifications, GlobalTransaction gtx, Transaction tx, InvocationContext ctx) throws Throwable
    {
       if (!skipInvalidation(ctx))
       {
@@ -286,7 +279,7 @@
       }
    }
 
-   public class InvalidationFilterVisitor extends AbstractCommandsVisitor
+   public class InvalidationFilterVisitor extends AbstractVisitor
    {
       Set<Fqn> result;
       public boolean containsPutForExternalRead;
@@ -333,12 +326,6 @@
       }
 
       @Override
-      public Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
-      {
-         return addFqn(command.getFqn());
-      }
-
-      @Override
       public Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
       {
          if (containsPutForExternalRead) return null;

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -8,17 +8,16 @@
 
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.RPCManager;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.RemoveDataCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.invocation.CacheTransactionHelper;
@@ -100,19 +99,13 @@
    }
 
    @Override
-   public Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
+   public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
-      return handleAll(ctx, command, command.getGlobalTransaction());
-   }
-
-   @Override
-   public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
-   {
       return handleAll(ctx, command, null);
    }
 
    @SuppressWarnings("deprecation")
-   public Object handleAll(InvocationContext ctx, CacheCommand command, GlobalTransaction gtx) throws Throwable
+   public Object handleAll(InvocationContext ctx, VisitableCommand command, GlobalTransaction gtx) throws Throwable
    {
       Option optionOverride = ctx.getOptionOverrides();
       boolean suppressExceptions = false;
@@ -189,7 +182,7 @@
          }
 
          // reset the context to prevent leakage of internals
-         ctx.setExecutingCommand(null);
+         ctx.setCommand(null);
          ctx.setMethodCall(null);
       }
    }

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,16 +1,16 @@
 package org.jboss.cache.interceptors;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
-import org.jboss.cache.commands.cachedata.GetDataMapCommand;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
-import org.jboss.cache.commands.cachedata.GetKeysCommand;
-import org.jboss.cache.commands.cachedata.GetNodeCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.RemoveDataCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
 import org.jboss.cache.interceptors.base.ChainedInterceptor;
 import org.jboss.cache.marshall.MarshalledValue;
 import org.jboss.cache.marshall.MarshalledValueHelper;
@@ -135,7 +135,7 @@
       return compactAndProcessRetVal(command, marshalledValues, retVal);
    }
 
-   private Object compactAndProcessRetVal(CacheCommand command, Set<MarshalledValue> marshalledValues, Object retVal)
+   private Object compactAndProcessRetVal(ReplicableCommand command, Set<MarshalledValue> marshalledValues, Object retVal)
          throws IOException, ClassNotFoundException
    {
       if (trace) log.trace("Compacting MarshalledValues created");

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -2,8 +2,6 @@
 
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.channel.BlockChannelCommand;
-import org.jboss.cache.commands.channel.UnblockChannelCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
 import org.jboss.cache.factories.annotations.Inject;
@@ -28,24 +26,6 @@
    }
 
    @Override
-   public Object handleBlockChannelCommand(InvocationContext ctx, BlockChannelCommand command) throws Throwable
-   {
-      notifier.notifyCacheBlocked(cacheSPI, true);
-      Object retVal = invokeNextInterceptor(ctx, command);
-      notifier.notifyCacheBlocked(cacheSPI, false);
-      return retVal;
-   }
-
-   @Override
-   public Object handleUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand command) throws Throwable
-   {
-      notifier.notifyCacheUnblocked(cacheSPI, true);
-      Object retval = invokeNextInterceptor(ctx, command);
-      notifier.notifyCacheUnblocked(cacheSPI, false);
-      return retval;
-   }
-
-   @Override
    public Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
    {
       Object retval = invokeNextInterceptor(ctx, command);

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -12,9 +12,9 @@
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeFactory;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.cachedata.MoveCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.invocation.CacheData;
 import org.jboss.cache.notifications.Notifier;

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -7,15 +7,14 @@
 package org.jboss.cache.interceptors;
 
 import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
+import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.annotations.Inject;
 import static org.jboss.cache.lock.NodeLock.LockType.READ;
 import static org.jboss.cache.lock.NodeLock.LockType.WRITE;
 import org.jboss.cache.optimistic.TransactionWorkspace;
@@ -113,7 +112,7 @@
       return transactionFinalized(ctx, command);
    }
 
-   private Object transactionFinalized(InvocationContext ctx, CacheCommand command) throws Throwable
+   private Object transactionFinalized(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
       Object retval = null;
       // we need to let the stack run its commits or rollbacks first -

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -13,9 +13,18 @@
 import org.jboss.cache.NodeFactory;
 import org.jboss.cache.NodeNotExistsException;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.functional.TxCacheCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.factories.annotations.Inject;
@@ -70,21 +79,6 @@
    }
 
    @Override
-   public Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
-   {
-      GlobalTransaction gtx = getGlobalTransaction(ctx);
-      TransactionWorkspace workspace = getTransactionWorkspace(gtx);
-      WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getBackup(), workspace, true, true);
-      if (workspaceNode != null)
-      {
-         setVersioning(ctx, workspace, workspaceNode);
-      }
-      Object result = invokeNextInterceptor(ctx, command);
-      addToModificationList(gtx, command, ctx);
-      return result;
-   }
-
-   @Override
    public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
    {
       GlobalTransaction gtx = getGlobalTransaction(ctx);
@@ -349,7 +343,7 @@
     *
     * @param gtx transaction
     */
-   private void addToModificationList(GlobalTransaction gtx, TxCacheCommand command, InvocationContext ctx)
+   private void addToModificationList(GlobalTransaction gtx, ReversibleCommand command, InvocationContext ctx)
    {
       Option opt = ctx.getOptionOverrides();
       if (opt == null || !opt.isCacheModeLocal())

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -9,23 +9,24 @@
 import org.jboss.cache.CacheException;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.AbstractVisitor;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.CreateNodeCommand;
-import org.jboss.cache.commands.cachedata.EvictNodeCommand;
-import org.jboss.cache.commands.cachedata.MoveCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.RemoveDataCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
-import org.jboss.cache.commands.state.DataVersionCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.VersionedDataCommand;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.visitors.AbstractCommandsVisitor;
+import org.jboss.cache.commands.write.CreateNodeCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.factories.annotations.Inject;
@@ -203,13 +204,13 @@
          // See JBCACHE-843 and docs/design/DataVersioning.txt
          //todo make the interceptor a field
          DataVersionPopulator populator = new DataVersionPopulator(getTransactionWorkspace(gtx));
-         List<CacheCommand> clonedModifications = new ArrayList<CacheCommand>(command.getModifications().size());
-         for (CacheCommand command1 : command.getModifications())
+         List<ReversibleCommand> clonedModifications = new ArrayList<ReversibleCommand>(command.getModifications().size());
+         for (ReversibleCommand command1 : command.getModifications())
          {
-            CacheCommand clone = (CacheCommand) command1.accept(null, populator);
+            ReversibleCommand clone = (ReversibleCommand) command1.acceptVisitor(null, populator);
             clonedModifications.add(clone);
          }
-         CacheCommand toBroadcast = commandsFactory.buildOptimisticPrepareCommand(gtx, clonedModifications, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
+         ReplicableCommand toBroadcast = commandsFactory.buildOptimisticPrepareCommand(gtx, clonedModifications, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
 
          //record the things we have possibly sent
          broadcastTxs.add(gtx);
@@ -280,7 +281,7 @@
       }
    }
 
-   public class DataVersionPopulator extends AbstractCommandsVisitor
+   public class DataVersionPopulator extends AbstractVisitor
    {
       final TransactionWorkspace workspace;
 
@@ -290,12 +291,6 @@
       }
 
       @Override
-      public Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
-      {
-         return command;
-      }
-
-      @Override
       public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
       {
          return command;
@@ -308,7 +303,7 @@
          return setDataVersion(clone, command.getFqn());
       }
 
-      private Object setDataVersion(DataVersionCommand clone, Fqn fqn)
+      private Object setDataVersion(VersionedDataCommand clone, Fqn fqn)
       {
          DataVersion versionToBroadcast = getVersionToBroadcast(workspace, fqn);
          clone.setDataVersion(versionToBroadcast);
@@ -365,7 +360,7 @@
       }
 
       @Override
-      public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+      public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
       {
          throw new CacheException("Not handling " + command + "!");
       }

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -3,7 +3,7 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.cachedata.EvictNodeCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.interceptors.base.ChainedInterceptor;

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -9,10 +9,21 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.cachedata.*;
+import org.jboss.cache.commands.DataCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.interceptors.base.PostProcessingChainedInterceptor;
@@ -74,7 +85,7 @@
       return handlePutCommand(ctx, command, command.isPutForExternalRead());
    }
 
-   private Object handlePutCommand(InvocationContext ctx, CacheDataCommand command, boolean zeroAcquisitionTimeout)
+   private Object handlePutCommand(InvocationContext ctx, DataCommand command, boolean zeroAcquisitionTimeout)
          throws Throwable
    {
       if ((ctx.isLockingSuppressed()) || configuration.getIsolationLevel() == IsolationLevel.NONE)

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,17 +1,16 @@
 package org.jboss.cache.interceptors;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.MoveCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.RemoveDataCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.factories.annotations.Inject;
@@ -99,12 +98,6 @@
    }
 
    @Override
-   public Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
-   {
-      return handleCrudMethod(ctx, command, false);
-   }
-
-   @Override
    public Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
    {
       return handleCrudMethod(ctx, command, false);
@@ -132,7 +125,7 @@
     * If we are within one transaction we won't do any replication as replication would only be performed at commit time.
     * If the operation didn't originate locally we won't do any replication either.
     */
-   private Object handleCrudMethod(InvocationContext ctx, CacheCommand command, boolean forceAsync)
+   private Object handleCrudMethod(InvocationContext ctx, VisitableCommand command, boolean forceAsync)
          throws Throwable
    {
       if (skipReplication(ctx)) return invokeNextInterceptor(ctx, command);

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -10,21 +10,23 @@
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.RPCManager;
 import org.jboss.cache.ReplicationException;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.AbstractVisitor;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.CreateNodeCommand;
-import org.jboss.cache.commands.cachedata.InvalidateCommand;
-import org.jboss.cache.commands.channel.BlockChannelCommand;
-import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.functional.TxCacheCommand;
-import org.jboss.cache.commands.state.DataVersionCommand;
-import org.jboss.cache.commands.state.GlobalTransactionCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.VersionedDataCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.visitors.DataVersionCommandsVisitor;
-import org.jboss.cache.commands.visitors.GlobalTransactionCommandsVisitor;
+import org.jboss.cache.commands.write.CreateNodeCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.factories.annotations.Inject;
@@ -80,11 +82,8 @@
    private final Map rollbackTransactions = new ConcurrentHashMap(16);
    private long prepares = 0;
    private long commits = 0;
-
    private long rollbacks = 0;
-   private GlobalTransactionCommandsVisitor globalTransactionCommandsVisitor;
 
-
    @Inject
    public void intialize(Configuration configuration, RPCManager rpcManager,
                          CacheTransactionHelper transactionHelper, Notifier notifier, InvocationContextContainer icc,
@@ -413,7 +412,7 @@
     * @throws Throwable
     */
    @Override
-   public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+   public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
       Object result;
       try
@@ -467,24 +466,11 @@
       }
       catch (Throwable throwable)
       {
-         boolean result1;
          ctx.throwIfNeeded(throwable);
          return null;
       }
    }
 
-   @Override
-   public Object handleBlockChannelCommand(InvocationContext ctx, BlockChannelCommand command) throws Throwable
-   {
-      return invokeNextInterceptor(ctx, command);
-   }
-
-   @Override
-   public Object handleUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand command) throws Throwable
-   {
-      return invokeNextInterceptor(ctx, command);
-   }
-
    private void copyForcedCacheModeToTxScope(InvocationContext ctx)
    {
       Option optionOverride = ctx.getOptionOverrides();
@@ -502,7 +488,7 @@
       }
    }
 
-   private CacheCommand attachGlobalTransaction(InvocationContext ctx, Transaction tx, CacheCommand command) throws Throwable
+   private ReplicableCommand attachGlobalTransaction(InvocationContext ctx, Transaction tx, VisitableCommand command) throws Throwable
    {
       if (trace)
       {
@@ -647,7 +633,7 @@
       return retval;
    }
 
-   public class ModificationsReplayVisitor extends DataVersionCommandsVisitor
+   public class ModificationsReplayVisitor extends AbstractVisitor
    {
       private final boolean injectDataVersions;
 
@@ -657,7 +643,7 @@
       }
 
       @Override
-      public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+      public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
       {
          Object result = invokeNextInterceptor(ctx, command);
          assertTxIsActive(ctx);
@@ -665,8 +651,37 @@
       }
 
       @Override
-      public Object handleDataVersionCommand(InvocationContext ctx, DataVersionCommand command) throws Throwable
+      public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
       {
+         return handleDataVersionCommand(ctx, command);
+      }
+
+      @Override
+      public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+      {
+         return handleDataVersionCommand(ctx, command);
+      }
+
+      @Override
+      public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+      {
+         return handleDataVersionCommand(ctx, command);
+      }
+
+      @Override
+      public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
+      {
+         return handleDataVersionCommand(ctx, command);
+      }
+
+      @Override
+      public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+      {
+         return handleDataVersionCommand(ctx, command);
+      }
+
+      private Object handleDataVersionCommand(InvocationContext ctx, VersionedDataCommand command) throws Throwable
+      {
          if (!injectDataVersions) return handleDefault(ctx, command);
          Option originalOption = ctx.getOptionOverrides();
          if (command.isVersioned())
@@ -739,19 +754,19 @@
     * @throws Throwable
     */
    @SuppressWarnings("deprecation")
-   private Object handleCommitRollback(InvocationContext ctx, CacheCommand command) throws Throwable
+   private Object handleCommitRollback(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
       GlobalTransaction gtx = ctx.getGlobalTransaction();
       Object result;
-      CacheCommand originalCommand = ctx.getExecutingCommand();
-      ctx.setExecutingCommand(command);
+      VisitableCommand originalCommand = ctx.getCommand();
+      ctx.setCommand(command);
       try
       {
          result = invokeNextInterceptor(ctx, command);
       }
       finally
       {
-         ctx.setExecutingCommand(originalCommand);
+         ctx.setCommand(originalCommand);
          ctx.setMethodCall(null);
       }
       if (log.isDebugEnabled()) log.debug("Finished local commit/rollback method for " + gtx);
@@ -772,7 +787,7 @@
       ctx.setCacheLoaderHasMods(clModifications != null && clModifications.size() > 0);
       try
       {
-         CacheCommand commitCommand;
+         VisitableCommand commitCommand;
          if (onePhaseCommit)
          {
             // running a 1-phase commit.
@@ -836,7 +851,7 @@
     *
     * @param gtx
     */
-   protected void runRollbackPhase(InvocationContext ctx, GlobalTransaction gtx, Transaction tx, List<TxCacheCommand> modifications)
+   protected void runRollbackPhase(InvocationContext ctx, GlobalTransaction gtx, Transaction tx, List<ReversibleCommand> modifications)
    {
       //Transaction ltx = null;
       try
@@ -844,7 +859,7 @@
          ctx.setTxHasMods(modifications != null && modifications.size() > 0);
 
          // JBCACHE-457
-         CacheCommand rollbackCommand = commandsFactory.buildRollbackCommand(gtx);
+         VisitableCommand rollbackCommand = commandsFactory.buildRollbackCommand(gtx);
          if (trace)
          {
             log.trace(" running rollback for " + gtx);
@@ -874,12 +889,12 @@
     * @param mods list of modifications
     * @return compacted list of modifications
     */
-   private List<TxCacheCommand> compact(List<TxCacheCommand> mods)
+   private List<ReversibleCommand> compact(List<ReversibleCommand> mods)
    {
       // TODO: Make this more sophisticated, so it aggregates multiple puts on the same node, puts followed by a remove, etc.
       // for now this just removes the redundant CreateNodeCommands from the list.
-      List<TxCacheCommand> newList = new LinkedList<TxCacheCommand>();
-      for (TxCacheCommand cmd : mods)
+      List<ReversibleCommand> newList = new LinkedList<ReversibleCommand>();
+      for (ReversibleCommand cmd : mods)
       {
          if (!(cmd instanceof CreateNodeCommand)) newList.add(cmd);
       }
@@ -894,10 +909,10 @@
     * @throws Throwable
     */
    @SuppressWarnings("deprecation")
-   public Object runPreparePhase(InvocationContext ctx, GlobalTransaction gtx, List<TxCacheCommand> modifications) throws Throwable
+   public Object runPreparePhase(InvocationContext ctx, GlobalTransaction gtx, List<ReversibleCommand> modifications) throws Throwable
    {
       // build the method call
-      CacheCommand prepareCommand;
+      VisitableCommand prepareCommand;
       //        if (cache.getCacheModeInternal() != CacheImpl.REPL_ASYNC)
       //        {
       // running a 2-phase commit.
@@ -929,8 +944,8 @@
       //if ltx is not null and it is already running
       if (txManager.getTransaction() != null && ltx != null && txManager.getTransaction().equals(ltx))
       {
-         CacheCommand originalCommand = ctx.getExecutingCommand();
-         ctx.setExecutingCommand(prepareCommand);
+         VisitableCommand originalCommand = ctx.getCommand();
+         ctx.setCommand(prepareCommand);
          // set the hasMods flag in the invocation ctx.  This should not be replicated, just used locally by the interceptors.
          ctx.setTxHasMods(modifications != null && modifications.size() > 0);
          try
@@ -939,7 +954,7 @@
          }
          finally
          {
-            ctx.setExecutingCommand(originalCommand);
+            ctx.setCommand(originalCommand);
             ctx.setMethodCall(null);
          }
       }
@@ -1021,19 +1036,73 @@
    /**
     * Replaces the global transaction in a method call with a new global transaction passed in.
     */
-   private CacheCommand replaceGtx(CacheCommand m, final GlobalTransaction gtx) throws Throwable
+   private VisitableCommand replaceGtx(VisitableCommand m, final GlobalTransaction gtx) throws Throwable
    {
-      //todo add this visitor locally
-      globalTransactionCommandsVisitor = new GlobalTransactionCommandsVisitor()
+      m.acceptVisitor(null, new AbstractVisitor()
       {
          @Override
-         public Object handleGlobalTransactionCommands(GlobalTransactionCommand command)
+         public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
          {
             command.setGlobalTransaction(gtx);
             return null;
          }
-      };
-      m.accept(null, globalTransactionCommandsVisitor);
+
+         @Override
+         public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+         {
+            command.setGlobalTransaction(gtx);
+            return null;
+         }
+
+         @Override
+         public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
+         {
+            command.setGlobalTransaction(gtx);
+            return null;
+         }
+
+         @Override
+         public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+         {
+            command.setGlobalTransaction(gtx);
+            return null;
+         }
+
+         @Override
+         public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+         {
+            command.setGlobalTransaction(gtx);
+            return null;
+         }
+
+         @Override
+         public Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+         {
+            command.setGlobalTransaction(gtx);
+            return null;
+         }
+
+         @Override
+         public Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+         {
+            command.setGlobalTransaction(gtx);
+            return null;
+         }
+
+         @Override
+         public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+         {
+            command.setGlobalTransaction(gtx);
+            return null;
+         }
+
+         @Override
+         public Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+         {
+            command.setGlobalTransaction(gtx);
+            return null;
+         }
+      });
       return m;
    }
 
@@ -1083,7 +1152,7 @@
    {
       Transaction tx = null;
       GlobalTransaction gtx = null;
-      List<TxCacheCommand> modifications = null;
+      List<ReversibleCommand> modifications = null;
       TransactionEntry entry = null;
       protected InvocationContext ctx; // the context for this call.
 

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -3,8 +3,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.visitors.AbstractCommandsVisitor;
+import org.jboss.cache.commands.AbstractVisitor;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.interceptors.InterceptorMBean;
 
 import java.util.Collections;
@@ -14,7 +14,7 @@
  * @author Mircea.Markus at jboss.com
  * @since 2.2
  */
-public class ChainedInterceptor extends AbstractCommandsVisitor implements InterceptorMBean
+public class ChainedInterceptor extends AbstractVisitor implements InterceptorMBean
 {
    private boolean statsEnabled = false;
 
@@ -63,13 +63,13 @@
       this.next = next;
    }
 
-   public Object invokeNextInterceptor(InvocationContext ctx, CacheCommand command) throws Throwable
+   public Object invokeNextInterceptor(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
-      return command.accept(ctx, getNext());
+      return command.acceptVisitor(ctx, getNext());
    }
 
    @Override
-   public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+   public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
       return invokeNextInterceptor(ctx, command);
    }

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingChainedInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingChainedInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,22 +1,26 @@
 package org.jboss.cache.interceptors.base;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.channel.BlockChannelCommand;
-import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
-import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
-import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
-import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 
 /**
  * This interceptor will call {@link #doAfterCall(org.jboss.cache.InvocationContext)} after invoking each handler method.
@@ -369,152 +373,8 @@
       return executeAll(ctx, command);
    }
 
-   @Override
-   public final Object handleReplicateCommand(InvocationContext ctx, ReplicateCommand command) throws Throwable
+   public Object executeAll(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
-      try
-      {
-         return executeReplicateCommands(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx);
-      }
-   }
-
-   public Object executeReplicateCommands(InvocationContext ctx, ReplicateCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleAnnounceBuddyPoolName(InvocationContext ctx, AnnounceBuddyPoolNameCommand command) throws Throwable
-   {
-      try
-      {
-         return executeAnnounceBuddyPoolName(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx);
-      }
-   }
-
-   public Object executeAnnounceBuddyPoolName(InvocationContext ctx, AnnounceBuddyPoolNameCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleRemoveFromBuddyGroupCommand(InvocationContext ctx, RemoveFromBuddyGroupCommand command) throws Throwable
-   {
-      try
-      {
-         return executeRemoveFromBuddyGroupCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx);
-      }
-   }
-
-   public Object executeRemoveFromBuddyGroupCommand(InvocationContext ctx, RemoveFromBuddyGroupCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleAssignToBuddyGroupCommand(InvocationContext ctx, AssignToBuddyGroupCommand command) throws Throwable
-   {
-      try
-      {
-         return executeAssignToBuddyGroupCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx);
-      }
-   }
-
-   public Object executeAssignToBuddyGroupCommand(InvocationContext ctx, AssignToBuddyGroupCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
-   {
-      try
-      {
-         return executeDataGravitationCleanupCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx);
-      }
-   }
-
-   public Object executeDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleClusteredGetCommand(InvocationContext ctx, ClusteredGetCommand command) throws Throwable
-   {
-      try
-      {
-         return executeClusteredGetCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx);
-      }
-   }
-
-   public Object executeClusteredGetCommand(InvocationContext ctx, ClusteredGetCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleBlockChannelCommand(InvocationContext ctx, BlockChannelCommand command) throws Throwable
-   {
-      try
-      {
-         return executeBlockChannelCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx);
-      }
-   }
-
-   public Object executeBlockChannelCommand(InvocationContext ctx, BlockChannelCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand command) throws Throwable
-   {
-      try
-      {
-         return executeUnblockChannelCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx);
-      }
-   }
-
-   public Object executeUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   public Object executeAll(InvocationContext ctx, CacheCommand command) throws Throwable
-   {
       return invokeNextInterceptor(ctx, command);
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,22 +1,26 @@
 package org.jboss.cache.interceptors.base;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.channel.BlockChannelCommand;
-import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
-import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
-import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
-import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 
 /**
  * Chained command interceptor that performs a skip check before calling each handler method.
@@ -314,137 +318,17 @@
    }
 
    @Override
-   public final Object handleReplicateCommand(InvocationContext ctx, ReplicateCommand command) throws Throwable
+   public final Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
       if (skipInterception(ctx))
       {
          return invokeNextInterceptor(ctx, command);
       }
-      return executeReplicateCommands(ctx, command);
-   }
-
-   public Object executeReplicateCommands(InvocationContext ctx, ReplicateCommand command) throws Throwable
-   {
       return executeAll(ctx, command);
    }
 
-   @Override
-   public final Object handleAnnounceBuddyPoolName(InvocationContext ctx, AnnounceBuddyPoolNameCommand command) throws Throwable
+   public Object executeAll(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
-      if (skipInterception(ctx))
-      {
-         return invokeNextInterceptor(ctx, command);
-      }
-      return executeAnnounceBuddyPoolName(ctx, command);
-   }
-
-   public Object executeAnnounceBuddyPoolName(InvocationContext ctx, AnnounceBuddyPoolNameCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleRemoveFromBuddyGroupCommand(InvocationContext ctx, RemoveFromBuddyGroupCommand command) throws Throwable
-   {
-      if (skipInterception(ctx))
-      {
-         return invokeNextInterceptor(ctx, command);
-      }
-      return executeRemoveFromBuddyGroupCommand(ctx, command);
-   }
-
-   public Object executeRemoveFromBuddyGroupCommand(InvocationContext ctx, RemoveFromBuddyGroupCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleAssignToBuddyGroupCommand(InvocationContext ctx, AssignToBuddyGroupCommand command) throws Throwable
-   {
-      if (skipInterception(ctx))
-      {
-         return invokeNextInterceptor(ctx, command);
-      }
-      return executeAssignToBuddyGroupCommand(ctx, command);
-   }
-
-   public Object executeAssignToBuddyGroupCommand(InvocationContext ctx, AssignToBuddyGroupCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
-   {
-      if (skipInterception(ctx))
-      {
-         return invokeNextInterceptor(ctx, command);
-      }
-      return executeDataGravitationCleanupCommand(ctx, command);
-   }
-
-   public Object executeDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleClusteredGetCommand(InvocationContext ctx, ClusteredGetCommand command) throws Throwable
-   {
-      if (skipInterception(ctx))
-      {
-         return invokeNextInterceptor(ctx, command);
-      }
-      return executeClusteredGetCommand(ctx, command);
-   }
-
-   public Object executeClusteredGetCommand(InvocationContext ctx, ClusteredGetCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleBlockChannelCommand(InvocationContext ctx, BlockChannelCommand command) throws Throwable
-   {
-      if (skipInterception(ctx))
-      {
-         return invokeNextInterceptor(ctx, command);
-      }
-      return executeBlockChannelCommand(ctx, command);
-   }
-
-   public Object executeBlockChannelCommand(InvocationContext ctx, BlockChannelCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand command) throws Throwable
-   {
-      if (skipInterception(ctx))
-      {
-         return invokeNextInterceptor(ctx, command);
-      }
-      return executeUnblockChannelCommand(ctx, command);
-   }
-
-   public Object executeUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand command) throws Throwable
-   {
-      return executeAll(ctx, command);
-   }
-
-   @Override
-   public final Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
-   {
-      if (skipInterception(ctx))
-      {
-         return invokeNextInterceptor(ctx, command);
-      }
-      return executeAll(ctx, command);
-   }
-
-   public Object executeAll(InvocationContext ctx, CacheCommand command) throws Throwable
-   {
       return invokeNextInterceptor(ctx, command);
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -2,9 +2,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.annotations.Inject;
 

Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -4,10 +4,17 @@
 import org.jboss.cache.buddyreplication.BuddyManager;
 import org.jboss.cache.buddyreplication.GravitateResult;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.channel.BlockChannelCommand;
-import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.factories.annotations.Inject;
@@ -575,22 +582,6 @@
       return cacheData;
    }
 
-   public void block()
-   {
-      assertIsConstructed();
-      BlockChannelCommand command = commandsFactory.buildBlockChannelCommand();
-      // need to skip status check here because this typically happens before the cache is in it's STARTED state
-      invoker.invoke(invocationContextContainer.get(), command);
-   }
-
-   public void unblock()
-   {
-      assertIsConstructed();
-      UnblockChannelCommand command = commandsFactory.buildUnblockChannelCommand();
-      // need to skip status check here because this typically happens before the cache is in it's STARTED state
-      invoker.invoke(invocationContextContainer.get(), command);
-   }
-
    protected void cacheStatusCheck(InvocationContext ctx)
    {
       assertIsConstructed();

Modified: core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -4,7 +4,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.CacheException;
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.interceptors.base.ChainedInterceptor;
 
@@ -50,6 +50,7 @@
 
    /**
     * Inserts the given interceptor at the specified position in the chain (o based indexing).
+    *
     * @throws IllegalArgumentException if the position is invalid (e.g. 5 and there are only 2 interceptors in the chain)
     */
    public synchronized void addInterceptor(ChainedInterceptor interceptor, int position)
@@ -78,7 +79,8 @@
 
    /**
     * Removes the interceptor at the given postion.
-    * @throws IllegalArgumentException if the position is invalid (e.g. 5 and there are only 2 interceptors in the chain) 
+    *
+    * @throws IllegalArgumentException if the position is invalid (e.g. 5 and there are only 2 interceptors in the chain)
     */
    public synchronized void removeInterceptor(int position)
    {
@@ -230,13 +232,13 @@
    /**
     * Walks the command through the interceptor chain. The received ctx is being passed in.
     */
-   @SuppressWarnings("deprecated")
-   public Object invoke(InvocationContext ctx, CacheCommand command)
+   @SuppressWarnings("deprecation")
+   public Object invoke(InvocationContext ctx, VisitableCommand command)
    {
-      ctx.setExecutingCommand(command);
+      ctx.setCommand(command);
       try
       {
-         return command.accept(ctx, firstInChain);
+         return command.acceptVisitor(ctx, firstInChain);
       }
       catch (CacheException e)
       {
@@ -253,24 +255,24 @@
    }
 
    /**
-    * Similar to {@link #invoke(org.jboss.cache.InvocationContext, org.jboss.cache.commands.CacheCommand)}, but
+    * Similar to {@link #invoke(org.jboss.cache.InvocationContext, org.jboss.cache.commands.ReplicableCommand)}, but
     * constructs a invocation context on the fly, using {@link InvocationContextContainer#get()}
     */
-   public Object invokeRemote(CacheCommand cacheCommand) throws Throwable
+   public Object invokeRemote(VisitableCommand cacheCommand) throws Throwable
    {
       InvocationContext ctxt = invocationContextContainer.get();
       ctxt.setOriginLocal(false);
-      return cacheCommand.accept(ctxt, firstInChain);
+      return cacheCommand.acceptVisitor(ctxt, firstInChain);
    }
 
    /**
-    * Similar to {@link #invoke(org.jboss.cache.InvocationContext, org.jboss.cache.commands.CacheCommand)}, but
+    * Similar to {@link #invoke(org.jboss.cache.InvocationContext, org.jboss.cache.commands.ReplicableCommand)}, but
     * constructs a invocation context on the fly, using {@link InvocationContextContainer#get()} and setting the origin local flag to it's default value.
     */
-   public Object invoke(CacheCommand cacheCommand) throws Throwable
+   public Object invoke(VisitableCommand cacheCommand) throws Throwable
    {
       InvocationContext ctxt = invocationContextContainer.get();
-      return cacheCommand.accept(ctxt, firstInChain);
+      return cacheCommand.acceptVisitor(ctxt, firstInChain);
    }
 
    /**

Modified: core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -9,14 +9,18 @@
 import net.jcip.annotations.ThreadSafe;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.RegionManager;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.CacheDataCommand;
-import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
-import org.jboss.cache.commands.cachedata.GetDataMapCommand;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
+import org.jboss.cache.commands.DataCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.lock.StripedLock;
@@ -26,7 +30,12 @@
 
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * A cache loader that consults other members in the cluster for values.  Does
@@ -99,7 +108,7 @@
       }
    }
 
-   private Object callRemote(CacheDataCommand dataCommand) throws Exception
+   private Object callRemote(DataCommand dataCommand) throws Exception
    {
       if (log.isTraceEnabled()) log.trace("cache=" + cache.getLocalAddress() + "; calling with " + dataCommand);
       List<Address> mbrs = cache.getMembers();

Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -6,7 +6,7 @@
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.invocation.CacheData;

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -12,27 +12,28 @@
 import org.jboss.cache.Region;
 import org.jboss.cache.RegionManager;
 import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.commands.cachedata.CacheDataCommand;
-import org.jboss.cache.commands.cachedata.EvictNodeCommand;
-import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
-import org.jboss.cache.commands.cachedata.GetDataMapCommand;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
-import org.jboss.cache.commands.cachedata.GetKeysCommand;
-import org.jboss.cache.commands.cachedata.InvalidateCommand;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.DataCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
 import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
 import org.jboss.cache.commands.remote.ClusteredGetCommand;
 import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
-import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
 import org.jboss.cache.commands.remote.ReplicateCommand;
-import org.jboss.cache.commands.state.GlobalTransactionCommand;
+import org.jboss.cache.commands.tx.AbstractTransactionCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.EvictNodeCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.annotations.ComponentName;
 import org.jboss.cache.factories.annotations.Inject;
@@ -113,7 +114,7 @@
       throw new RuntimeException("Needs to be overridden!");
    }
 
-   protected Fqn extractFqn(MarshallableCommand cmd)
+   protected Fqn extractFqn(ReplicableCommand cmd)
    {
       if (cmd == null) throw new NullPointerException("Command is null");
 
@@ -126,8 +127,8 @@
 
             // Prepare method has a list of modifications. We will just take the first one and extract.
             PrepareCommand pc = (PrepareCommand) cmd;
-            List modifications = pc.getModifications();
-            fqn = extractFqn((MarshallableCommand) modifications.get(0));
+            List<ReversibleCommand> modifications = pc.getModifications();
+            fqn = extractFqn(modifications.get(0));
 
             // If this is two phase commit, map the FQN to the GTX so
             // we can find it when the commit/rollback comes through
@@ -138,7 +139,7 @@
          case RollbackCommand.METHOD_ID:
          case CommitCommand.METHOD_ID:
             // We stored the fqn in the transactions map during the prepare phase
-            fqn = transactions.remove(((GlobalTransactionCommand) cmd).getGlobalTransaction());
+            fqn = transactions.remove(((AbstractTransactionCommand) cmd).getGlobalTransaction());
             break;
 
          case GravitateDataCommand.METHOD_ID:
@@ -150,7 +151,7 @@
          case GetKeyValueCommand.METHOD_ID:
          case GetKeysCommand.METHOD_ID:
          case RemoteExistsNodeCommand.METHOD_ID:
-            fqn = ((CacheDataCommand) cmd).getFqn();
+            fqn = ((DataCommand) cmd).getFqn();
             break;
 
          case DataGravitationCleanupCommand.METHOD_ID:
@@ -173,9 +174,9 @@
             fqn = ((ClusteredGetCommand) cmd).getCacheDataComand().getFqn();
             break;
          default:
-            if (cmd instanceof CacheDataCommand)
+            if (cmd instanceof DataCommand)
             {
-               fqn = ((CacheDataCommand) cmd).getFqn();
+               fqn = ((DataCommand) cmd).getFqn();
             }
             else
             {

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -10,9 +10,8 @@
 import org.jboss.cache.Region;
 import static org.jboss.cache.Region.Status;
 import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.optimistic.DefaultDataVersion;
 import org.jboss.cache.transaction.GlobalTransaction;
@@ -92,9 +91,9 @@
             region = rrv.region;
             o = rrv.returnValue;
          }
-         else if (o instanceof MarshallableCommand)
+         else if (o instanceof ReplicableCommand)
          {
-            MarshallableCommand marshallableCommand = (MarshallableCommand) o;
+            ReplicableCommand marshallableCommand = (ReplicableCommand) o;
             region = extractFqnRegion(marshallableCommand);
          }
 
@@ -114,7 +113,7 @@
       // parse the stream as per normal.
       Object[] retVal = objectFromObjectStreamRegionBased(in);
       RegionalizedMethodCall rmc = new RegionalizedMethodCall();
-      rmc.command = (CacheCommand) retVal[0];
+      rmc.command = (ReplicableCommand) retVal[0];
       rmc.region = (Fqn) retVal[1];
       return rmc;
    }
@@ -247,7 +246,7 @@
       return region;
    }
 
-   private Fqn extractFqnRegion(MarshallableCommand cmd) throws Exception
+   private Fqn extractFqnRegion(ReplicableCommand cmd) throws Exception
    {
       Fqn fqn = extractFqn(cmd);
 
@@ -268,9 +267,9 @@
          out.writeByte(MAGICNUMBER_REF);
          writeReference(out, refMap.get(o));
       }
-      else if (o instanceof MarshallableCommand)
+      else if (o instanceof ReplicableCommand)
       {
-         MarshallableCommand command = (MarshallableCommand) o;
+         ReplicableCommand command = (ReplicableCommand) o;
 
          if (command.getCommandId() > -1)
          {
@@ -434,7 +433,7 @@
       out.writeObject(s);
    }
 
-   private void marshallCommand(MarshallableCommand command, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception
+   private void marshallCommand(ReplicableCommand command, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception
    {
       out.writeShort(command.getCommandId());
       Object[] args = command.getParameters();
@@ -635,7 +634,7 @@
       return (String) in.readObject();
    }
 
-   private CacheCommand unmarshallCommand(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception
+   private ReplicableCommand unmarshallCommand(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception
    {
       short methodId = in.readShort();
       byte numArgs = in.readByte();

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,11 +1,10 @@
 package org.jboss.cache.marshall;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
 import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
-import org.jboss.cache.commands.remote.DirectCommand;
 import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
 import org.jboss.cache.invocation.CacheLifecycleManager;
 import org.jboss.cache.invocation.InterceptorChain;
@@ -22,7 +21,7 @@
 import java.util.Vector;
 
 /**
- * A JGroups RPC dispatcher that knows how to deal with {@link org.jboss.cache.commands.CacheCommand}s.
+ * A JGroups RPC dispatcher that knows how to deal with {@link org.jboss.cache.commands.ReplicableCommand}s.
  *
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
  * @since 2.2.0
@@ -64,9 +63,9 @@
 
    /**
     * Similar to {@link #callRemoteMethods(java.util.Vector, org.jgroups.blocks.MethodCall, int, long, boolean, boolean, org.jgroups.blocks.RspFilter)} except that this version
-    * is aware of {@link org.jboss.cache.commands.CacheCommand} objects.
+    * is aware of {@link org.jboss.cache.commands.ReplicableCommand} objects.
     */
-   public RspList invokeRemoteCommands(Vector<Address> dests, MarshallableCommand command, int mode, long timeout,
+   public RspList invokeRemoteCommands(Vector<Address> dests, ReplicableCommand command, int mode, long timeout,
                                        boolean use_anycasting, boolean oob, RspFilter filter)
    {
       if (dests != null && dests.isEmpty())
@@ -108,7 +107,7 @@
       {
          try
          {
-            return executeCommand((CacheCommand) req_marshaller.objectFromByteBuffer(req.getBuffer()), req);
+            return executeCommand((ReplicableCommand) req_marshaller.objectFromByteBuffer(req.getBuffer()), req);
          }
          catch (Throwable x)
          {
@@ -122,32 +121,34 @@
       }
    }
 
-   protected Object executeCommand(CacheCommand cmd, Message req) throws Throwable
+   protected Object executeCommand(ReplicableCommand cmd, Message req) throws Throwable
    {
       if (trace) log.trace("Executing command: " + cmd + " [sender=" + req.getSrc() + "]");
 
-      if (cmd instanceof DirectCommand)
+      if (cmd instanceof VisitableCommand)
       {
-         if (trace) log.trace("This is a direct command - so performing directly and not via the invoker.");
-         DirectCommand dCmd = (DirectCommand) cmd;
+         InvocationContext ctx = invocationContextContainer.get();
+         ctx.setOriginLocal(false);
+         if (!lifecycleManager.allowsInvocation(false))
+         {
+            return null;
+         }
+         return interceptorChain.invoke(ctx, (VisitableCommand) cmd);
+      }
+      else
+      {
+         if (trace) log.trace("This is a non-visitable command - so performing directly and not via the invoker.");
 
          // need to check cache status for all except buddy replication commands.
-         if (!(dCmd instanceof AnnounceBuddyPoolNameCommand ||
-               dCmd instanceof AssignToBuddyGroupCommand ||
-               dCmd instanceof RemoveFromBuddyGroupCommand)
+         if (!(cmd instanceof AnnounceBuddyPoolNameCommand ||
+               cmd instanceof AssignToBuddyGroupCommand ||
+               cmd instanceof RemoveFromBuddyGroupCommand)
                && !lifecycleManager.allowsInvocation(false))
          {
             return null;
          }
-         return dCmd.performDirectly();
+         return cmd.perform(null);
       }
-      InvocationContext ctx = invocationContextContainer.get();
-      ctx.setOriginLocal(false);
-      if (!lifecycleManager.allowsInvocation(false))
-      {
-         return null;
-      }
-      return interceptorChain.invoke(ctx, cmd);
    }
 
    @Override

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,9 +1,9 @@
 package org.jboss.cache.marshall;
 
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.invocation.CacheLifecycleManager;
+import org.jboss.cache.invocation.InterceptorChain;
 import org.jboss.cache.invocation.InvocationContextContainer;
-import org.jboss.cache.invocation.InterceptorChain;
-import org.jboss.cache.invocation.CacheLifecycleManager;
 import org.jgroups.Channel;
 import org.jgroups.MembershipListener;
 import org.jgroups.Message;
@@ -25,7 +25,7 @@
     */
    public InactiveRegionAwareRpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, Object serverObj,
                                            InvocationContextContainer container, InterceptorChain interceptorChain,
-                                    CacheLifecycleManager lifecycleManager)
+                                           CacheLifecycleManager lifecycleManager)
    {
       super(channel, l, l2, serverObj, container, interceptorChain, lifecycleManager);
    }
@@ -48,7 +48,7 @@
       if (isValid(req))
       {
          RegionalizedMethodCall rmc;
-         CacheCommand command;
+         ReplicableCommand command;
 
          try
          {

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -26,7 +26,7 @@
  * Thanks to Elias Ross/genman for this info.
  *
  * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
- * @deprecated - in favour of {@link org.jboss.cache.commands.CacheCommand} instances.  Will be removed in 3.X.
+ * @deprecated - in favour of {@link org.jboss.cache.commands.ReplicableCommand} instances.  Will be removed in 3.X.
  */
 @Deprecated
 public class MethodCall extends org.jgroups.blocks.MethodCall

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,7 +1,7 @@
 package org.jboss.cache.marshall;
 
 import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.ReplicableCommand;
 
 /**
  * A regionalized MethodCall object, created when {@link Marshaller#regionalizedMethodCallFromByteBuffer(byte[])} or
@@ -16,6 +16,6 @@
  */
 class RegionalizedMethodCall
 {
-   CacheCommand command;
+   ReplicableCommand command;
    Fqn region;
 }

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -12,8 +12,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Modification;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
-import org.jboss.cache.commands.functional.TxCacheCommand;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
 import org.jboss.cache.lock.IdentityLock;
@@ -67,11 +67,11 @@
    /**
     * List<MethodCall> of modifications ({@link MethodCall}). They will be replicated on TX commit
     */
-   private final List<TxCacheCommand> modificationList = new LinkedList<TxCacheCommand>();
+   private final List<ReversibleCommand> modificationList = new LinkedList<ReversibleCommand>();
 
    // For some reason we see multiple threads accessing this list - even within the same tx.  Could be due to reuse of
    // tx identifiers in the DummyTM, which is where we see this problem.
-   private final List<TxCacheCommand> classLoadeModList = new CopyOnWriteArrayList<TxCacheCommand>();
+   private final List<ReversibleCommand> classLoadeModList = new CopyOnWriteArrayList<ReversibleCommand>();
 
    /**
     * LinkedHashSet<IdentityLock> of locks acquired by the transaction. We use
@@ -101,13 +101,13 @@
    /**
     * Adds a modification to the modification list.
     */
-   public void addModification(TxCacheCommand command)
+   public void addModification(ReversibleCommand command)
    {
       if (command == null) return;
       modificationList.add(command);
    }
 
-   public void addCacheLoaderModification(TxCacheCommand command)
+   public void addCacheLoaderModification(ReversibleCommand command)
    {
       if (command != null) classLoadeModList.add(command);
    }
@@ -115,12 +115,12 @@
    /**
     * Returns all modifications.
     */
-   public List<TxCacheCommand> getModifications()
+   public List<ReversibleCommand> getModifications()
    {
       return modificationList;
    }
 
-   public List<TxCacheCommand> getCacheLoaderModifications()
+   public List<ReversibleCommand> getCacheLoaderModifications()
    {
       // make sure this isn't modified externally
       return Collections.unmodifiableList(classLoadeModList);
@@ -319,15 +319,15 @@
       {
          log.trace("undoOperations " + modificationList);
       }
-      ArrayList<TxCacheCommand> copy;
+      ArrayList<ReversibleCommand> copy;
       synchronized (modificationList)
       {
-         copy = new ArrayList<TxCacheCommand>(modificationList);
+         copy = new ArrayList<ReversibleCommand>(modificationList);
       }
       for (ListIterator i = copy.listIterator(copy.size()); i.hasPrevious();)
       {
          Object undoOp = i.previous();
-         TxCacheCommand txCommand = (TxCacheCommand) undoOp;
+         ReversibleCommand txCommand = (ReversibleCommand) undoOp;
          if (log.isDebugEnabled()) log.debug("Calling rollback() on command " + undoOp);
          txCommand.rollback();
       }
@@ -398,7 +398,7 @@
 
    public boolean wasRemovedInTx(Fqn fqn)
    {
-      for (TxCacheCommand txCacheCommand : getCacheLoaderModifications())
+      for (ReversibleCommand txCacheCommand : getCacheLoaderModifications())
       {
          //todo - revisit this as it is ugly. phps add an isRemovred(fqn) somwhere on command hierarchy?
          if (txCacheCommand instanceof RemoveNodeCommand && fqn.isChildOrEquals(((RemoveNodeCommand) txCacheCommand).getFqn()))

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -10,7 +10,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.CacheException;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.functional.TxCacheCommand;
+import org.jboss.cache.commands.ReversibleCommand;
 import org.jboss.cache.lock.NodeLock;
 
 import javax.transaction.Transaction;
@@ -180,7 +180,7 @@
    /**
     * Adds a motification to the global transaction.
     */
-   public void addModification(GlobalTransaction gtx, TxCacheCommand m)
+   public void addModification(GlobalTransaction gtx, ReversibleCommand m)
    {
       TransactionEntry entry = get(gtx);
       if (entry == null)
@@ -191,7 +191,7 @@
       entry.addModification(m);
    }
 
-   public void addCacheLoaderModification(GlobalTransaction gtx, TxCacheCommand m)
+   public void addCacheLoaderModification(GlobalTransaction gtx, ReversibleCommand m)
    {
       if (m != null)
       {

Modified: core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -9,12 +9,11 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.RPCManager;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Configuration.CacheMode;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
 import org.jboss.cache.lock.NodeLock;
-import org.jboss.cache.marshall.MethodCall;
 import org.jboss.cache.misc.TestingUtil;
 import org.jboss.cache.optimistic.TransactionWorkspace;
 import org.jboss.cache.transaction.GlobalTransaction;
@@ -179,7 +178,7 @@
       {
          // specify what we expect called on the mock Rpc Manager.  For params we don't care about, just use ANYTHING.
          // setting the mock object to expect the "sync" param to be false.
-         expect(rpcManager.callRemoteMethods(anyAddresses(), (CacheCommand) anyObject(), eq(false), anyBoolean(), anyInt(), anyBoolean())).andReturn(null);
+         expect(rpcManager.callRemoteMethods(anyAddresses(), (ReplicableCommand) anyObject(), eq(false), anyBoolean(), anyInt(), anyBoolean())).andReturn(null);
       }
 
       replay(rpcManager);
@@ -242,7 +241,7 @@
          List<Address> memberList = originalRpcManager.getMembers();
          expect(barfingRpcManager.getMembers()).andReturn(memberList).anyTimes();
          expect(barfingRpcManager.getLocalAddress()).andReturn(originalRpcManager.getLocalAddress()).anyTimes();
-         expect(barfingRpcManager.callRemoteMethods(anyAddresses(), (CacheCommand) anyObject(), anyBoolean(), anyBoolean(), anyInt(), anyBoolean())).andThrow(new RuntimeException("Barf!")).anyTimes();
+         expect(barfingRpcManager.callRemoteMethods(anyAddresses(), (ReplicableCommand) anyObject(), anyBoolean(), anyBoolean(), anyInt(), anyBoolean())).andThrow(new RuntimeException("Barf!")).anyTimes();
          replay(barfingRpcManager);
 
          TestingUtil.extractComponentRegistry(cache1).registerComponent(RPCManager.class.getName(), barfingRpcManager, RPCManager.class);

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -8,9 +8,9 @@
 
 import org.jboss.cache.Fqn;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.ComponentRegistry;
@@ -143,7 +143,7 @@
 
       BuddyManager bm = createBasicBuddyManager();
 
-      ReplicateCommand newReplicatedCall = (ReplicateCommand) bm.transformFqns(call2);
+      ReplicateCommand newReplicatedCall = bm.transformReplicateCommand(call2);
       PutKeyValueCommand newPutCall = (PutKeyValueCommand) newReplicatedCall.getSingleModification();
 
       // should use object refs to transform the original MethodCall.
@@ -156,12 +156,12 @@
    {
       Fqn fqn1 = Fqn.ROOT;
 
-      MarshallableCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false, false);
+      ReplicableCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false, false);
       ReplicateCommand call2 = new ReplicateCommand(call1);
 
       BuddyManager bm = createBasicBuddyManager();
 
-      ReplicateCommand newReplicatedCall = (ReplicateCommand) bm.transformFqns(call2);
+      ReplicateCommand newReplicatedCall = bm.transformReplicateCommand(call2);
       PutKeyValueCommand newPutCall = (PutKeyValueCommand) newReplicatedCall.getSingleModification();
 
       // should use object refs to transform the original MethodCall.
@@ -180,7 +180,7 @@
       PutKeyValueCommand call2 = new PutKeyValueCommand(null, fqn2, "key", "value", false, false);
       PutKeyValueCommand call3 = new PutKeyValueCommand(null, fqn3, "key", "value", false, false);
       PutKeyValueCommand call4 = new PutKeyValueCommand(null, fqn4, "key", "value", false, false);
-      List<MarshallableCommand> list = new ArrayList<MarshallableCommand>();
+      List<ReplicableCommand> list = new ArrayList<ReplicableCommand>();
       list.add(call1);
       list.add(call2);
       list.add(call3);
@@ -190,8 +190,8 @@
 
       BuddyManager bm = createBasicBuddyManager();
 
-      ReplicateCommand newReplicatedCall = (ReplicateCommand) bm.transformFqns(call5);
-      List<MarshallableCommand> l = newReplicatedCall.getModifications();
+      ReplicateCommand newReplicatedCall = bm.transformReplicateCommand(call5);
+      List<ReplicableCommand> l = newReplicatedCall.getModifications();
 
       // should use object refs to transform the original MethodCall.
       String expected = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + DUMMY_LOCAL_ADDRESS;

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -16,6 +16,7 @@
 import org.jboss.cache.eviction.LRUConfiguration;
 import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.misc.TestingUtil;
+import static org.jboss.cache.misc.TestingUtil.dumpCacheContents;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertTrue;
 import org.testng.annotations.Test;

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -8,6 +8,7 @@
 
 import org.jboss.cache.Fqn;
 import org.jboss.cache.misc.TestingUtil;
+import static org.jboss.cache.misc.TestingUtil.dumpCacheContents;
 import static org.testng.AssertJUnit.assertTrue;
 import org.testng.annotations.Test;
 

Modified: core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -5,7 +5,7 @@
 import org.jboss.cache.Cache;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.RPCManager;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.ComponentRegistry;
 import org.jboss.cache.misc.TestingUtil;
@@ -82,7 +82,7 @@
 
       // now try the last PUT which should result in the queue being flushed.
       expect(mockRpcManager.getMembers()).andReturn(originalRpcManager.getMembers()).anyTimes();
-      expect(mockRpcManager.callRemoteMethods((List<Address>) anyObject(), (CacheCommand) anyObject(), anyBoolean(), anyBoolean(), anyInt(), anyBoolean())).andReturn(Collections.emptyList()).anyTimes();
+      expect(mockRpcManager.callRemoteMethods((List<Address>) anyObject(), (ReplicableCommand) anyObject(), anyBoolean(), anyBoolean(), anyInt(), anyBoolean())).andReturn(Collections.emptyList()).anyTimes();
       replay(mockRpcManager);
 
       cache.put("/a/b/c/LAST", "k", "v");
@@ -111,7 +111,7 @@
 
       // expect basic cluster related calls
       expect(mockRpcManager.getMembers()).andReturn(originalRpcManager.getMembers()).anyTimes();
-      expect(mockRpcManager.callRemoteMethods((List<Address>) anyObject(), (CacheCommand) anyObject(), anyBoolean(), anyBoolean(), anyInt(), anyBoolean())).andReturn(Collections.emptyList()).anyTimes();
+      expect(mockRpcManager.callRemoteMethods((List<Address>) anyObject(), (ReplicableCommand) anyObject(), anyBoolean(), anyBoolean(), anyInt(), anyBoolean())).andReturn(Collections.emptyList()).anyTimes();
       replay(mockRpcManager);
 
       Thread[] threads = new Thread[numThreads];

Modified: core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -13,15 +13,15 @@
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.Region;
 import org.jboss.cache.RegionManager;
-import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
-import org.jboss.cache.commands.cachedata.GetNodeCommand;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.RemoveDataCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
-import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.config.EvictionConfig;
 import org.jboss.cache.config.EvictionRegionConfig;
 import org.jboss.cache.eviction.DummyEvictionConfiguration;
@@ -100,7 +100,7 @@
    {
       // make sure node that doesn't exist does not result in a node visit event.
 
-      CacheCommand command = commandsFactory.buildGetNodeCommand(Fqn.fromString(fqn1));
+      VisitableCommand command = commandsFactory.buildGetNodeCommand(Fqn.fromString(fqn1));
       invoker.invoke(command);
       Region regionABC = regionManager.getRegion(fqn1, false);
       assertNull(regionABC.takeLastEventNode());

Modified: core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -5,7 +5,7 @@
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.misc.TestingUtil;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeMethod;

Modified: core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -137,7 +137,7 @@
       assertNull("Tx should have been scrubbed", cache.getInvocationContext().getTransaction());
       assertNull("Gtx should have been scrubbed", cache.getInvocationContext().getGlobalTransaction());
       assertEquals("Method call should have been scrubbed", null, cache.getInvocationContext().getMethodCall());
-      assertEquals("Cache command should have been scrubbed", null, cache.getInvocationContext().getExecutingCommand());
+      assertEquals("Cache command should have been scrubbed", null, cache.getInvocationContext().getCommand());
 
       // check that the transaction entry hasn't leaked stuff.
       assert entry.getModifications().isEmpty() : "Should have scrubbed modifications in transaction entry";

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -12,9 +12,9 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Region;
 import org.jboss.cache.RegionManager;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.misc.TestingUtil;
 import static org.testng.AssertJUnit.*;
@@ -180,7 +180,7 @@
       rman.activate(A);
       assertTrue(rman.hasRegion(A, Region.Type.MARSHALLING));
 
-      CacheCommand result = (CacheCommand) testee.objectFromByteBuffer(callBytes);
+      ReplicableCommand result = (ReplicableCommand) testee.objectFromByteBuffer(callBytes);
       assertEquals("Did not get replicate method when passing" +
             " call for active node", ReplicateCommand.class, result.getClass());
    }

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,8 +1,8 @@
 package org.jboss.cache.marshall;
 
 import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
 import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import static org.testng.AssertJUnit.assertEquals;
 import org.testng.annotations.Test;
 

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -8,10 +8,9 @@
 
 import org.jboss.cache.Fqn;
 import org.jboss.cache.RegionManager;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.ComponentRegistry;
 import static org.testng.AssertJUnit.assertEquals;
@@ -113,12 +112,12 @@
    public void testMethodCall() throws Exception
    {
       Fqn fqn = Fqn.fromElements(3, false);
-      CacheCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value", false, false);
+      ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value", false, false);
       byte[] asBytes = marshaller.objectToByteBuffer(cmd);
       Object o2 = marshaller.objectFromByteBuffer(asBytes);
 
-      assertTrue("Unmarshalled object should be a method call", o2 instanceof CacheCommand);
-      CacheCommand cmd2 = (CacheCommand) o2;
+      assertTrue("Unmarshalled object should be a method call", o2 instanceof ReplicableCommand);
+      ReplicableCommand cmd2 = (ReplicableCommand) o2;
 
       assertEquals(cmd, cmd2);
    }
@@ -126,12 +125,12 @@
    public void testNestedMethodCall() throws Exception
    {
       Fqn fqn = Fqn.fromElements(3, false);
-      MarshallableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value", false, false);
-      CacheCommand replicateCmd = new ReplicateCommand(cmd);
+      ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value", false, false);
+      ReplicableCommand replicateCmd = new ReplicateCommand(cmd);
       byte[] asBytes = marshaller.objectToByteBuffer(replicateCmd);
       Object o2 = marshaller.objectFromByteBuffer(asBytes);
-      assertTrue("Unmarshalled object should be a method call", o2 instanceof CacheCommand);
-      CacheCommand cmd2 = (CacheCommand) o2;
+      assertTrue("Unmarshalled object should be a method call", o2 instanceof ReplicableCommand);
+      ReplicableCommand cmd2 = (ReplicableCommand) o2;
 
       assertEquals(replicateCmd, cmd2);
    }
@@ -211,13 +210,13 @@
    protected void doReplicationQueueTest() throws Exception
    {
       // replication queue takes a list of replicate() MethodCalls and wraps them in a single replicate call.
-      List<MarshallableCommand> calls = new ArrayList<MarshallableCommand>();
+      List<ReplicableCommand> calls = new ArrayList<ReplicableCommand>();
 
       Fqn f = Fqn.fromElements("BlahBlah", 3, false);
       String k = "key", v = "value";
 
-      MarshallableCommand cmd = new PutKeyValueCommand(null, f, k, v, true, false);
-      MarshallableCommand replCmd = new ReplicateCommand(cmd);
+      ReplicableCommand cmd = new PutKeyValueCommand(null, f, k, v, true, false);
+      ReplicableCommand replCmd = new ReplicateCommand(cmd);
 
       calls.add(replCmd);
 
@@ -226,7 +225,7 @@
 
       calls.add(replCmd);
 
-      MarshallableCommand replAllCmd = new ReplicateCommand(calls);
+      ReplicableCommand replAllCmd = new ReplicateCommand(calls);
 
       byte[] buf = marshaller.objectToByteBuffer(replAllCmd);
 

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,8 +1,12 @@
 package org.jboss.cache.marshall;
 
-import org.jboss.cache.*;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.ComponentRegistry;
@@ -18,7 +22,14 @@
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
 import java.util.Map;
 
 /**

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,10 +1,10 @@
 package org.jboss.cache.marshall;
 
 import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
+import org.jboss.cache.commands.ReversibleCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.ComponentRegistry;
 import static org.testng.AssertJUnit.assertEquals;
@@ -28,8 +28,8 @@
    private Marshaller m;
    private ObjectOutputStream stream;
    private ByteArrayOutputStream byteStream;
-   private CacheCommand command1;
-   private List<CacheCommand> list = new ArrayList<CacheCommand>(2);
+   private ReversibleCommand command1;
+   private List<ReversibleCommand> list = new ArrayList<ReversibleCommand>(2);
    private PrepareCommand prepareComand;
 
    @BeforeMethod(alwaysRun = true)

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -6,10 +6,10 @@
 import org.jboss.cache.Region;
 import org.jboss.cache.buddyreplication.GravitateResult;
 import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.CacheDataCommand;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
+import org.jboss.cache.commands.DataCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
 import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.misc.TestingUtil;
 import static org.testng.AssertJUnit.*;
@@ -99,7 +99,7 @@
       assertSame(listClass, cache2.get(fqn, key).getClass());
 
 
-      CacheDataCommand command = new GetKeyValueCommand(fqn, key, false);
+      DataCommand command = new GetKeyValueCommand(fqn, key, false);
       ClusteredGetCommand clusteredGet = new ClusteredGetCommand(false, command);
 
       List responses = cache1.getRPCManager().callRemoteMethods(null, clusteredGet, true, true, 15000, false);

Modified: core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -11,9 +11,8 @@
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.CacheStatus;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.util.CachePrinter;
-import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.factories.ComponentRegistry;
 import org.jboss.cache.interceptors.base.ChainedInterceptor;
 import org.jboss.cache.invocation.CacheInvocationDelegate;
@@ -21,13 +20,14 @@
 import org.jboss.cache.invocation.InterceptorChain;
 import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.loader.CacheLoaderManager;
+import org.jboss.cache.util.CachePrinter;
 import org.jgroups.JChannel;
 
 import java.io.File;
 import java.lang.reflect.Field;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
-import java.util.ArrayList;
 
 /**
  * Utilities for unit testing JBossCache.
@@ -545,7 +545,7 @@
       throw new RuntimeException("Timed out waiting for condition");
    }
 
-   public static void replicateCommand(CacheSPI cache, CacheCommand command) throws Throwable
+   public static void replicateCommand(CacheSPI cache, VisitableCommand command) throws Throwable
    {
       ComponentRegistry cr = extractComponentRegistry(cache);
       InterceptorChain ic = cr.getComponent(InterceptorChain.class);
@@ -606,10 +606,11 @@
       }
       System.out.println("**** END: Cache Contents ****");
    }
+
    public static void dumpCacheContents(Object... caches)
    {
       List<CacheSPI> result = new ArrayList<CacheSPI>();
-      for (Object cache: caches)
+      for (Object cache : caches)
       {
          result.add((CacheSPI<Object, Object>) cache);
       }

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -7,13 +7,18 @@
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.functional.TxCacheCommand;
-import org.jboss.cache.commands.state.DataVersionCommand;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.VersionedDataCommand;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
 import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.interceptors.*;
+import org.jboss.cache.interceptors.CacheMgmtInterceptor;
+import org.jboss.cache.interceptors.CallInterceptor;
+import org.jboss.cache.interceptors.NotificationInterceptor;
+import org.jboss.cache.interceptors.OptimisticLockingInterceptor;
+import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
+import org.jboss.cache.interceptors.OptimisticValidatorInterceptor;
 import org.jboss.cache.interceptors.base.ChainedInterceptor;
 import org.jboss.cache.loader.DummyInMemoryCacheLoader;
 import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
@@ -282,14 +287,14 @@
       }
    }
 
-   protected List<TxCacheCommand> injectDataVersion(List<TxCacheCommand> modifications)
+   protected List<ReversibleCommand> injectDataVersion(List<ReversibleCommand> modifications)
    {
       List<MethodCall> newList = new LinkedList<MethodCall>();
-      for (TxCacheCommand c : modifications)
+      for (ReversibleCommand c : modifications)
       {
-         if (c instanceof DataVersionCommand)
+         if (c instanceof VersionedDataCommand)
          {
-            ((DataVersionCommand)c).setDataVersion(new DefaultDataVersion());
+            ((VersionedDataCommand) c).setDataVersion(new DefaultDataVersion());
          }
 //         Object[] oa = c.getArgs();
 //         Object[] na = new Object[oa.length + 1];

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -10,9 +10,7 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.VersionedNode;
-import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.functional.TxCacheCommand;
-import org.jboss.cache.commands.state.GlobalTransactionCommand;
+import org.jboss.cache.commands.ReversibleCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
@@ -42,7 +40,6 @@
    Log log = LogFactory.getLog(CacheTest.class);
 
    private CacheSPI<Object, Object> c;
-   private CommandsFactory commandsFactory;
 
    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception
@@ -220,13 +217,12 @@
 
       remoteGtx.setAddress(new DummyAddress());
       //hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
 
       command.setGlobalTransaction(remoteGtx);
 
-      commandsFactory = new CommandsFactory();
       //call our remote method
-      List<TxCacheCommand> cacheCommands = injectDataVersion(entry.getModifications());
+      List<ReversibleCommand> cacheCommands = injectDataVersion(entry.getModifications());
       OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, cacheCommands, (Map) null, (Address) remoteGtx.getAddress(), false);
 
       TestingUtil.replicateCommand(c, prepareCommand);

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -10,7 +10,7 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
 import org.jboss.cache.interceptors.TxInterceptor;
@@ -258,8 +258,7 @@
       final String fastThreadName = "FAST";
       ChainedInterceptor slowdownInterceptor = new ChainedInterceptor()
       {
-
-         public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+         public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
          {
             if (Thread.currentThread().getName().equals(slowThreadName))
             {
@@ -295,7 +294,7 @@
       final String fastThreadName = "FAST";
       ChainedInterceptor slowdownInterceptor = new ChainedInterceptor()
       {
-         public Object hanldeDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+         public Object hanldeDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
          {
             if (Thread.currentThread().getName().equals(slowThreadName) && ctx.getMethodCall().getMethodId() == OptimisticPrepareCommand.METHOD_ID)
             {

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,8 +1,8 @@
 package org.jboss.cache.optimistic;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.interceptors.base.ChainedInterceptor;
 
 import java.util.ArrayList;
@@ -18,16 +18,16 @@
  */
 public class MockFailureInterceptor extends ChainedInterceptor
 {
-   private List<Class<? extends CacheCommand>> allCalled = new ArrayList<Class<? extends CacheCommand>>();
-   private List<Class<? extends CacheCommand>> failurelist = new ArrayList<Class<? extends CacheCommand>>();
+   private List<Class<? extends ReplicableCommand>> allCalled = new ArrayList<Class<? extends ReplicableCommand>>();
+   private List<Class<? extends ReplicableCommand>> failurelist = new ArrayList<Class<? extends ReplicableCommand>>();
    private List<Integer> allCalledIdsList = new ArrayList<Integer>();
 
    @Override
-   public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+   public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
       if (failurelist.contains(command.getClass())) throw new Exception("Failure in method " + command);
       allCalled.add(command.getClass());
-      allCalledIdsList.add(((MarshallableCommand) command).getCommandId());
+      allCalledIdsList.add(command.getCommandId());
 
       return null;
    }
@@ -35,7 +35,7 @@
    /**
     * @return Returns the failurelist.
     */
-   public List<Class<? extends CacheCommand>> getFailurelist()
+   public List<Class<? extends ReplicableCommand>> getFailurelist()
    {
       return failurelist;
    }
@@ -43,7 +43,7 @@
    /**
     * @param failurelist The failurelist to set.
     */
-   public void setFailurelist(List<Class<? extends CacheCommand>> failurelist)
+   public void setFailurelist(List<Class<? extends ReplicableCommand>> failurelist)
    {
       this.failurelist = failurelist;
    }
@@ -51,7 +51,7 @@
    /**
     * @return Returns the called.
     */
-   public List<Class<? extends CacheCommand>> getAllCalled()
+   public List<Class<? extends ReplicableCommand>> getAllCalled()
    {
       return allCalled;
    }
@@ -59,7 +59,7 @@
    /**
     * @param called The called to set.
     */
-   public void setAllCalled(List<Class<? extends CacheCommand>> called)
+   public void setAllCalled(List<Class<? extends ReplicableCommand>> called)
    {
       this.allCalled = called;
    }

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -1,8 +1,8 @@
 package org.jboss.cache.optimistic;
 
 import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.functional.MarshallableCommand;
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.interceptors.base.ChainedInterceptor;
 
 import java.util.ArrayList;
@@ -18,15 +18,15 @@
  */
 public class MockInterceptor extends ChainedInterceptor
 {
-   CacheCommand calledCommand;
-   private List<Class<? extends CacheCommand>> calledlist = new ArrayList<Class<? extends CacheCommand>>();
+   ReplicableCommand calledCommand;
+   private List<Class<? extends ReplicableCommand>> calledlist = new ArrayList<Class<? extends ReplicableCommand>>();
    private List<Integer> calledIdsList = new ArrayList<Integer>();
 
    @Override
-   public synchronized Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+   public synchronized Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
       calledlist.add(command.getClass());
-      calledIdsList.add(((MarshallableCommand) command).getCommandId());
+      calledIdsList.add(command.getCommandId());
       calledCommand = command;
       return null;
    }
@@ -34,17 +34,17 @@
    /**
     * @return Returns the called.
     */
-   public CacheCommand getCalledCommand()
+   public ReplicableCommand getCalledCommand()
    {
       return calledCommand;
    }
 
-   public Class<? extends CacheCommand> getCalledCommandClass()
+   public Class<? extends ReplicableCommand> getCalledCommandClass()
    {
       return calledCommand.getClass();
    }
 
-   public List<Class<? extends CacheCommand>> getAllCalled()
+   public List<Class<? extends ReplicableCommand>> getAllCalled()
    {
       return calledlist;
    }
@@ -57,7 +57,7 @@
    /**
     * @param called The called to set.
     */
-   public void setCalled(CacheCommand called)
+   public void setCalled(ReplicableCommand called)
    {
       this.calledCommand = called;
    }

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -8,7 +8,7 @@
 
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
 import org.jboss.cache.interceptors.base.ChainedInterceptor;
 import org.jboss.cache.loader.SamplePojo;

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -4,7 +4,7 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.interceptors.OptimisticInterceptor;
 import org.jboss.cache.interceptors.OptimisticLockingInterceptor;
 import org.jboss.cache.lock.NodeLock;
@@ -217,7 +217,7 @@
 
 
    @Override
-   public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+   public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
    {
       TransactionWorkspace w = getTransactionWorkspace(ctx.getGlobalTransaction());
       Map nodeMap = w.getNodes();

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -7,8 +7,7 @@
 package org.jboss.cache.optimistic;
 
 import org.jboss.cache.CacheSPI;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.state.GlobalTransactionCommand;
+import org.jboss.cache.commands.ReversibleCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
@@ -144,14 +143,14 @@
 
       remoteGtx.setAddress(new TestAddress());
       //hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = (ReversibleCommand) entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
 
       //call our remote method
-      CacheCommand prepcareCommand = new OptimisticPrepareCommand(remoteGtx, null, (Map) null, (Address) remoteGtx.getAddress(), false);
+      OptimisticPrepareCommand optimisticPrepareCommand = new OptimisticPrepareCommand(remoteGtx, null, (Map) null, (Address) remoteGtx.getAddress(), false);
       try
       {
-         TestingUtil.replicateCommand(cache, prepcareCommand); //getInvocationDelegate(cache)._replicate(prepareMethod);
+         TestingUtil.replicateCommand(cache, optimisticPrepareCommand); //getInvocationDelegate(cache)._replicate(prepareMethod);
       }
       catch (Throwable t)
       {
@@ -209,13 +208,13 @@
 
       remoteGtx.setAddress(new TestAddress());
       //hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
-      CacheCommand prepcareCommand = new OptimisticPrepareCommand(remoteGtx, null, (Map) null, (Address) remoteGtx.getAddress(), false);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, null, null, (Address) remoteGtx.getAddress(), false);
       try
       {
-         TestingUtil.replicateCommand(cache, prepcareCommand);
+         TestingUtil.replicateCommand(cache, prepareCommand);
       }
       catch (Throwable t)
       {
@@ -241,7 +240,7 @@
       assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
 
       //	    call our remote method
-      CacheCommand cacheCommand = new RollbackCommand(null);
+      RollbackCommand cacheCommand = new RollbackCommand(null);
       try
       {
          TestingUtil.replicateCommand(cache, cacheCommand);
@@ -287,7 +286,7 @@
 
       remoteGtx.setAddress(new TestAddress());
       //hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
 
       List calls = dummy.getAllCalledIds();
@@ -297,7 +296,7 @@
       assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
 
       //	    call our remote method
-      CacheCommand cacheCommand = new CommitCommand(gtx);
+      CommitCommand cacheCommand = new CommitCommand(gtx);
 
       try
       {
@@ -346,7 +345,7 @@
 
       remoteGtx.setAddress(new TestAddress());
       //hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
 
       command.setGlobalTransaction(remoteGtx);
 
@@ -357,7 +356,7 @@
       assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
 
       //	    call our remote method
-      CacheCommand cacheCommand = new RollbackCommand(remoteGtx);
+      RollbackCommand cacheCommand = new RollbackCommand(remoteGtx);
 
       TestingUtil.replicateCommand(cache, cacheCommand);
       assertTrue("Should be handled on the remote end without barfing, in the event of a rollback without a prepare", true);
@@ -399,12 +398,12 @@
 
       remoteGtx.setAddress(new TestAddress());
       //hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
-      CacheCommand prepcareCommand = new OptimisticPrepareCommand(remoteGtx, null, (Map) null, (Address) remoteGtx.getAddress(), false);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, null, (Map) null, (Address) remoteGtx.getAddress(), false);
       try
       {
-         TestingUtil.replicateCommand(cache, prepcareCommand);
+         TestingUtil.replicateCommand(cache, prepareCommand);
       }
       catch (Throwable t)
       {
@@ -431,7 +430,7 @@
       assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
 
       //	    call our remote method
-      CacheCommand commitCommand = new CommitCommand(remoteGtx);
+      CommitCommand commitCommand = new CommitCommand(remoteGtx);
       try
       {
          TestingUtil.replicateCommand(cache, commitCommand);

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -7,7 +7,7 @@
 package org.jboss.cache.optimistic;
 
 import org.jboss.cache.CacheSPI;
-import org.jboss.cache.commands.state.GlobalTransactionCommand;
+import org.jboss.cache.commands.ReversibleCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
@@ -305,7 +305,7 @@
 
       remoteGtx.setAddress(new DummyAddress());
       //hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
       OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
@@ -364,7 +364,7 @@
 
       remoteGtx.setAddress(new DummyAddress());
       //hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
       OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
@@ -447,7 +447,7 @@
 
       remoteGtx.setAddress(new DummyAddress());
       //hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
       OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
@@ -535,7 +535,7 @@
 
       remoteGtx.setAddress(new DummyAddress());
       //hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
       OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
@@ -633,7 +633,7 @@
       remoteGtx.setAddress(new DummyAddress());
 
 //	    hack the method call to make it have the remote globalTransaction
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
       OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
@@ -717,7 +717,7 @@
 
       remoteGtx.setAddress(new DummyAddress());
 
-      GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
+      ReversibleCommand command = entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
       OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -10,7 +10,7 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
@@ -391,7 +391,7 @@
 
    public static class ResetRemoteFlagInterceptor extends ChainedInterceptor
    {
-      public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
+      public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
       {
          log.trace("Setting isRemote on globalTransaction " + ctx.getGlobalTransaction() + " to true");
          ctx.getGlobalTransaction().setRemote(true);

Modified: core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java	2008-04-25 17:50:41 UTC (rev 5697)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java	2008-04-26 01:24:30 UTC (rev 5698)
@@ -4,7 +4,7 @@
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.RPCManager;
-import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.commands.remote.ReplicateCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
@@ -75,7 +75,7 @@
    private static class DelegatingRPCManager implements RPCManager
    {
       RPCManager delegate;
-      Map<Class<? extends CacheCommand>, Boolean> log = new HashMap<Class<? extends CacheCommand>, Boolean>();
+      Map<Class<? extends ReplicableCommand>, Boolean> log = new HashMap<Class<? extends ReplicableCommand>, Boolean>();
 
       public void disconnect()
       {
@@ -92,28 +92,28 @@
          delegate.start();
       }
 
-      void logCall(CacheCommand command, boolean oob)
+      void logCall(ReplicableCommand command, boolean oob)
       {
          if (command instanceof ReplicateCommand)
          {
-            CacheCommand cmd = ((ReplicateCommand) command).getSingleModification();
+            ReplicableCommand cmd = ((ReplicateCommand) command).getSingleModification();
             log.put(cmd.getClass(), oob);
          }
       }
 
-      public List<Object> callRemoteMethods(List<Address> recipients, CacheCommand cacheCommand, int mode, boolean excludeSelf, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception
+      public List<Object> callRemoteMethods(List<Address> recipients, ReplicableCommand cacheCommand, int mode, boolean excludeSelf, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception
       {
          logCall(cacheCommand, useOutOfBandMessage);
          return delegate.callRemoteMethods(recipients, cacheCommand, mode, excludeSelf, timeout, responseFilter, useOutOfBandMessage);
       }
 
-      public List<Object> callRemoteMethods(List<Address> recipients, CacheCommand cacheCommand, int mode, boolean excludeSelf, long timeout, boolean useOutOfBandMessage) throws Exception
+      public List<Object> callRemoteMethods(List<Address> recipients, ReplicableCommand cacheCommand, int mode, boolean excludeSelf, long timeout, boolean useOutOfBandMessage) throws Exception
       {
          logCall(cacheCommand, useOutOfBandMessage);
          return delegate.callRemoteMethods(recipients, cacheCommand, mode, excludeSelf, timeout, useOutOfBandMessage);
       }
 
-      public List<Object> callRemoteMethods(List<Address> recipients, CacheCommand command, boolean synchronous, boolean excludeSelf, int timeout, boolean useOutOfBandMessage) throws Exception
+      public List<Object> callRemoteMethods(List<Address> recipients, ReplicableCommand command, boolean synchronous, boolean excludeSelf, int timeout, boolean useOutOfBandMessage) throws Exception
       {
          logCall(command, useOutOfBandMessage);
          return delegate.callRemoteMethods(recipients, command, synchronous, excludeSelf, timeout, useOutOfBandMessage);




More information about the jbosscache-commits mailing list