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

Ben Wang bwang at jboss.com
Mon Oct 9 04:02:59 EDT 2006


  User: bwang   
  Date: 06/10/09 04:02:59

  Modified:    src/org/jboss/cache    Cache.java TreeCacheProxyImpl.java
                        Fqn.java
  Log:
  Added.
  
  Revision  Changes    Path
  1.8       +9 -3      JBossCache/src/org/jboss/cache/Cache.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Cache.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Cache.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- Cache.java	29 Aug 2006 11:54:10 -0000	1.7
  +++ Cache.java	9 Oct 2006 08:02:59 -0000	1.8
  @@ -134,13 +134,19 @@
      void evict(Fqn fqn, boolean recursive);
   
      /**
  -    * Retrieves a {@link Region} for a given {@link Fqn}.  If the region does not exist, one is created.
  +    * Retrieves a {@link Region} for a given {@link Fqn}.  If the region does not exist,
  +    * and <li>createIfAbsent</li> is true, then one is created.
  +    * Note that if there is parent Fqn that matches an existing region, the region will be
  +    * retrieved first. That is, we will do a recursive search for the matching region starting
  +    * from the root.
       *
  -    * @return a Region
  +    * @param fqn Fqn that is contained in a region.
  +    * @param createIfAbsent If true, will create a new associated region if not found.
  +    * @return a Region. Null if none is found.
       * @throws UnsupportedOperationException if the region cannot be defined.
       * @see Region
       */
  -   Region getRegion(Fqn fqn);
  +   Region getRegion(Fqn fqn, boolean createIfAbsent);
   
      /**
       * Lifecycle method
  
  
  
  1.40      +26 -4     JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCacheProxyImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -b -r1.39 -r1.40
  --- TreeCacheProxyImpl.java	24 Sep 2006 15:58:00 -0000	1.39
  +++ TreeCacheProxyImpl.java	9 Oct 2006 08:02:59 -0000	1.40
  @@ -48,6 +48,16 @@
         this.currentNode = currentNode;
      }
   
  +   /**
  +    * A temp solution untill we figure out how to extract the membership functionality from
  +    * TreeCache.
  +    * @return
  +    */
  +   public TreeCache getTreeCache()
  +   {
  +      return treeCache;
  +   }
  +
      public Configuration getConfiguration()
      {
         return treeCache.getConfiguration();
  @@ -247,15 +257,27 @@
         treeCache.evict(n.getFqn());
      }
   
  -   public Region getRegion(Fqn fqn)
  +   public Region getRegion(Fqn fqn, boolean createIfAbsent)
  +   {
  +      // loop thru children fqn to find the match first.
  +      // Or alternatively we can iterate thru the regionRegistry to
  +      // find the match.
  +      for(int i=0; i < fqn.size(); i++)
      {
  -      if (treeCache.regionsRegistry.containsKey(fqn))
  +         Fqn f = fqn.getFqnChild(i);
  +         if (treeCache.regionsRegistry.containsKey(f))
         {
  -         return treeCache.regionsRegistry.get(fqn);
  +            // first match is returned
  +            return treeCache.regionsRegistry.get(f);
         }
  -      else
  +      }
  +
  +      if(createIfAbsent)
         {
            return new RegionImpl(treeCache, fqn);
  +      } else
  +      {
  +         return null;
         }
      }
   
  
  
  
  1.38      +2 -2      JBossCache/src/org/jboss/cache/Fqn.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Fqn.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Fqn.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -b -r1.37 -r1.38
  --- Fqn.java	30 Aug 2006 17:08:19 -0000	1.37
  +++ Fqn.java	9 Oct 2006 08:02:59 -0000	1.38
  @@ -41,7 +41,7 @@
    * <p/>
    * Another way to look at it is that the "/" separarator is only parsed when it form sa  part of a String passed in to Fqn.fromString() and not otherwise.
    *
  - * @version $Revision: 1.37 $
  + * @version $Revision: 1.38 $
    */
   public class Fqn implements Cloneable, Externalizable
   {
  @@ -251,7 +251,7 @@
       */
      public Fqn getFqnChild(int index)
      {
  -      return createFqn(elements.subList(0, index));
  +      return createFqn(elements.subList(0, index+1));
      }
   
      /**
  
  
  



More information about the jboss-cvs-commits mailing list