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

Ben Wang bwang at jboss.com
Tue Jan 2 07:27:40 EST 2007


  User: bwang   
  Date: 07/01/02 07:27:40

  Modified:    src-50/org/jboss/cache/pojo/collection   
                        CachedListImpl.java CachedMapImpl.java
                        CachedSetImpl.java
  Log:
  JBCACHE-907 Fixed size() problem with loader.
  
  Revision  Changes    Path
  1.14      +4 -9      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.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- CachedListImpl.java	30 Dec 2006 17:49:53 -0000	1.13
  +++ CachedListImpl.java	2 Jan 2007 12:27:40 -0000	1.14
  @@ -25,6 +25,7 @@
   import java.util.List;
   import java.util.ListIterator;
   import java.util.NoSuchElementException;
  +import java.util.Set;
   
   /**
    * List implementation that uses cache as a backend store.
  @@ -52,11 +53,11 @@
      }
   
      // implementation of the java.util.List interface
  -   private Node getNode()
  +   private Set<Node> getNodeChildren()
      {
         try
         {
  -         return CacheApiUtil.getDataNode(cache_, getFqn());
  +         return CacheApiUtil.getNodeChildren(cache_, getFqn());
         }
         catch (Exception e)
         {
  @@ -105,13 +106,7 @@
   
      public int size()
      {
  -      Node node = getNode();
  -      if (node == null)
  -      {
  -         return 0;
  -      }
  -
  -      Collection<Node> children = node.getChildren();
  +      Set<Node> children = getNodeChildren();
         return children == null ? 0 : children.size();
      }
   
  
  
  
  1.17      +12 -18    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.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- CachedMapImpl.java	31 Dec 2006 02:08:42 -0000	1.16
  +++ CachedMapImpl.java	2 Jan 2007 12:27:40 -0000	1.17
  @@ -70,11 +70,11 @@
   
      // implementation of the java.util.Map interface
   
  -   private Node getNode()
  +   private Set<Node> getNodeChildren()
      {
         try
         {
  -         return CacheApiUtil.getDataNode(cache_, getFqn());
  +         return CacheApiUtil.getNodeChildren(cache_, getFqn());
         }
         catch (Exception e)
         {
  @@ -139,13 +139,7 @@
   
      public int size()
      {
  -      Node node = getNode();
  -      if (node == null)
  -      {
  -         return 0;
  -      }
  -
  -      Collection<Node> children = node.getChildren();
  +      Set<Node> children = getNodeChildren();
         return children == null ? 0 : children.size();
      }
   
  @@ -156,11 +150,11 @@
   
      public boolean containsKey(Object object)
      {
  -      Collection<Node> children = getNode().getChildren();
  +      Set<Node> children = getNodeChildren();
         if (children == null) return false;
  -      for (Node n : children)
  +      for (Object n : children)
         {
  -         if (n.getFqn().getLastElement().equals(Null.toNullKeyObject(object))) return true;
  +         if (((Node)n).getFqn().getLastElement().equals(Null.toNullKeyObject(object))) return true;
         }
   
         return false;
  @@ -180,13 +174,13 @@
   
            public int size()
            {
  -            Collection<Node> children = getNode().getChildren();
  +            Set<Node> children = getNodeChildren();
               return children == null ? 0 : children.size();
            }
   
            public Iterator iterator()
            {
  -            Collection<Node> children = getNode().getChildren();
  +            Set<Node> children = getNodeChildren();
               final Iterator i =
                       children == null
                               ? Collections.EMPTY_LIST.iterator()
  @@ -223,7 +217,7 @@
   
            public int size()
            {
  -            Collection<Node> children = getNode().getChildren();
  +            Set<Node> children = getNodeChildren();
               return children == null ? 0 : children.size();
            }
   
  @@ -234,7 +228,7 @@
   
            public Iterator iterator()
            {
  -            Collection<Node> children = getNode().getChildren();
  +            Set<Node> children = getNodeChildren();
               final Iterator i =
                       children == null
                               ? Collections.EMPTY_LIST.iterator()
  @@ -284,13 +278,13 @@
   
            public int size()
            {
  -            Collection<Node> children = getNode().getChildren();
  +            Set<Node> children = getNodeChildren();
               return children == null ? 0 : children.size();
            }
   
            public Iterator iterator()
            {
  -            Collection<Node> children = getNode().getChildren();
  +            Set<Node> children = getNodeChildren();
               final Iterator i =
                       children == null
                               ? Collections.EMPTY_LIST.iterator()
  
  
  
  1.14      +14 -13    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.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- CachedSetImpl.java	30 Dec 2006 17:49:53 -0000	1.13
  +++ CachedSetImpl.java	2 Jan 2007 12:27:40 -0000	1.14
  @@ -21,6 +21,7 @@
   import java.util.Collection;
   import java.util.Collections;
   import java.util.Iterator;
  +import java.util.Set;
   
   /**
    * Set implementation that uses a cache as an underlying backend store.
  @@ -49,9 +50,16 @@
         this.interceptor_ = interceptor;
      }
   
  -   private Node getNode()
  +   private Set<Node> getNodeChildren()
      {
  -      return CacheApiUtil.getDataNode(cache_, getFqn());
  +      try
  +      {
  +         return CacheApiUtil.getNodeChildren(cache_, getFqn());
  +      }
  +      catch (Exception e)
  +      {
  +         throw new RuntimeException(e);
  +      }
      }
   
      private Fqn getFqn()
  @@ -85,11 +93,7 @@
   
      public void clear()
      {
  -      Node node = getNode();
  -      if (node == null)
  -         return;
  -
  -      Collection<Node> children = node.getChildren();
  +      Set<Node> children = getNodeChildren();
         for (Node n : children)
         {
            pCache_.detach(n.getFqn());
  @@ -115,7 +119,7 @@
   
      public Iterator iterator()
      {
  -      Node node = getNode();
  +      Node node = cache_.getRoot().getChild(getFqn());
         if (node == null)
            return Collections.EMPTY_SET.iterator();
         return new IteratorImpl(node);
  @@ -152,11 +156,8 @@
   
      public int size()
      {
  -      Node node = getNode();
  -      if (node == null)
  -         return 0;
  -
  -      return node.getChildren().size();
  +      Set<Node> children = getNodeChildren();
  +      return (children == null)? 0: children.size();
      }
   
      public String toString()
  
  
  



More information about the jboss-cvs-commits mailing list