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

Manik Surtani msurtani at jboss.com
Wed Oct 18 07:07:54 EDT 2006


  User: msurtani
  Date: 06/10/18 07:07:54

  Modified:    src/org/jboss/cache          TreeCache.java
                        AbstractCacheListener.java ConsoleListener.java
                        CacheSPI.java TreeCacheView.java Cache.java
                        TreeCacheView2.java CacheListener.java
                        RegionManager.java
  Log:
  * added more tests for the move() API
  * added a nodeMoved listener event
  * moved some methods from CacheSPI to Cache
  
  Revision  Changes    Path
  1.253     +4 -4      JBossCache/src/org/jboss/cache/TreeCache.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCache.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCache.java,v
  retrieving revision 1.252
  retrieving revision 1.253
  diff -u -b -r1.252 -r1.253
  --- TreeCache.java	12 Oct 2006 23:03:57 -0000	1.252
  +++ TreeCache.java	18 Oct 2006 11:07:54 -0000	1.253
  @@ -91,7 +91,7 @@
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    * @author Brian Stansberry
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Id: TreeCache.java,v 1.252 2006/10/12 23:03:57 msurtani Exp $
  + * @version $Id: TreeCache.java,v 1.253 2006/10/18 11:07:54 msurtani Exp $
    *          <p/>
    * @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
    */
  @@ -1077,7 +1077,7 @@
         {
            log.error("failed to activate " + subtreeFqn, t);
   
  -         // "Re-inactivate" the region
  +         // "Re-deactivate" the region
            try
            {
               inactivateRegion(subtreeFqn);
  @@ -1224,7 +1224,7 @@
      {
         if (!configuration.isUseRegionBasedMarshalling())
         {
  -         throw new IllegalStateException("TreeCache.inactivate(). useRegionBasedMarshalling flag is not set!");
  +         throw new IllegalStateException("TreeCache.deactivate(). useRegionBasedMarshalling flag is not set!");
         }
   
         Fqn fqn = Fqn.fromString(subtreeFqn);
  @@ -1240,7 +1240,7 @@
            boolean inactive = marshaller_.isInactive(subtreeFqn);
            if (!inactive)
            {
  -            regionManager.inactivate(subtreeFqn);
  +            regionManager.deactivate(subtreeFqn);
            }
   
            // Create a list with the Fqn in the main tree and any buddy backup trees
  
  
  
  1.2       +47 -43    JBossCache/src/org/jboss/cache/AbstractCacheListener.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AbstractCacheListener.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/AbstractCacheListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- AbstractCacheListener.java	18 Jul 2006 10:50:46 -0000	1.1
  +++ AbstractCacheListener.java	18 Oct 2006 11:07:54 -0000	1.2
  @@ -43,6 +43,10 @@
       {
       }
   
  +   public void nodeMoved(Fqn from, Fqn to, boolean pre)
  +   {
  +   }
  +
       public void nodeActivated(Fqn fqn, boolean pre)
       {
       }
  
  
  
  1.10      +12 -0     JBossCache/src/org/jboss/cache/ConsoleListener.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConsoleListener.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/ConsoleListener.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- ConsoleListener.java	6 Sep 2006 15:30:55 -0000	1.9
  +++ ConsoleListener.java	18 Oct 2006 11:07:54 -0000	1.10
  @@ -147,6 +147,18 @@
   
      }
   
  +   public void nodeMoved(Fqn from, Fqn to, boolean pre)
  +   {
  +      if (pre)
  +      {
  +         printEvent("About to move " + from + " to " + to);
  +      }
  +      else
  +      {
  +         printEvent("Moved " + from + " to " + to);
  +      }
  +   }
  +
      public void nodeVisited(Fqn fqn, boolean pre)
      {
         if (pre) printEvent("DataNode visited: " + fqn);
  
  
  
  1.18      +0 -10     JBossCache/src/org/jboss/cache/CacheSPI.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheSPI.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheSPI.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- CacheSPI.java	12 Oct 2006 23:03:57 -0000	1.17
  +++ CacheSPI.java	18 Oct 2006 11:07:54 -0000	1.18
  @@ -15,7 +15,6 @@
   import org.jboss.cache.statetransfer.StateTransferManager;
   import org.jgroups.Address;
   
  -import javax.transaction.TransactionManager;
   import java.util.List;
   import java.util.Map;
   
  @@ -111,8 +110,6 @@
      // that is used by either an interceptor, or eviction policy
      // should be added to this interface, provided they are public.
   
  -   TransactionManager getTransactionManager();
  -
      ReplicationQueue getReplQueue();
   
      int getNumberOfAttributes();
  @@ -134,11 +131,4 @@
       * that is responsible for emitting notifications to registered {@link CacheListener}s.
       */
      Notifier getNotifier();
  -
  -   /**
  -    * Retrieves the current invocation context for the current invocation.
  -    */
  -   InvocationContext getInvocationContext();
  -
  -   void setInvocationContext(InvocationContext ctx);
   }
  
  
  
  1.16      +5 -1      JBossCache/src/org/jboss/cache/TreeCacheView.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCacheView.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheView.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -b -r1.15 -r1.16
  --- TreeCacheView.java	12 Oct 2006 23:03:57 -0000	1.15
  +++ TreeCacheView.java	18 Oct 2006 11:07:54 -0000	1.16
  @@ -53,7 +53,7 @@
    * The view itself caches only the nodes, but doesn't cache any of the data (HashMap) associated with it. When
    * data needs to be displayed, the underlying tree will be accessed directly.
    *
  - * @version $Revision: 1.15 $
  + * @version $Revision: 1.16 $
    * @author<a href="mailto:bela at jboss.org">Bela Ban</a> March 27 2003
    */
   public class TreeCacheView implements TreeCacheViewMBean
  @@ -583,6 +583,10 @@
         nodeCreated(fqn, pre, false);
      }
   
  +   public void nodeMoved(Fqn from, Fqn to, boolean pre)
  +   {
  +   }
  +
      public void nodeActivated(Fqn fqn, boolean pre)
      {
      }
  
  
  
  1.11      +21 -0     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.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- Cache.java	12 Oct 2006 23:03:57 -0000	1.10
  +++ Cache.java	18 Oct 2006 11:07:54 -0000	1.11
  @@ -8,6 +8,7 @@
   
   import org.jboss.cache.config.Configuration;
   
  +import javax.transaction.TransactionManager;
   import java.util.List;
   import java.util.Map;
   import java.util.Set;
  @@ -168,4 +169,24 @@
       */
      void destroy();
   
  +   /**
  +    * Retrieves a reference to a running {@link javax.transaction.TransactionManager}, if one is configured.
  +    *
  +    * @return a TransactionManager
  +    */
  +   TransactionManager getTransactionManager();
  +
  +   /**
  +    * Retrieves the current invocation context for the current invocation and cache instance.
  +    *
  +    * @see org.jboss.cache.InvocationContext
  +    */
  +   InvocationContext getInvocationContext();
  +
  +   /**
  +    * Sets the passed in {@link org.jboss.cache.InvocationContext} as current.
  +    *
  +    * @param ctx
  +    */
  +   void setInvocationContext(InvocationContext ctx);
   }
  
  
  
  1.17      +6 -1      JBossCache/src/org/jboss/cache/TreeCacheView2.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCacheView2.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheView2.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- TreeCacheView2.java	29 Sep 2006 04:03:26 -0000	1.16
  +++ TreeCacheView2.java	18 Oct 2006 11:07:54 -0000	1.17
  @@ -53,7 +53,7 @@
    * The view itself caches only the nodes, but doesn't cache any of the data (HashMap) associated with it. When
    * data needs to be displayed, the underlying tree will be accessed directly.
    *
  - * @version $Revision: 1.16 $
  + * @version $Revision: 1.17 $
    */
   public class TreeCacheView2
   {
  @@ -513,6 +513,10 @@
         nodeCreated(fqn, pre, true);
      }
   
  +   public void nodeMoved(Fqn from, Fqn to, boolean pre)
  +   {
  +   }
  +
      public void nodeActivated(Fqn fqn, boolean pre)
      {
      }
  @@ -890,6 +894,7 @@
      /* -------------------------- End of Private Methods ------------------------------ */
   
      /*----------------------- Actions ---------------------------*/
  +
      class ExitAction extends AbstractAction
      {
         private static final long serialVersionUID = -5364163916172148038L;
  
  
  
  1.3       +110 -94   JBossCache/src/org/jboss/cache/CacheListener.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheListener.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheListener.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- CacheListener.java	18 Jul 2006 10:50:46 -0000	1.2
  +++ CacheListener.java	18 Oct 2006 11:07:54 -0000	1.3
  @@ -12,12 +12,12 @@
   
   /**
    * A litener API where listeners can be attached to a running {@link Cache} so users can be notified of {@link Cache} events.
  - *
  + * <p/>
    * // TODO: Question:  How should this behave WRT transactions?  Should callbacks occur after a tx commits, or as the invocations are made?
    *
  + * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    * @see Cache
    * @since 2.0.0
  - * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    */
   public interface CacheListener
   {
  @@ -33,7 +33,7 @@
       /**
        * Called before and after a {@link Node} is modified.  Data passed in is
        * always an unmodifiable {@link Map} of the data in the {@link Node}.
  -     *
  +    * <p/>
        * When called with pre=true, this is the initial state of the {@link Node} before
        * modification.  When called with pre=false, this is the new state of the
        * {@link Node}.
  @@ -47,7 +47,7 @@
       /**
        * Called before and after a {@link Node} is removed.  Data passed in is
        * always an unmodifiable {@link Map} of the data in the {@link Node}.
  -     *
  +    * <p/>
        * When called with pre=true, this is the initial state of the {@link Node} before
        * removal.  When called with pre=false, this is null.
        *
  @@ -59,6 +59,7 @@
   
       /**
        * Called when a {@link Node} is visisted, i.e., {@link Node#get(Object)} is called.
  +    *
        * @param fqn
        */
       void nodeVisited(Fqn fqn, boolean pre);
  @@ -74,15 +75,26 @@
   
       /**
        * Called when a {@link Node} is loaded into memory via a {@link org.jboss.cache.loader.CacheLoader}. This is not the same
  -     * as {@link #nodeCreated(Fqn, boolean, boolean)}.
  -     *
  +    * as {@link #nodeCreated(Fqn,boolean,boolean)}.
  +    * <p/>
        * The data passed in is an unmodifiable {@link Map}.  If the {@link Node} is loaded but the data isn't
        * (for example when calling {@link Node#getChildren()}) the data map is null.
        */
       void nodeLoaded(Fqn fqn, boolean pre, Map data);
   
       /**
  +    * Called when a {@link Node} is moved using the {@link Node#move(Node)} API.
  +    *
  +    * @param from
  +    * @param to
  +    * @param pre
  +    * @see org.jboss.cache.Node#move(Node)
  +    */
  +   void nodeMoved(Fqn from, Fqn to, boolean pre);
  +
  +   /**
        * Called when a {@link Node} is activated.
  +    *
        * @param fqn
        * @param pre
        */
  @@ -90,6 +102,7 @@
   
       /**
        * Called when a {@link Node} is passivated.
  +    *
        * @param fqn
        * @param pre
        */
  @@ -97,12 +110,14 @@
   
       /**
        * Called when the {@link Cache} is started.
  +    *
        * @param cache
        */
       void cacheStarted(CacheSPI cache);
   
       /**
        * Called when the {@link Cache} is stopped.
  +    *
        * @param cache
        */
       void cacheStopped(CacheSPI cache);
  @@ -110,6 +125,7 @@
       /**
        * // TODO: Perhaps move this to a new ClusterListener?
        * // TODO: Should we break the JGroups dependency and just pass a List of new members?
  +    *
        * @param new_view
        */
       void viewChange(View new_view);  // might be MergeView after merging
  
  
  
  1.3       +114 -7    JBossCache/src/org/jboss/cache/RegionManager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RegionManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/RegionManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- RegionManager.java	13 Oct 2006 14:53:28 -0000	1.2
  +++ RegionManager.java	18 Oct 2006 11:07:54 -0000	1.3
  @@ -67,6 +67,17 @@
   
      }
   
  +   /**
  +    * Overloaded form of {@link #setContextClassLoaderAsCurrent(Fqn)}
  +    *
  +    * @param fqn
  +    * @see #setContextClassLoaderAsCurrent(Fqn)
  +    */
  +   public void setContextClassLoaderAsCurrent(String fqn)
  +   {
  +      setContextClassLoaderAsCurrent(Fqn.fromString(fqn));
  +   }
  +
      public Region getRegion(Fqn fqn, boolean createIfAbsent)
      {
         // first see if a region for this specific Fqn exists
  @@ -95,6 +106,18 @@
   
      }
   
  +   /**
  +    * Overloaded form of {@link #getRegion(Fqn,boolean)}
  +    *
  +    * @param fqn
  +    * @param createIfAbsent
  +    * @see #getRegion(Fqn,boolean)
  +    */
  +   public Region getRegion(String fqn, boolean createIfAbsent)
  +   {
  +      return getRegion(Fqn.fromString(fqn), createIfAbsent);
  +   }
  +
      public void registerClassLoader(Fqn fqn, ClassLoader cl)
      {
         Region existing = getRegion(fqn, false);
  @@ -105,27 +128,61 @@
         existing.registerContextClassLoader(cl);
      }
   
  +   /**
  +    * Overloaded form of {@link #registerClassLoader(Fqn,ClassLoader)}
  +    *
  +    * @param fqn
  +    * @see #registerClassLoader(Fqn,ClassLoader)
  +    */
  +   public void registerClassLoader(String fqn, ClassLoader cl)
  +   {
  +      registerClassLoader(Fqn.fromString(fqn), cl);
  +   }
  +
  +   /**
  +    * Overloaded form of {@link #unregisterClassLoader(Fqn)}
  +    *
  +    * @param fqn
  +    * @see #unregisterClassLoader(Fqn)
  +    */
      public void unregisterClassLoader(Fqn fqn)
      {
         Region region = getRegion(fqn, false);
         if (region != null) region.unregisterContextClassLoader();
      }
   
  +
  +   public void unregisterClassLoader(String fqn)
  +   {
  +      unregisterClassLoader(Fqn.fromString(fqn));
  +   }
  +
      public void removeRegion(Fqn fqn)
      {
         regionsRegistry.remove(fqn);
      }
   
  +
  +   /**
  +    * Overloaded form of {@link #removeRegion(Fqn)}
  +    *
  +    * @param fqn
  +    * @see #removeRegion(Fqn)
  +    */
  +   public void removeRegion(String fqn)
  +   {
  +      removeRegion(Fqn.fromString(fqn));
  +   }
  +
      /**
       * Activates unmarshalling of replication messages for the region
       * rooted in the given Fqn.
       *
  -    * @param fqnStr
  +    * @param fqn
       */
  -   public void activate(String fqnStr)
  +   public void activate(Fqn fqn)
      {
  -      if (log.isTraceEnabled()) log.trace("Activating region " + fqnStr);
  -      Fqn fqn = Fqn.fromString(fqnStr);
  +      if (log.isTraceEnabled()) log.trace("Activating region " + fqn);
         Region r = getRegion(fqn, false);
         if (r != null)
         {
  @@ -148,20 +205,42 @@
         }
      }
   
  +   /**
  +    * Overloaded form of {@link #activate(Fqn)}
  +    *
  +    * @param fqn
  +    * @see #activate(Fqn)
  +    */
  +   public void activate(String fqn)
  +   {
  +      activate(Fqn.fromString(fqn));
  +   }
  +
  +
      public boolean hasRegion(Fqn fqn)
      {
         return regionsRegistry.containsKey(fqn);
      }
   
      /**
  +    * Overloaded form of {@link #hasRegion(Fqn)}
  +    *
  +    * @param fqn
  +    * @see #hasRegion(Fqn)
  +    */
  +   public boolean hasRegion(String fqn)
  +   {
  +      return hasRegion(Fqn.fromString(fqn));
  +   }
  +
  +   /**
       * Disables unmarshalling of replication messages for the region
       * rooted in the given Fqn.
       *
  -    * @param fqnStr
  +    * @param fqn
       */
  -   public void inactivate(String fqnStr)
  +   public void deactivate(Fqn fqn)
      {
  -      Fqn fqn = Fqn.fromString(fqnStr);
         Region region = getRegion(fqn, false);
   
         if (region != null)
  @@ -185,6 +264,19 @@
      }
   
      /**
  +    * Overloaded form of {@link #deactivate(Fqn)}
  +    *
  +    * @param fqn
  +    * @see #deactivate(Fqn)
  +    */
  +   public void deactivate(String fqn)
  +   {
  +      deactivate(Fqn.fromString(fqn));
  +   }
  +
  +   /**
  +    * Note that the ordered list returned is sorted according to the natural order defined in the {@link Comparable} interface, which {@link org.jboss.cache.Region} extends.
  +    *
       * @return an ordered list of all active regions with registered context class loaders.
       */
      public List<Region> getAllMarshallingRegions()
  @@ -198,4 +290,19 @@
         return regions;
      }
   
  +   /**
  +    * Note that the ordered list returned is sorted according to the natural order defined in the {@link Comparable} interface, which {@link org.jboss.cache.Region} extends.
  +    *
  +    * @return an ordered list of all regions, regardless of whether they are active, have eviction policies defined or have class loaders set.
  +    */
  +   public List<Region> getAllRegions()
  +   {
  +      List<Region> regions = new ArrayList<Region>(regionsRegistry.values());
  +
  +      Collections.sort(regions);
  +
  +      return regions;
  +   }
  +
  +
   }
  
  
  



More information about the jboss-cvs-commits mailing list