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

Jason Thomas Greene jgreene at jboss.com
Sun Apr 22 22:53:22 EDT 2007


  User: jgreene 
  Date: 07/04/22 22:53:22

  Modified:    src/org/jboss/cache/pojo    MethodDeclarations.java
                        PojoCacheListener.java PojoUtil.java
  Log:
  Introduce new notification API
  Remove mixin approach
  
  Revision  Changes    Path
  1.3       +9 -10     JBossCache/src/org/jboss/cache/pojo/MethodDeclarations.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MethodDeclarations.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/MethodDeclarations.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- MethodDeclarations.java	25 Jan 2007 21:54:05 -0000	1.2
  +++ MethodDeclarations.java	23 Apr 2007 02:53:22 -0000	1.3
  @@ -7,20 +7,19 @@
   
   package org.jboss.cache.pojo;
   
  +import java.lang.reflect.Field;
  +import java.lang.reflect.Method;
  +import java.util.List;
  +
   import org.jboss.aop.InstanceAdvisor;
   import org.jboss.aop.advice.Interceptor;
  -import org.jboss.cache.pojo.observable.Observer;
   import org.jboss.cache.Fqn;
   
  -import java.lang.reflect.Method;
  -import java.lang.reflect.Field;
  -import java.util.List;
  -
   /**
    * Method declarations for rollback method mostly.
    *
    * @author Ben Wang
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class MethodDeclarations
   {
  @@ -40,13 +39,13 @@
           try
           {
              attachInterceptor = PojoUtil.class.getDeclaredMethod("attachInterceptor",
  -                   new Class[] {Object.class, InstanceAdvisor.class, Interceptor.class, Observer.class});
  +                   new Class[] {Object.class, InstanceAdvisor.class, Interceptor.class});
              detachInterceptor = PojoUtil.class.getDeclaredMethod("detachInterceptor",
  -                   new Class[] {InstanceAdvisor.class, Interceptor.class, Observer.class});
  +                   new Class[] {InstanceAdvisor.class, Interceptor.class});
              undoAttachInterceptor = PojoUtil.class.getDeclaredMethod("undoAttachInterceptor",
  -                   new Class[] {Object.class, InstanceAdvisor.class, Interceptor.class, Observer.class});
  +                   new Class[] {Object.class, InstanceAdvisor.class, Interceptor.class});
              undoDetachInterceptor = PojoUtil.class.getDeclaredMethod("undoDetachInterceptor",
  -                   new Class[] {InstanceAdvisor.class, Interceptor.class, Observer.class});
  +                   new Class[] {InstanceAdvisor.class, Interceptor.class});
              inMemorySubstitution = PojoUtil.class.getDeclaredMethod("inMemorySubstitution",
                      new Class[] {Object.class, Field.class, Object.class});
              undoInMemorySubstitution = PojoUtil.class.getDeclaredMethod("undoInMemorySubstitution",
  
  
  
  1.2       +41 -20    JBossCache/src/org/jboss/cache/pojo/PojoCacheListener.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PojoCacheListener.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/PojoCacheListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- PojoCacheListener.java	13 Jan 2007 15:55:01 -0000	1.1
  +++ PojoCacheListener.java	23 Apr 2007 02:53:22 -0000	1.2
  @@ -7,41 +7,62 @@
   
   package org.jboss.cache.pojo;
   
  -import java.lang.reflect.Field;
  +import org.jboss.cache.pojo.notification.AttachNotification;
  +import org.jboss.cache.pojo.notification.DetachNotification;
  +import org.jboss.cache.pojo.notification.FieldModifyNotification;
  +import org.jboss.cache.pojo.notification.ListModifyNotification;
  +import org.jboss.cache.pojo.notification.MapModifyNotification;
  +import org.jboss.cache.pojo.notification.SetModifyNotification;
   
   /**
    * Listener interface for PojoCache events
    *
  + * @author Jason T. Greene
    * @author Ben Wang
  - * @version $Id: PojoCacheListener.java,v 1.1 2007/01/13 15:55:01 bwang Exp $
  + * @version $Id: PojoCacheListener.java,v 1.2 2007/04/23 02:53:22 jgreene Exp $
    * @since 2.0
    */
   public interface PojoCacheListener
   {
      /**
  -    * Event when a POJO is attaching.
  +    * Called before and after object is attached to the cache.
       *
  -    * @param pojo    The POJO that is attaching.
  -    * @param pre     True if this the callback before it is attached.
  -    * @param isLocal True if this is the local event, e.g., I am the active node.
  +    * @param notification
       */
  -   void attach(Object pojo, boolean pre, boolean isLocal);
  +   public void attach(AttachNotification notification);
   
      /**
  -    * Event when a POJO is detaching.
  +    * Called before and after an object is detached from the cache.
       *
  -    * @param pojo    The POJO that is detaching.
  -    * @param pre     True if this the callback before it is detached.
  -    * @param isLocal True if this is the local event, e.g., I am the active node.
  +    * @param notification
       */
  -   void detach(Object pojo, boolean pre, boolean isLocal);
  +   public void detach(DetachNotification notification);
   
      /**
  -    * Event when a POJO is modifying.
  +    * Called before an after a field on an attached object is modified.
       *
  -    * @param pojo    The POJO that is modifying.
  -    * @param pre     True if this the callback before it is modified.
  -    * @param isLocal True if this is the local event, e.g., I am the active node.
  +    * @param notification
       */
  -   void modify(Object pojo, Field field, boolean pre, boolean isLocal);
  +   public void modify(FieldModifyNotification notification);
  +   
  +   /**
  +    * Called when a list is modified.
  +    * 
  +    * @param notification
  +    */
  +   public void modify(ListModifyNotification notification);
  +   
  +   /**
  +    * Called when a Set is modified
  +    * 
  +    * @param notification
  +    */
  +   public void modify(SetModifyNotification notification);
  +   
  +   /**
  +    * Called when a Map is modified
  +    * 
  +    * @param notification
  +    */
  +   public void modify(MapModifyNotification notification);
   }
  
  
  
  1.3       +14 -24    JBossCache/src/org/jboss/cache/pojo/PojoUtil.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PojoUtil.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/PojoUtil.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- PojoUtil.java	25 Jan 2007 21:54:05 -0000	1.2
  +++ PojoUtil.java	23 Apr 2007 02:53:22 -0000	1.3
  @@ -7,6 +7,9 @@
   
   package org.jboss.cache.pojo;
   
  +import java.lang.reflect.Field;
  +import java.util.List;
  +
   import org.jboss.aop.Advised;
   import org.jboss.aop.Domain;
   import org.jboss.aop.InstanceAdvisor;
  @@ -17,17 +20,12 @@
   import org.jboss.cache.pojo.annotation.TxUndo;
   import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor;
   import org.jboss.cache.pojo.interceptors.dynamic.ReentrancyStopperInterceptor;
  -import org.jboss.cache.pojo.observable.Observer;
  -import org.jboss.cache.pojo.observable.Subject;
  -
  -import java.lang.reflect.Field;
  -import java.util.List;
   
   /**
    * Utility class for method wrappers that we are interested to rollback (i.e., rollback).
    *
    * @author Ben Wang
  - * @version $Id: PojoUtil.java,v 1.2 2007/01/25 21:54:05 genman Exp $
  + * @version $Id: PojoUtil.java,v 1.3 2007/04/23 02:53:22 jgreene Exp $
    */
   public class PojoUtil
   {
  @@ -35,25 +33,23 @@
      private boolean checkRecursive = false;
   
      @TxUndo
  -   public void attachInterceptor(Object pojo, InstanceAdvisor advisor, Interceptor interceptor,
  -                                 Observer observer)
  +   public void attachInterceptor(Object pojo, InstanceAdvisor advisor, Interceptor interceptor)
      {
  -      _attachInterceptor(pojo, advisor, interceptor, observer);
  +      _attachInterceptor(pojo, advisor, interceptor);
      }
   
      @TxUndo
  -   public void detachInterceptor(InstanceAdvisor advisor, Interceptor interceptor, Observer observer)
  +   public void detachInterceptor(InstanceAdvisor advisor, Interceptor interceptor)
      {
  -      _detachInterceptor(advisor, interceptor, observer);
  +      _detachInterceptor(advisor, interceptor);
      }
   
  -   public void undoAttachInterceptor(Object pojo, InstanceAdvisor advisor, Interceptor interceptor,
  -                                     Observer observer)
  +   public void undoAttachInterceptor(Object pojo, InstanceAdvisor advisor, Interceptor interceptor)
      {
  -      _detachInterceptor(advisor, interceptor, observer);
  +      _detachInterceptor(advisor, interceptor);
      }
   
  -   public void undoDetachInterceptor(InstanceAdvisor advisor, Interceptor interceptor, Observer observer)
  +   public void undoDetachInterceptor(InstanceAdvisor advisor, Interceptor interceptor)
      {
         Object pojo = ((CacheFieldInterceptor) interceptor).getAopInstance().get();
         if (pojo == null)
  @@ -61,7 +57,7 @@
            throw new PojoCacheException("PojoUtil.detachInterceptor(): null pojo");
         }
   
  -      _attachInterceptor(pojo, advisor, interceptor, observer);
  +      _attachInterceptor(pojo, advisor, interceptor);
      }
   
      @TxUndo
  @@ -75,12 +71,8 @@
         _inMemorySubstitution(obj, field, oldValue);
      }
   
  -   private void _attachInterceptor(Object pojo, InstanceAdvisor advisor, Interceptor interceptor,
  -                                   Observer observer)
  +   private void _attachInterceptor(Object pojo, InstanceAdvisor advisor, Interceptor interceptor)
      {
  -      // add the observer
  -      ((Subject) pojo).addObserver(observer);
  -
         // Note that subject interceptor should come before the cache interceptor.
         advisor.appendInterceptor(interceptor);
   
  @@ -134,7 +126,7 @@
         }
      }
   
  -   private void _detachInterceptor(InstanceAdvisor advisor, Interceptor interceptor, Observer observer)
  +   private void _detachInterceptor(InstanceAdvisor advisor, Interceptor interceptor)
      {
         advisor.removeInterceptor(interceptor.getName());
         // retrieve pojo
  @@ -145,8 +137,6 @@
            throw new PojoCacheException("PojoUtil.detachInterceptor(): null pojo");
         }
   
  -      ((Subject) pojo).removeObserver(observer);
  -
         if (checkRecursive)
         {
            // Insert interceptor to detect recursive call
  
  
  



More information about the jboss-cvs-commits mailing list