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

Ben Wang bwang at jboss.com
Thu Jul 13 11:56:12 EDT 2006


  User: bwang   
  Date: 06/07/13 11:56:12

  Modified:    src-50/org/jboss/cache/pojo/collection    
                        CachedListImpl.java CachedMapImpl.java
                        CachedSetImpl.java CollectionInterceptorUtil.java
  Log:
  Refctoring and moved some classes to impl dir.
  
  Revision  Changes    Path
  1.5       +18 -15    JBossCache/src-50/org/jboss/cache/pojo/collection/CachedListImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CachedListImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CachedListImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- CachedListImpl.java	7 Jul 2006 10:26:03 -0000	1.4
  +++ CachedListImpl.java	13 Jul 2006 15:56:12 -0000	1.5
  @@ -11,6 +11,7 @@
   import org.jboss.cache.pojo.util.AopUtil;
   import org.jboss.cache.pojo.util.Null;
   import org.jboss.cache.pojo.PojoTreeCache;
  +import org.jboss.cache.pojo.impl.PojoCacheImpl;
   import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor;
   
   import java.util.Iterator;
  @@ -34,11 +35,13 @@
   //   protected static final Log log_ = LogFactory.getLog(CachedListImpl.class);
      @SuppressWarnings({"CanBeFinal"})
      private PojoTreeCache cache_;
  +   private PojoCacheImpl pCache_;
      private AbstractCollectionInterceptor interceptor_;
   
  -   public CachedListImpl(PojoTreeCache cache, AbstractCollectionInterceptor interceptor)
  +   public CachedListImpl(PojoCacheImpl cache, AbstractCollectionInterceptor interceptor)
      {
  -      cache_ = cache;
  +      pCache_ = cache;
  +      cache_ = (PojoTreeCache)pCache_.getCache();
         interceptor_ = interceptor;
      }
   
  @@ -64,7 +67,7 @@
         checkIndex();
         try
         {
  -         return Null.toNullValue(cache_.getObject(AopUtil.constructFqn(getFqn(), Integer.toString(index))));
  +         return Null.toNullValue(pCache_.getObject(AopUtil.constructFqn(getFqn(), Integer.toString(index))));
         } catch (Exception e)
         {
            throw new RuntimeException(e);
  @@ -102,7 +105,7 @@
         {
            if (index != 0)
               checkIndex(); // Since index can be size().
  -         return Null.toNullValue(cache_.putObject(AopUtil.constructFqn(getFqn(), Integer.toString(index)), Null.toNullObject(element)));
  +         return Null.toNullValue(pCache_.putObject(AopUtil.constructFqn(getFqn(), Integer.toString(index)), Null.toNullObject(element)));
         } catch (Exception e)
         {
            throw new RuntimeException(e);
  @@ -117,10 +120,10 @@
               checkIndex(); // Since index can be size().
            for (int i = size(); i > index; i--)
            {
  -            Object obj = cache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(i - 1)));
  -            cache_.putObject(AopUtil.constructFqn(getFqn(), Integer.toString(i)), obj);
  +            Object obj = pCache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(i - 1)));
  +            pCache_.putObject(AopUtil.constructFqn(getFqn(), Integer.toString(i)), obj);
            }
  -         cache_.putObject(AopUtil.constructFqn(getFqn(), Integer.toString(index)), Null.toNullObject(element));
  +         pCache_.putObject(AopUtil.constructFqn(getFqn(), Integer.toString(index)), Null.toNullObject(element));
         } catch (Exception e)
         {
            throw new RuntimeException(e);
  @@ -175,15 +178,15 @@
            checkIndex();
            // Object result = cache.removeObject(((Fqn) fqn.clone()).add(new Integer(index)));
            int size = size();
  -         Object result = Null.toNullValue(cache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(index))));
  +         Object result = Null.toNullValue(pCache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(index))));
            if (size == (index + 1))
            {
               return result; // We are the last one.
            }
            for (int i = index; i < size - 1; i++)
            {
  -            Object obj = cache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(i + 1)));
  -            cache_.putObject(AopUtil.constructFqn(getFqn(), Integer.toString(i)), obj);
  +            Object obj = pCache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(i + 1)));
  +            pCache_.putObject(AopUtil.constructFqn(getFqn(), Integer.toString(i)), obj);
            }
            return result;
         } catch (Exception e)
  @@ -219,7 +222,7 @@
   
               try
               {
  -               return Null.toNullValue(cache_.getObject(AopUtil.constructFqn(getFqn(), Integer.toString(++current))));
  +               return Null.toNullValue(pCache_.getObject(AopUtil.constructFqn(getFqn(), Integer.toString(++current))));
               } catch (Exception e)
               {
                  throw new RuntimeException(e);
  @@ -238,16 +241,16 @@
                  if (current < (size - 1))
                  {
                     // Need to reshuffle the items.
  -                  Object last = cache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(current)));
  +                  Object last = pCache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(current)));
                     for (int i = current + 1; i < size; i++)
                     {
  -                     last = cache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(i)));
  -                     cache_.putObject(AopUtil.constructFqn(getFqn(), Integer.toString(i - 1)), last);
  +                     last = pCache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(i)));
  +                     pCache_.putObject(AopUtil.constructFqn(getFqn(), Integer.toString(i - 1)), last);
                     }
                  } else
                  { // we are the last index.
                     // Need to move back the cursor.
  -                  cache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(current)));
  +                  pCache_.removeObject(AopUtil.constructFqn(getFqn(), Integer.toString(current)));
                  }
                  current--;
                  size--;
  
  
  
  1.8       +11 -8     JBossCache/src-50/org/jboss/cache/pojo/collection/CachedMapImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CachedMapImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CachedMapImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- CachedMapImpl.java	7 Jul 2006 10:26:03 -0000	1.7
  +++ CachedMapImpl.java	13 Jul 2006 15:56:12 -0000	1.8
  @@ -11,6 +11,7 @@
   import org.jboss.cache.Fqn;
   import org.jboss.cache.pojo.util.Null;
   import org.jboss.cache.pojo.PojoTreeCache;
  +import org.jboss.cache.pojo.impl.PojoCacheImpl;
   import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor;
   
   import java.util.AbstractCollection;
  @@ -36,12 +37,14 @@
   
   //   protected static final Log log_ = LogFactory.getLog(CachedMapImpl.class);
   
  +   private PojoCacheImpl pCache_;
      private PojoTreeCache cache_;
      private AbstractCollectionInterceptor interceptor_;
   
  -   public CachedMapImpl(PojoTreeCache cache, AbstractCollectionInterceptor interceptor)
  +   public CachedMapImpl(PojoCacheImpl pCache, AbstractCollectionInterceptor interceptor)
      {
  -      this.cache_ = cache;
  +      pCache_ = pCache;
  +      cache_ = (PojoTreeCache)pCache_.getCache();
         interceptor_ = interceptor;
   
      }
  @@ -78,7 +81,7 @@
      {
         try
         {
  -         return Null.toNullValue(cache_.getObject(constructFqn(getFqn(), Null.toNullKeyObject(key))));
  +         return Null.toNullValue(pCache_.getObject(constructFqn(getFqn(), Null.toNullKeyObject(key))));
         } catch (Exception e)
         {
            throw new RuntimeException(e);
  @@ -89,7 +92,7 @@
      {
         try
         {
  -         return cache_.putObject(constructFqn(getFqn(), Null.toNullKeyObject(key)), Null.toNullObject(value));
  +         return pCache_.putObject(constructFqn(getFqn(), Null.toNullKeyObject(key)), Null.toNullObject(value));
         } catch (Exception e)
         {
            throw new RuntimeException(e);
  @@ -109,7 +112,7 @@
      {
         try
         {
  -         return cache_.removeObject(constructFqn(getFqn(), Null.toNullKeyObject(key)));
  +         return pCache_.removeObject(constructFqn(getFqn(), Null.toNullKeyObject(key)));
         } catch (Exception e)
         {
            throw new RuntimeException(e);
  @@ -237,7 +240,7 @@
                     try
                     {
                        lastKey = i.next();
  -                     return Null.toNullValue(cache_.getObject(constructFqn(getFqn(), lastKey)));
  +                     return Null.toNullValue(pCache_.getObject(constructFqn(getFqn(), lastKey)));
                     }
                     catch (NotSerializableException e)
                     {
  @@ -384,7 +387,7 @@
         {
            try
            {
  -            return Null.toNullValue(cache_.getObject(constructFqn(getFqn(), key)));
  +            return Null.toNullValue(pCache_.getObject(constructFqn(getFqn(), key)));
            } catch (Exception e)
            {
               throw new RuntimeException(e);
  @@ -395,7 +398,7 @@
         {
            try
            {
  -            return cache_.putObject(constructFqn(getFqn(), key), Null.toNullObject(value));
  +            return pCache_.putObject(constructFqn(getFqn(), key), Null.toNullObject(value));
            } catch (Exception e)
            {
               throw new RuntimeException(e);
  
  
  
  1.5       +8 -5      JBossCache/src-50/org/jboss/cache/pojo/collection/CachedSetImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CachedSetImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CachedSetImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- CachedSetImpl.java	7 Jul 2006 10:26:03 -0000	1.4
  +++ CachedSetImpl.java	13 Jul 2006 15:56:12 -0000	1.5
  @@ -12,6 +12,7 @@
   import org.jboss.cache.pojo.util.AopUtil;
   import org.jboss.cache.pojo.util.Null;
   import org.jboss.cache.pojo.PojoTreeCache;
  +import org.jboss.cache.pojo.impl.PojoCacheImpl;
   import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor;
   
   import java.util.AbstractSet;
  @@ -34,11 +35,13 @@
   //   protected static final Log log_=LogFactory.getLog(CachedSetImpl.class);
   
      private PojoTreeCache cache_;
  +   private PojoCacheImpl pCache_;
      private AbstractCollectionInterceptor interceptor_;
   
  -   public CachedSetImpl(PojoTreeCache cache, AbstractCollectionInterceptor interceptor)
  +   public CachedSetImpl(PojoCacheImpl cache, AbstractCollectionInterceptor interceptor)
      {
  -      this.cache_ = cache;
  +      pCache_ = cache;
  +      this.cache_ = (PojoTreeCache)pCache_.getCache();
         this.interceptor_ = interceptor;
      }
   
  @@ -92,7 +95,7 @@
   
         try
         {
  -         cache_.putObject(AopUtil.constructFqn(getFqn(), keyString), Null.toNullObject(o));
  +         pCache_.putObject(AopUtil.constructFqn(getFqn(), keyString), Null.toNullObject(o));
            return true;
         } catch (CacheException e)
         {
  @@ -214,7 +217,7 @@
   
            try
            {
  -            return Null.toNullValue(cache_.getObject(AopUtil.constructFqn(getFqn(), this.key)));
  +            return Null.toNullValue(pCache_.getObject(AopUtil.constructFqn(getFqn(), this.key)));
            } catch (CacheException e)
            {
               throw new RuntimeException(e);
  @@ -230,7 +233,7 @@
   
            try
            {
  -            cache_.removeObject(AopUtil.constructFqn(getFqn(), this.key));
  +            pCache_.removeObject(AopUtil.constructFqn(getFqn(), this.key));
            } catch (CacheException e)
            {
               throw new RuntimeException(e);
  
  
  
  1.5       +4 -3      JBossCache/src-50/org/jboss/cache/pojo/collection/CollectionInterceptorUtil.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CollectionInterceptorUtil.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CollectionInterceptorUtil.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- CollectionInterceptorUtil.java	7 Jul 2006 10:26:03 -0000	1.4
  +++ CollectionInterceptorUtil.java	13 Jul 2006 15:56:12 -0000	1.5
  @@ -16,6 +16,7 @@
   import org.jboss.aop.util.MethodHashing;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.pojo.PojoTreeCache;
  +import org.jboss.cache.pojo.impl.PojoCacheImpl;
   import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor;
   import org.jboss.cache.pojo.interceptors.dynamic.CachedListInterceptor;
   import org.jboss.cache.pojo.interceptors.dynamic.CachedMapInterceptor;
  @@ -49,17 +50,17 @@
         return result;
      }
   
  -   public static ClassProxy createMapProxy(PojoTreeCache cache, Fqn fqn, Class clazz, Map obj) throws Exception
  +   public static ClassProxy createMapProxy(PojoCacheImpl cache, Fqn fqn, Class clazz, Map obj) throws Exception
      {
         return CollectionInterceptorUtil.createProxy(clazz, new CachedMapInterceptor(cache, fqn, clazz, obj));
      }
   
  -   public static ClassProxy createListProxy(PojoTreeCache cache, Fqn fqn, Class clazz, List obj) throws Exception
  +   public static ClassProxy createListProxy(PojoCacheImpl cache, Fqn fqn, Class clazz, List obj) throws Exception
      {
         return CollectionInterceptorUtil.createProxy(clazz, new CachedListInterceptor(cache, fqn, clazz, obj));
      }
   
  -   public static ClassProxy createSetProxy(PojoTreeCache cache, Fqn fqn, Class clazz, Set obj) throws Exception
  +   public static ClassProxy createSetProxy(PojoCacheImpl cache, Fqn fqn, Class clazz, Set obj) throws Exception
      {
         return CollectionInterceptorUtil.createProxy(clazz, new CachedSetInterceptor(cache, fqn, clazz, obj));
      }
  
  
  



More information about the jboss-cvs-commits mailing list