[jboss-cvs] JBossCache/src-50/org/jboss/cache/pojo/interceptors ...

Ben Wang bwang at jboss.com
Sun Jul 30 22:44:42 EDT 2006


  User: bwang   
  Date: 06/07/30 22:44:42

  Modified:    src-50/org/jboss/cache/pojo/interceptors 
                        PojoTxUndoInterceptor.java
  Log:
  JBCACHE-686 Colelction handles undo properly.
  
  Revision  Changes    Path
  1.3       +14 -4     JBossCache/src-50/org/jboss/cache/pojo/interceptors/PojoTxUndoInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PojoTxUndoInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/interceptors/PojoTxUndoInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- PojoTxUndoInterceptor.java	7 Jul 2006 09:34:41 -0000	1.2
  +++ PojoTxUndoInterceptor.java	31 Jul 2006 02:44:42 -0000	1.3
  @@ -13,13 +13,14 @@
   import org.jboss.aop.joinpoint.Invocation;
   import org.jboss.aop.joinpoint.MethodInvocation;
   import java.lang.reflect.Method;
  +import java.lang.reflect.Field;
   
   /**
  - * Interceptor (done via aop advice) for transaction undo. This is is attached to the
  - * operation that needs a corresponding undo, e.g., attachInterceptor.
  + * Interceptor (done via aop advice) for transaction rollback. This is is attached to the
  + * operation that needs a corresponding rollback, e.g., attachInterceptor.
    *
    * @author Ben Wang
  - * @version $Id: PojoTxUndoInterceptor.java,v 1.2 2006/07/07 09:34:41 bwang Exp $
  + * @version $Id: PojoTxUndoInterceptor.java,v 1.3 2006/07/31 02:44:42 bwang Exp $
    */
   public class PojoTxUndoInterceptor extends AbstractInterceptor
   {
  @@ -45,7 +46,7 @@
   //         throw new IllegalStateException("PojoTxUndoInterceptor.invoke(): PojoTxSynchronizationHandler is null");
         }
   
  -      // Add to the undo list
  +      // Add to the rollback list
         String methodName = invocation.getMethod().getName();
         // TODO Needs to handle Collection interceptor as well.
         if( methodName.equals(MethodDeclarations.attachInterceptor.getName()))
  @@ -58,6 +59,15 @@
            Method method = MethodDeclarations.undoDetachInterceptor;
            MethodCall mc = new MethodCall(method, invocation.getArguments(), invocation.getTargetObject());
            handler.addToList(mc);
  +      } else if ( methodName.equals(MethodDeclarations.fieldReplaceNewValue.getName()))
  +      {
  +         Method method = MethodDeclarations.undoFieldReplaceNewValue;
  +         Object obj = invocation.getArguments()[0];
  +         Field field = (Field)invocation.getArguments()[1];
  +         Object oldValue = field.get(obj);
  +         Object[] args = new Object[] { obj, field, oldValue };
  +         MethodCall mc = new MethodCall(method, args, invocation.getTargetObject());
  +         handler.addToList(mc);
         } else
         {
            throw new RuntimeException("PojoTxUndoInterceptor: invalid invocation name: " +methodName);
  
  
  



More information about the jboss-cvs-commits mailing list