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

Jason Thomas Greene jgreene at jboss.com
Wed Jun 27 20:56:06 EDT 2007


  User: jgreene 
  Date: 07/06/27 20:56:06

  Modified:    src/org/jboss/cache/pojo/collection    CachedListImpl.java
                        CachedMapImpl.java CachedSetImpl.java
  Log:
  Reduce dependency on CacheSPI
  
  Revision  Changes    Path
  1.3       +18 -18    JBossCache/src/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/org/jboss/cache/pojo/collection/CachedListImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- CachedListImpl.java	31 May 2007 19:11:06 -0000	1.2
  +++ CachedListImpl.java	28 Jun 2007 00:56:06 -0000	1.3
  @@ -19,7 +19,7 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.jboss.cache.CacheSPI;
  +import org.jboss.cache.Cache;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.Node;
   import org.jboss.cache.pojo.impl.PojoCacheImpl;
  @@ -37,27 +37,27 @@
   public class CachedListImpl extends CachedListAbstract
   {
      private static Log log_ = LogFactory.getLog(CachedListImpl.class.getName());
  -   private CacheSPI cache_;
  -   private PojoCacheImpl pCache_;
  -   private AbstractCollectionInterceptor interceptor_;
  +   private Cache<Object, Object> cache;
  +   private PojoCacheImpl pojoCache;
  +   private AbstractCollectionInterceptor interceptor;
   
      public CachedListImpl(PojoCacheImpl cache, AbstractCollectionInterceptor interceptor)
      {
  -      pCache_ = cache;
  -      cache_ = (CacheSPI) pCache_.getCache();
  -      interceptor_ = interceptor;
  +      this.pojoCache = cache;
  +      this.cache = pojoCache.getCache();
  +      this.interceptor = interceptor;
      }
   
      private Fqn getFqn()
      {
  -      return interceptor_.getFqn();
  +      return interceptor.getFqn();
      }
   
      // implementation of the java.util.List interface
   
      private Set<Node> getNodeChildren()
      {
  -      return CacheApiUtil.getNodeChildren(cache_, getFqn());
  +      return CacheApiUtil.getNodeChildren(cache, getFqn());
      }
   
      /**
  @@ -76,7 +76,7 @@
      public Object get(int index)
      {
         checkIndex();
  -      return Null.toNullValue(pCache_.getObject(AopUtil.constructFqn(getFqn(), IntegerCache.toString(index))));
  +      return Null.toNullValue(pojoCache.getObject(AopUtil.constructFqn(getFqn(), IntegerCache.toString(index))));
      }
   
      private static void checkIndex()
  @@ -125,9 +125,9 @@
      private Object attach(int i, Object obj, String operation)
      {
         Fqn fqn = AopUtil.constructFqn(getFqn(), IntegerCache.toString(i));
  -      Object o = pCache_.attach(fqn, Null.toNullObject(obj));
  +      Object o = pojoCache.attach(fqn, Null.toNullObject(obj));
         if (operation != null)
  -         pCache_.getCache().put(fqn, POJOCACHE_OPERATION, operation);
  +         pojoCache.getCache().put(fqn, POJOCACHE_OPERATION, operation);
         
         return o;
      }
  @@ -141,8 +141,8 @@
      {
         Fqn fqn = AopUtil.constructFqn(getFqn(), IntegerCache.toString(i));
         if (operation != null)
  -         pCache_.getCache().put(fqn, POJOCACHE_OPERATION, operation);
  -      return pCache_.detach(fqn);
  +         pojoCache.getCache().put(fqn, POJOCACHE_OPERATION, operation);
  +      return pojoCache.detach(fqn);
      }
   
      public int indexOf(Object o)
  @@ -229,7 +229,7 @@
                  throw new NoSuchElementException("CachedSetImpl.iterator.next(). " +
                          " Cursor position " + current + " is greater than the size " + size());
   
  -            return Null.toNullValue(pCache_.getObject(AopUtil.constructFqn(getFqn(), IntegerCache.toString(++current))));
  +            return Null.toNullValue(pojoCache.getObject(AopUtil.constructFqn(getFqn(), IntegerCache.toString(++current))));
            }
   
            public void remove()
  
  
  
  1.3       +32 -35    JBossCache/src/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/org/jboss/cache/pojo/collection/CachedMapImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- CachedMapImpl.java	31 May 2007 19:11:06 -0000	1.2
  +++ CachedMapImpl.java	28 Jun 2007 00:56:06 -0000	1.3
  @@ -8,7 +8,18 @@
   
   import static org.jboss.cache.pojo.impl.InternalConstant.POJOCACHE_OPERATION;
   
  +import java.io.Serializable;
  +import java.util.AbstractCollection;
  +import java.util.AbstractSet;
  +import java.util.ArrayList;
  +import java.util.Collection;
  +import java.util.Collections;
  +import java.util.Iterator;
  +import java.util.Map;
  +import java.util.Set;
  +
   import org.jboss.aop.Advised;
  +import org.jboss.cache.Cache;
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.Node;
  @@ -19,16 +30,6 @@
   import org.jboss.cache.pojo.util.CacheApiUtil;
   import org.jboss.cache.pojo.util.Null;
   
  -import java.io.Serializable;
  -import java.util.AbstractCollection;
  -import java.util.AbstractSet;
  -import java.util.ArrayList;
  -import java.util.Collection;
  -import java.util.Collections;
  -import java.util.Iterator;
  -import java.util.Map;
  -import java.util.Set;
  -
   /**
    * Map that uses cache as a backend store.
    *
  @@ -38,19 +39,15 @@
   @Reentrant
   public class CachedMapImpl implements Map
   {
  -
  -//   protected static final Log log_ = LogFactory.getLog(CachedMapImpl.class);
  -
  -   private PojoCacheImpl pCache_;
  -   private CacheSPI cache_;
  -   private AbstractCollectionInterceptor interceptor_;
  +   private PojoCacheImpl pojoCache;
  +   private Cache<Object, Object> cache;
  +   private AbstractCollectionInterceptor interceptor;
   
      public CachedMapImpl(PojoCacheImpl pCache, AbstractCollectionInterceptor interceptor)
      {
  -      pCache_ = pCache;
  -      cache_ = (CacheSPI) pCache_.getCache();
  -      interceptor_ = interceptor;
  -
  +      this.pojoCache = pCache;
  +      this.cache = pojoCache.getCache();
  +      this.interceptor = interceptor;
      }
   
      private static Fqn constructFqn(Fqn baseFqn, Object relative)
  @@ -65,14 +62,14 @@
   
      private Fqn getFqn()
      {
  -      return interceptor_.getFqn();
  +      return interceptor.getFqn();
      }
      
      private Object attach(Object key, Object value)
      {
         Fqn fqn = constructFqn(getFqn(), Null.toNullKeyObject(key));
  -      Object o = pCache_.attach(fqn, Null.toNullObject(value));
  -      pCache_.getCache().put(fqn, POJOCACHE_OPERATION, "PUT");
  +      Object o = pojoCache.attach(fqn, Null.toNullObject(value));
  +      pojoCache.getCache().put(fqn, POJOCACHE_OPERATION, "PUT");
         
         return o;
      }
  @@ -80,21 +77,21 @@
      private Object detach(Object key)
      {
         Fqn fqn = constructFqn(getFqn(), Null.toNullKeyObject(key));
  -      pCache_.getCache().put(fqn, POJOCACHE_OPERATION, "REMOVE");
  +      pojoCache.getCache().put(fqn, POJOCACHE_OPERATION, "REMOVE");
         
  -      return pCache_.detach(fqn);
  +      return pojoCache.detach(fqn);
      }
   
      // implementation of the java.util.Map interface
   
      private Set<Node> getNodeChildren()
      {
  -      return CacheApiUtil.getNodeChildren(cache_, getFqn());
  +      return CacheApiUtil.getNodeChildren(cache, getFqn());
      }
   
      public Object get(Object key)
      {
  -      return Null.toNullValue(pCache_.getObject(constructFqn(getFqn(), Null.toNullKeyObject(key))));
  +      return Null.toNullValue(pojoCache.getObject(constructFqn(getFqn(), Null.toNullKeyObject(key))));
      }
   
      public Object put(Object key, Object value)
  @@ -236,7 +233,7 @@
                  {
                     Fqn f = ((Node) i.next()).getFqn();
                     lastKey = f.getLastElement();
  -                  return Null.toNullValue(pCache_.getObject(f));
  +                  return Null.toNullValue(pojoCache.getObject(f));
                  }
   
                  public void remove()
  @@ -371,7 +368,7 @@
   
         public Object getValue()
         {
  -         return Null.toNullValue(pCache_.getObject(constructFqn(getFqn(), key)));
  +         return Null.toNullValue(pojoCache.getObject(constructFqn(getFqn(), key)));
         }
   
         public Object setValue(Object value)
  
  
  
  1.3       +34 -35    JBossCache/src/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/org/jboss/cache/pojo/collection/CachedSetImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- CachedSetImpl.java	31 May 2007 19:11:06 -0000	1.2
  +++ CachedSetImpl.java	28 Jun 2007 00:56:06 -0000	1.3
  @@ -8,6 +8,14 @@
   
   import static org.jboss.cache.pojo.impl.InternalConstant.POJOCACHE_OPERATION;
   
  +import java.util.AbstractSet;
  +import java.util.Collection;
  +import java.util.Collections;
  +import java.util.HashSet;
  +import java.util.Iterator;
  +import java.util.Set;
  +
  +import org.jboss.cache.Cache;
   import org.jboss.cache.CacheException;
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Fqn;
  @@ -20,13 +28,6 @@
   import org.jboss.cache.pojo.util.CacheApiUtil;
   import org.jboss.cache.pojo.util.Null;
   
  -import java.util.AbstractSet;
  -import java.util.Collection;
  -import java.util.Collections;
  -import java.util.HashSet;
  -import java.util.Iterator;
  -import java.util.Set;
  -
   /**
    * Set implementation that uses a cache as an underlying backend store.
    * Set data is stored in children nodes named based on the attached Object's hash code
  @@ -41,28 +42,26 @@
   @Reentrant
   public class CachedSetImpl extends AbstractSet
   {
  -   //   protected static final Log log_=LogFactory.getLog(CachedSetImpl.class);
  -
  -   private PojoCacheImpl pCache_;
  -   private CacheSPI cache_;
  -   private AbstractCollectionInterceptor interceptor_;
  +   private PojoCacheImpl pojoCache;
  +   private Cache<Object, Object> cache;
  +   private AbstractCollectionInterceptor interceptor;
   
      public CachedSetImpl(PojoCacheImpl cache, AbstractCollectionInterceptor interceptor)
      {
  -      pCache_ = cache;
  -      this.cache_ = (CacheSPI) pCache_.getCache();
  -      this.interceptor_ = interceptor;
  +      this.pojoCache = cache;
  +      this.cache = pojoCache.getCache();
  +      this.interceptor = interceptor;
      }
   
      private Set<Node> getNodeChildren()
      {
  -      return CacheApiUtil.getNodeChildren(cache_, getFqn());
  +      return CacheApiUtil.getNodeChildren(cache, getFqn());
      }
   
      private Fqn getFqn()
      {
         // Cannot cache this as this can be reset
  -      return interceptor_.getFqn();
  +      return interceptor.getFqn();
      }
   
      // java.util.Set implementation
  @@ -95,7 +94,7 @@
         Set<Node> children = getNodeChildren();
         for (Node n : children)
         {
  -         pCache_.detach(n.getFqn());
  +         pojoCache.detach(n.getFqn());
         }
      }
   
  @@ -122,7 +121,7 @@
   
      public Iterator iterator()
      {
  -      Node node = cache_.getRoot().getChild(getFqn());
  +      Node node = cache.getRoot().getChild(getFqn());
         if (node == null)
         {
            return Collections.EMPTY_SET.iterator();
  @@ -200,9 +199,9 @@
      private Object attach(Object key, Object pojo, boolean add)
      {
         Fqn fqn = AopUtil.constructFqn(getFqn(), key);
  -      Object o = pCache_.attach(fqn, pojo);
  +      Object o = pojoCache.attach(fqn, pojo);
         if (add)
  -         pCache_.getCache().put(fqn, POJOCACHE_OPERATION, "ADD");
  +         pojoCache.getCache().put(fqn, POJOCACHE_OPERATION, "ADD");
         
         return o;
      }
  @@ -216,21 +215,21 @@
      {
         Fqn fqn = AopUtil.constructFqn(getFqn(), key);
         if (remove)
  -         pCache_.getCache().put(fqn, POJOCACHE_OPERATION, "REMOVE");
  +         pojoCache.getCache().put(fqn, POJOCACHE_OPERATION, "REMOVE");
         
  -      return pCache_.detach(fqn);
  +      return pojoCache.detach(fqn);
      }
      
      private Object getNoUnmask(Object key)
      {
  -      return pCache_.getObject(AopUtil.constructFqn(getFqn(), key));
  +      return pojoCache.getObject(AopUtil.constructFqn(getFqn(), key));
      }
   
      public int hashCode()
      {
         int result = super.hashCode();
  -      result = 29 * result + cache_.hashCode();
  -      result = 29 * result + interceptor_.hashCode();
  +      result = 29 * result + cache.hashCode();
  +      result = 29 * result + interceptor.hashCode();
         return result;
      }
   
  @@ -276,7 +275,7 @@
         public Object next()
         {
            node = iterator.next();
  -         o = Null.toNullValue(pCache_.getObject(node.getFqn()));
  +         o = Null.toNullValue(pojoCache.getObject(node.getFqn()));
            return o;
         }
   
  
  
  



More information about the jboss-cvs-commits mailing list