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

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Jul 4 05:57:55 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-07-04 05:57:55 -0400 (Fri, 04 Jul 2008)
New Revision: 6175

Added:
   core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java
Removed:
   core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java
Modified:
   core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
Log:
Added support for preprocessing intercepted commands

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java	2008-07-04 09:39:44 UTC (rev 6174)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java	2008-07-04 09:57:55 UTC (rev 6175)
@@ -27,7 +27,7 @@
 import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.interceptors.base.PostProcessingCommandInterceptor;
+import org.jboss.cache.interceptors.base.PrePostProcessingCommandInterceptor;
 import org.jboss.cache.invocation.InvocationContext;
 import org.jboss.cache.invocation.NodeInvocationDelegate;
 import org.jboss.cache.lock.LockManager;
@@ -49,7 +49,7 @@
  * @see <a href="http://wiki.jboss.org/wiki/JBossCacheMVCC">MVCC designs</a>
  * @since 3.0
  */
-public class MVCCLockingInterceptor extends PostProcessingCommandInterceptor
+public class MVCCLockingInterceptor extends PrePostProcessingCommandInterceptor
 {
    boolean allowWriteSkew;
    LockManager lockManager;

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-07-04 09:39:44 UTC (rev 6174)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-07-04 09:57:55 UTC (rev 6175)
@@ -30,7 +30,7 @@
 import org.jboss.cache.commands.write.RemoveNodeCommand;
 import org.jboss.cache.factories.CommandsFactory;
 import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.interceptors.base.PostProcessingCommandInterceptor;
+import org.jboss.cache.interceptors.base.PrePostProcessingCommandInterceptor;
 import org.jboss.cache.invocation.InvocationContext;
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.lock.LockManager;
@@ -64,7 +64,7 @@
  * @author Bela Ban
  * @version $Id$
  */
-public class PessimisticLockInterceptor extends PostProcessingCommandInterceptor
+public class PessimisticLockInterceptor extends PrePostProcessingCommandInterceptor
 {
    private DataContainer dataContainer;
    private PessimisticNodeBasedLockManager lockManager;

Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java	2008-07-04 09:39:44 UTC (rev 6174)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java	2008-07-04 09:57:55 UTC (rev 6175)
@@ -1,421 +0,0 @@
-package org.jboss.cache.interceptors.base;
-
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.commands.read.ExistsCommand;
-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.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.*;
-import org.jboss.cache.invocation.InvocationContext;
-
-/**
- * This interceptor will call {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} after invoking each visit method
- * (and the {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)} method) in
- * a <tt>finally</tt> block.
- * <p/>
- * It is useful if common cleanup code is required at the end of each call.
- * <p/>
- * Instead of overriding visitXXX() methods, implementations should override their handleXXX() counterparts defined in this class
- * instead, as well as the {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method.
- *
- * @author Mircea.Markus at jboss.com
- * @since 2.2
- */
-public abstract class PostProcessingCommandInterceptor extends CommandInterceptor
-{
-   @Override
-   public final Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
-   {
-      try
-      {
-         return handlePutDataMapCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
-   {
-      try
-      {
-         return handlePutKeyValueCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   @Override
-   public final Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
-   {
-      try
-      {
-         return handlePutForExternalReadCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-
-   protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   protected Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-
-   @Override
-   public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
-   {
-      try
-      {
-         return handleRemoveNodeCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
-   {
-      try
-      {
-         return handleCreateNodeCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-
-   @Override
-   public final Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
-   {
-      try
-      {
-         return handleClearDataCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
-   {
-      try
-      {
-         return handleEvictFqnCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
-   {
-      try
-      {
-         return handleInvalidateCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
-   {
-      try
-      {
-         return handleRemoveKeyCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
-   {
-      try
-      {
-         return handleGetDataMapCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
-   {
-      try
-      {
-         return handleExistsNodeCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
-   {
-      try
-      {
-         return handleGetKeyValueCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
-   {
-      try
-      {
-         return handleGetNodeCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
-   {
-      try
-      {
-         return handleGetKeysCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
-   {
-      try
-      {
-         return handleGetChildrenNamesCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
-   {
-      try
-      {
-         return handleMoveCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
-   {
-      try
-      {
-         return handleGravitateDataCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
-   {
-      try
-      {
-         return handlePrepareCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
-   {
-      try
-      {
-         return handleRollbackCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
-   {
-      try
-      {
-         return handleCommitCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   @Override
-   public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
-   {
-      try
-      {
-         return handleOptimisticPrepareCommand(ctx, command);
-      }
-      finally
-      {
-         doAfterCall(ctx, command);
-      }
-   }
-
-   protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
-   {
-      return handleDefault(ctx, command);
-   }
-
-   /**
-    * Callback that is invoked after every handleXXX() method defined above.
-    *
-    * @param ctx     invocation context
-    * @param command command which was invoked
-    */
-   protected abstract void doAfterCall(InvocationContext ctx, VisitableCommand command);
-}

Copied: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java (from rev 6169, core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java	2008-07-04 09:57:55 UTC (rev 6175)
@@ -0,0 +1,437 @@
+package org.jboss.cache.interceptors.base;
+
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.read.ExistsCommand;
+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.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.ClearDataCommand;
+import org.jboss.cache.commands.write.CreateNodeCommand;
+import org.jboss.cache.commands.write.EvictCommand;
+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.PutForExternalReadCommand;
+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.invocation.InvocationContext;
+
+/**
+ * This interceptor adds pre and post processing to each <tt>visitXXX()</tt> method.
+ * <p/>
+ * For each <tt>visitXXX()</tt> method invoked, it will first call {@link #doBeforeCall(org.jboss.cache.invocation.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
+ * and if this method returns true, it will proceed to invoking a <tt>handleXXX()</tt> method and lastly, {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
+ * in a <tt>finally</tt> block.  Note that the <tt>doAfterCall()</tt> method is still invoked even if <tt>doBeforeCall()</tt> returns <tt>false</tt>.
+ * <p/>
+ * Instead of overriding <tt>visitXXX()</tt> methods, implementations should override their <tt>handleXXX()</tt> counterparts defined in this class
+ * instead, as well as the {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method and
+ * optionally {@link #doBeforeCall(org.jboss.cache.invocation.InvocationContext, org.jboss.cache.commands.VisitableCommand)}.
+ * <p/>
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+public abstract class PrePostProcessingCommandInterceptor extends CommandInterceptor
+{
+   @Override
+   public final Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handlePutDataMapCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handlePutKeyValueCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   @Override
+   public final Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handlePutForExternalReadCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+
+   protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   protected Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+
+   @Override
+   public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleRemoveNodeCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleCreateNodeCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+
+   @Override
+   public final Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleClearDataCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleEvictFqnCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleInvalidateCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleRemoveKeyCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGetDataMapCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleExistsNodeCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGetKeyValueCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGetNodeCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGetKeysCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGetChildrenNamesCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleMoveCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleGravitateDataCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handlePrepareCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleRollbackCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleCommitCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   @Override
+   public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+   {
+      try
+      {
+         return doBeforeCall(ctx, command) ? handleOptimisticPrepareCommand(ctx, command) : null;
+      }
+      finally
+      {
+         doAfterCall(ctx, command);
+      }
+   }
+
+   protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
+   /**
+    * Callback that is invoked after every handleXXX() method defined above.
+    *
+    * @param ctx     invocation context
+    * @param command command which was invoked
+    */
+   protected abstract void doAfterCall(InvocationContext ctx, VisitableCommand command);
+
+   protected boolean doBeforeCall(InvocationContext ctx, VisitableCommand command)
+   {
+      return true;
+   }
+}




More information about the jbosscache-commits mailing list