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

Manik Surtani msurtani at jboss.com
Wed Aug 16 06:52:51 EDT 2006


  User: msurtani
  Date: 06/08/16 06:52:51

  Modified:    src/org/jboss/cache        CacheSPI.java
                        ConsoleListener.java NodeImpl.java TreeCache.java
                        TreeCacheProxyImpl.java TreeCacheView.java
                        TreeCacheView2.java
  Log:
  fixed simple notification events
  
  Revision  Changes    Path
  1.7       +3 -0      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.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- CacheSPI.java	15 Aug 2006 21:02:23 -0000	1.6
  +++ CacheSPI.java	16 Aug 2006 10:52:51 -0000	1.7
  @@ -13,6 +13,7 @@
   import org.jboss.cache.loader.CacheLoader;
   import org.jboss.cache.loader.CacheLoaderManager;
   import org.jboss.cache.statetransfer.StateTransferManager;
  +import org.jboss.cache.notifications.Notifier;
   import org.jgroups.Address;
   import org.jgroups.blocks.MethodCall;
   
  @@ -149,4 +150,6 @@
   
       List _gravitateData(Fqn fqn, boolean b, boolean b1);
   
  +    Notifier getNotifier();
  +
   }
  
  
  
  1.8       +1 -1      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.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- ConsoleListener.java	20 Jul 2006 11:48:25 -0000	1.7
  +++ ConsoleListener.java	16 Aug 2006 10:52:51 -0000	1.8
  @@ -88,7 +88,7 @@
       public void listen(boolean wait)
       throws Exception
       {
  -        _cache.addTreeCacheListener(this);
  +        _cache.getNotifier().addCacheListener(this);
   
           if (_startCache)
           {
  
  
  
  1.4       +2 -1      JBossCache/src/org/jboss/cache/NodeImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/NodeImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- NodeImpl.java	14 Aug 2006 17:52:35 -0000	1.3
  +++ NodeImpl.java	16 Aug 2006 10:52:51 -0000	1.4
  @@ -270,6 +270,7 @@
                // after acquiring exclusive lock
                child = (NodeImpl)children().get(child_name);
                if (child == null) {
  +                 cache.getNotifier().notifyNodeCreated(child.getFqn(), true);
                    child = newChild;
                    children.put(child_name, child);
                    if(gtx != null) {
  @@ -288,7 +289,7 @@
                if (trace) {
                    log.trace("created child: fqn=" + child_fqn);
                }
  -             cache.notifyNodeCreated(child.getFqn());
  +             cache.getNotifier().notifyNodeCreated(child.getFqn(), false);
            }
         }
         return child;
  
  
  
  1.214     +59 -344   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.213
  retrieving revision 1.214
  diff -u -b -r1.213 -r1.214
  --- TreeCache.java	15 Aug 2006 21:02:23 -0000	1.213
  +++ TreeCache.java	16 Aug 2006 10:52:51 -0000	1.214
  @@ -38,6 +38,7 @@
   import org.jboss.cache.optimistic.DataVersion;
   import org.jboss.cache.statetransfer.StateTransferManager;
   import org.jboss.cache.util.MBeanConfigurator;
  +import org.jboss.cache.notifications.Notifier;
   import org.jboss.invocation.MarshalledValueOutputStream;
   import org.jboss.system.ServiceMBeanSupport;
   import org.jgroups.*;
  @@ -73,7 +74,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.213 2006/08/15 21:02:23 msurtani Exp $
  + * @version $Id: TreeCache.java,v 1.214 2006/08/16 10:52:51 msurtani Exp $
    *          <p/>
    * @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
    */
  @@ -91,28 +92,6 @@
       */
      protected DataNode root = NodeFactory.getInstance().createRootDataNode(NodeFactory.NODE_TYPE_TREENODE, this);
   
  -   /**
  -    * Set of TreeCacheListener.
  -    *
  -    * @see #addTreeCacheListener
  -    */
  -   private final Set<CacheListener> listeners = new CopyOnWriteArraySet();
  -
  -   // calling iterator on a ConcurrentHashMap is expensive due to synchronization - same problem
  -   // with calling isEmpty so hasListeners is an optimization to indicate whether or not listeners
  -   // is empty
  -   //
  -   /**
  -    * True if listeners are initialized.
  -    */
  -   protected boolean hasListeners = false;
  -
  -   // store this seperately from other listeners to avoid concurrency penalty of
  -   // iterating through ConcurrentHashMap - eviction listener is always there (or almost always)
  -   // and there are less frequently other listeners so optimization is justified
  -   //
  -   CacheListener evictionPolicyListener = null;
  -
      final static Object NULL = new Object();
   
      /**
  @@ -254,6 +233,7 @@
   
      /** State transfer manager. Do not access this field directly -- use the getter */
      private StateTransferManager stateTransferManager;
  +   private Notifier notifier;
   
      public StateTransferManager getStateTransferManager()
      {
  @@ -575,54 +555,6 @@
            log.debug("fetchState(): state could not be retrieved (first member)");
      }
   
  -   /**
  -    * Sets the eviction listener.
  -    */
  -   public void setEvictionListener(CacheListener listener)
  -   {
  -      evictionPolicyListener = listener;
  -   }
  -
  -   /**
  -    * Adds a tree cache listener.
  -    */
  -   public void addTreeCacheListener(CacheListener listener)
  -   {
  -      // synchronize on listenrs just to
  -      // ensure hasListeners is set correctly
  -      // based on possibility of concurrent adds/removes
  -      //
  -      synchronized (listeners)
  -      {
  -         listeners.add(listener);
  -         hasListeners = true;
  -      }
  -   }
  -
  -   /**
  -    * Removes a tree cache listener.
  -    */
  -   public void removeTreeCacheListener(CacheListener listener)
  -   {
  -      // synchronize on listenrs just to
  -      // ensure hasListeners is set correctly
  -      // based on possibility of concurrent adds/removes
  -      //
  -      synchronized (listeners)
  -      {
  -         listeners.remove(listener);
  -         hasListeners = !listeners.isEmpty();
  -      }
  -   }
  -
  -   /**
  -    * Returns a collection containing the listeners of this tree cache.
  -    */
  -   public Set getTreeCacheListeners()
  -   {
  -      return Collections.unmodifiableSet(listeners);
  -   }
  -
      /* --------------------------- MBeanSupport ------------------------- */
   
      /**
  @@ -637,6 +569,7 @@
   
      protected void _createService() throws Exception
      {
  +       notifier = new Notifier();
          stateFetchTimeout = configuration.getLockAcquisitionTimeout() + 5000;
          if (configuration.isNodeLockingOptimistic()) root = NodeFactory.getInstance().createRootDataNode(NodeFactory.NODE_TYPE_OPTIMISTIC_NODE, this);
          setUseReplQueue(configuration.isUseReplQueue());
  @@ -794,7 +727,7 @@
         }
   
         coordinator = determineCoordinator();
  -      notifyCacheStarted();
  +      notifier.notifyCacheStarted(getCacheSPI());
         started = true;
      }
   
  @@ -849,13 +782,8 @@
            cacheLoaderManager.stopCacheLoader();
         }
   
  -      notifyCacheStopped();
  -
  -      // Need to clean up listeners as well
  -      listeners.clear();
  -      hasListeners = false;
  -
  -      evictionPolicyListener = null;
  +      notifier.notifyCacheStopped(getCacheSPI());
  +      notifier.removeAllCacheListeners();
   
         useCreateService = false;
         started = false;
  @@ -1919,10 +1847,10 @@
         if (log.isTraceEnabled())
            log.trace(new StringBuffer("_get(").append("\"").append(fqn).append("\", ").append(key).append(", \"").
               append(sendNodeEvent).append("\")"));
  +      if (sendNodeEvent) notifier.notifyNodeVisited(fqn, true);
         DataNode n = findNode(fqn);
         if (n == null) return null;
  -      if (sendNodeEvent)
  -         notifyNodeVisited(fqn);
  +      if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false);
         return n.get(key);
      }
   
  @@ -2791,7 +2719,8 @@
               log.trace(errStr);
            throw new NodeNotExistsException(errStr);
         }
  -      notifyNodeModify(fqn, true);
  +      notifier.notifyNodeModified(fqn, true, Collections.unmodifiableMap(n.getData()));
  +
         // TODO: move creation of undo-operations to separate Interceptor
         // create a compensating method call (reverting the effect of
         // this modification) and put it into the TX's undo list.
  @@ -2820,8 +2749,8 @@
            // 1. put undo-op in TX' undo-operations list (needed to rollback TX)
            tx_table.addUndoOperation(tx, undo_op);
         }
  -      notifyNodeModified(fqn);
  -      notifyNodeModify(fqn, false);
  +
  +      notifier.notifyNodeModified(fqn, false, Collections.unmodifiableMap(n.getData()));
      }
   
      /**
  @@ -2863,7 +2792,7 @@
            throw new NodeNotExistsException(errStr);
         }
   
  -      notifyNodeModify(fqn, true);
  +      notifier.notifyNodeModified(fqn, true, Collections.unmodifiableMap(n.getData()));
         old_value = n.put(key, value);
   
         // create a compensating method call (reverting the effect of
  @@ -2885,8 +2814,7 @@
            tx_table.addUndoOperation(tx, undo_op);
         }
   
  -      notifyNodeModified(fqn);
  -      notifyNodeModify(fqn, false);
  +      notifier.notifyNodeModified(fqn, false, Collections.unmodifiableMap(n.getData()));
         return old_value;
      }
   
  @@ -2991,10 +2919,11 @@
               log.trace("node " + fqn + " not found");
            return;
         }
  -      if (sendNodeEvent)
  -         notifyNodeRemove(fqn, true);
  +
  +      if (eviction)
  +        notifier.notifyNodeEvicted(fqn, true);
         else
  -         notifyNodeEvict(fqn, true);
  +        notifier.notifyNodeRemoved(fqn, true, Collections.unmodifiableMap(n.getData()));
   
         parent_node = n.getParent();
   
  @@ -3016,16 +2945,10 @@
            tx_table.addUndoOperation(tx, undo_op);
         }
   
  -      if (sendNodeEvent)
  -      {
  -         notifyNodeRemoved(fqn);
  -         notifyNodeRemove(fqn, false);
  -      }
  +       if (eviction)
  +         notifier.notifyNodeEvicted(fqn, false);
         else
  -      {
  -         notifyNodeEvicted(fqn);
  -         notifyNodeEvict(fqn, false);
  -      }
  +         notifier.notifyNodeRemoved(fqn, false, null);
      }
   
      /**
  @@ -3066,7 +2989,9 @@
            log.warn("node " + fqn + " not found");
            return null;
         }
  -      notifyNodeModify(fqn, true);
  +
  +      notifier.notifyNodeModified(fqn, true, Collections.unmodifiableMap(n.getData()));
  +
         old_value = n.remove(key);
   
         // create a compensating method call (reverting the effect of
  @@ -3080,8 +3005,7 @@
            tx_table.addUndoOperation(tx, undo_op);
         }
   
  -      notifyNodeModified(fqn); // changed from notifyNodeRemoved() - Jimmy Wilson
  -      notifyNodeModify(fqn, false);
  +      notifier.notifyNodeModified(fqn, false, Collections.unmodifiableMap(n.getData()));
         return old_value;
      }
   
  @@ -3151,9 +3075,9 @@
         }
   
         if (eviction)
  -         notifyNodeEvict(fqn, true);
  +         notifier.notifyNodeEvicted(fqn, true);
         else
  -         notifyNodeModify(fqn, true);
  +         notifier.notifyNodeModified(fqn, true, Collections.unmodifiableMap(n.getData()));
   
         n.clear();
         if (eviction)
  @@ -3161,19 +3085,17 @@
   
         if (sendNodeEvent)
         {
  -         notifyNodeVisited(fqn);
  +         notifier.notifyNodeVisited(fqn, false);
         }
         else
         { // FIXME Bela did this so GUI view can refresh the view after node is evicted. But this breaks eviction policy, especially AOP!!!!
            if (eviction)
            {
  -            notifyNodeEvicted(fqn);
  -            notifyNodeEvict(fqn, false);
  +            notifier.notifyNodeEvicted(fqn, false);
            }
            else
            {
  -            notifyNodeModified(fqn); // todo: merge these 2 notifications back into 1 !
  -            notifyNodeModify(fqn, false);
  +            notifier.notifyNodeModified(fqn, false, Collections.unmodifiableMap(n.getData()));
            }
         }
   
  @@ -3254,16 +3176,16 @@
      /**
       * Compensating method to {@link #_remove(GlobalTransaction,Fqn,boolean)}.
       */
  -   public void _addChild(GlobalTransaction tx, Fqn parent_fqn, Object child_name, DataNode old_node)
  +   public void _addChild(GlobalTransaction gtx, Fqn parent_fqn, Object child_name, DataNode childNode)
         throws CacheException
      {
         if (log.isTraceEnabled())
  -         log.trace(new StringBuffer("_addChild(").append(tx).append(", \"").append(parent_fqn).
  +         log.trace(new StringBuffer("_addChild(").append("\"").append(parent_fqn).
               append("\", \"").append(child_name).append("\")"));
   
  -      if (parent_fqn == null || child_name == null || old_node == null)
  +      if (parent_fqn == null || child_name == null || childNode == null)
         {
  -         log.error("parent_fqn or child_name or node was null");
  +         log.error("parent_fqn or child_name or childNode was null");
            return;
         }
         DataNode tmp = findNode(parent_fqn);
  @@ -3272,8 +3194,11 @@
            log.warn("node " + parent_fqn + " not found");
            return;
         }
  -      tmp.addChild(child_name, old_node);
  -      notifyNodeCreated(new Fqn(parent_fqn, child_name));
  +
  +      Fqn fqn = new Fqn(parent_fqn, child_name);
  +      notifier.notifyNodeCreated(fqn, true);
  +      tmp.addChild(child_name, childNode);
  +      notifier.notifyNodeCreated(fqn, false);
      }
   
   
  @@ -3652,6 +3577,14 @@
           return new TreeCacheProxyImpl(this, (NodeImpl) root);
       }
   
  +    /**
  +     * @return an instance of {@link Notifier} which has been configured with this instance of TreeCache.
  +     */
  +    public Notifier getNotifier()
  +    {
  +        return notifier;
  +    }
  +
       /*-------------------- MessageListener ----------------------*/
   
      class MessageListenerAdaptor implements MessageListener
  @@ -3770,7 +3703,7 @@
            coordinator = determineCoordinator();
   
            // now notify listeners - *after* updating the coordinator. - JBCACHE-662 
  -         if (needNotification) notifyViewChange(new_view);
  +         if (needNotification) notifier.notifyViewChange(new_view);
   
            // Wake up any thread waiting in fetchStateOnStartup
            members.notifyAll();
  @@ -4070,229 +4003,11 @@
         return marshaller_;
      }
   
  -   /**
  -    * Sends a notification that a node was created.
  -    */
  -   public void notifyNodeCreated(Fqn fqn)
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -         evictionPolicyListener.nodeCreated(fqn, true, true);
  -      }
  -      if (hasListeners)
  -      {
  -         for (CacheListener listener : listeners)
  -         {
  -            listener.nodeCreated(fqn, true, true);
  -         }
  -      }
  -   }
  -
  -   /**
  -    * Sends a notification that a node was loaded.
  -    */
  -   public void notifyNodeLoaded(Fqn fqn)
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -         evictionPolicyListener.nodeLoaded(fqn, true, Collections.EMPTY_MAP);
  -      }
  -      if (hasListeners)
  -      {
  -         for (CacheListener listener : listeners)
  -         {
  -            listener.nodeLoaded(fqn, true, Collections.EMPTY_MAP);
  -         }
  -      }
  -   }
  -
  -   /**
  -    * Sends a notification that a node was activated.
  -    */
  -   public void notifyNodeActivate(Fqn fqn, boolean pre)
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -        evictionPolicyListener.nodeActivated(fqn, pre);
  -      }
  -      if (hasListeners)
  -      {
  -         for (CacheListener listener : listeners)
  -         {
  -            listener.nodeActivated(fqn, pre);
  -         }
  -      }
  -   }
  -
  -   /**
  -    * Sends a notification that a node was passivated.
  -    */
  -   public void notifyNodePassivate(Fqn fqn, boolean pre)
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -            evictionPolicyListener.nodePassivated(fqn, pre);
  -      }
  -      if (hasListeners)
  -      {
  -          for (CacheListener listener : listeners)
  -          {
  -              listener.nodePassivated(fqn, pre);
  -          }
  -      }
  -   }
  -
  -   protected void notifyNodeRemove(Fqn fqn, boolean pre)
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -        evictionPolicyListener.nodeRemoved(fqn, pre, InvocationContext.getCurrent().isOriginLocal(), Collections.EMPTY_MAP);
  -      }
  -      if (hasListeners)
  -      {
  -         for (CacheListener listener : listeners)
  -         {
  -               listener.nodeRemoved(fqn, pre, InvocationContext.getCurrent().isOriginLocal(), Collections.EMPTY_MAP);
  -         }
  -      }
  -   }
  -
  -   protected void notifyNodeRemoved(Fqn fqn)
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -         evictionPolicyListener.nodeRemoved(fqn, false, InvocationContext.getCurrent().isOriginLocal(), Collections.EMPTY_MAP);
  -      }
  -      if (hasListeners)
  -      {
  -         for (CacheListener listener : listeners)
  -         {
  -            listener.nodeRemoved(fqn, false, InvocationContext.getCurrent().isOriginLocal(), Collections.EMPTY_MAP);
  -         }
  -      }
  -   }
  -
  -   protected void notifyNodeEvict(Fqn fqn, boolean pre)
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -         if (evictionPolicyListener instanceof ExtendedTreeCacheListener)
  -         {
  -            ((ExtendedTreeCacheListener) evictionPolicyListener).nodeEvict(fqn, pre);
  -         }
  -      }
  -      if (hasListeners)
  -      {
  -         for (Iterator it = listeners.iterator(); it.hasNext();)
  -         {
  -            Object listener = it.next();
  -            if (listener instanceof ExtendedTreeCacheListener)
  -            {
  -               ((ExtendedTreeCacheListener) listener).nodeEvict(fqn, pre);
  -            }
  -         }
  -      }
  -   }
  -
  -   protected void notifyNodeEvicted(Fqn fqn)
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -         evictionPolicyListener.nodeEvicted(fqn, true, true);
  -      }
  -      if (hasListeners)
  -      {
  -          for (CacheListener listener : listeners)
  -          {
  -              listener.nodeEvicted(fqn, true, true);
  -          }
  -      }
  -   }
  -
  -
  -   protected void notifyNodeModify(Fqn fqn, boolean pre)
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -        evictionPolicyListener.nodeModified(fqn, pre, InvocationContext.getCurrent().isOriginLocal(), null);
  -      }
  -      if (hasListeners)
  -      {
  -          for (CacheListener listener : listeners)
  -          {
  -              listener.nodeModified(fqn, pre, InvocationContext.getCurrent().isOriginLocal(), null);
  -          }
  -      }
  -   }
  -
  -   protected void notifyNodeModified(Fqn fqn)
  -   {
  -   }
  -
  -   protected void notifyNodeVisited(Fqn fqn)
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -         evictionPolicyListener.nodeVisited(fqn, true);
  -      }
  -      if (hasListeners)
  -      {
  -          for (CacheListener listener : listeners)
  -          {
  -              listener.nodeVisited(fqn, true);
  -          }
  -      }
  -   }
  -
  -   protected void notifyCacheStarted()
  -   {
  -      if (evictionPolicyListener != null)
  -      {
  -         evictionPolicyListener.cacheStarted(getCacheSPI());
  -      }
  -      if (hasListeners)
  -      {
  -          for (CacheListener listener : listeners)
  -          {
  -              listener.cacheStarted(getCacheSPI());
  -          }
  -      }
  -   }
  -
       public CacheSPI getCacheSPI()
       {
           return new TreeCacheProxyImpl(this, (NodeImpl) root);
       }
   
  -   protected void notifyCacheStopped()
  -   {
  -       if (evictionPolicyListener != null)
  -       {
  -          evictionPolicyListener.cacheStopped(getCacheSPI());
  -       }
  -       if (hasListeners)
  -       {
  -           for (CacheListener listener : listeners)
  -           {
  -               listener.cacheStopped(getCacheSPI());
  -           }
  -       }
  -   }
  -
  -   protected void notifyViewChange(View v)
  -   {
  -       if (evictionPolicyListener != null)
  -       {
  -          evictionPolicyListener.viewChange(v);
  -       }
  -       if (hasListeners)
  -       {
  -           for (CacheListener listener : listeners)
  -           {
  -               listener.viewChange(v);
  -           }
  -       }
  -   }
   
      /**
       * Returns the default JGroup properties.
  
  
  
  1.11      +17 -7     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.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- TreeCacheProxyImpl.java	15 Aug 2006 21:02:23 -0000	1.10
  +++ TreeCacheProxyImpl.java	16 Aug 2006 10:52:51 -0000	1.11
  @@ -14,6 +14,7 @@
   import org.jboss.cache.eviction.RegionManager;
   import org.jboss.cache.statetransfer.StateTransferManager;
   import org.jboss.cache.factories.NodeFactory;
  +import org.jboss.cache.notifications.Notifier;
   import org.jgroups.Address;
   import org.jgroups.blocks.MethodCall;
   import org.apache.commons.logging.Log;
  @@ -161,7 +162,7 @@
   
       public void addCacheListener(CacheListener l)
       {
  -        treeCache.addTreeCacheListener(l);
  +        treeCache.getNotifier().addCacheListener(l);
       }
   
       public void addCacheListener(Fqn region, CacheListener l)
  @@ -171,7 +172,7 @@
   
       public void removeCacheListener(CacheListener l)
       {
  -        treeCache.removeTreeCacheListener(l);
  +        treeCache.getNotifier().removeCacheListener(l);
       }
   
       public void removeCacheListener(Fqn region, CacheListener l)
  @@ -181,7 +182,7 @@
   
       public Set<CacheListener> getCacheListeners()
       {
  -        return treeCache.getTreeCacheListeners();
  +        return treeCache.getNotifier().getCacheListeners();
       }
   
       public Set<CacheListener> getCacheListeners(Fqn region)
  @@ -297,11 +298,13 @@
           if (InvocationContext.getOptionOverrides().isBypassInterceptorChain())
           {
               TreeCacheProxyImpl retval = null;
  +            NodeImpl newNode;
  +            GlobalTransaction gtx = InvocationContext.getCurrent().getGlobalTransaction();
   
               if (f.size() == 1)
               {
  -                NodeImpl newNode = (NodeImpl) NodeFactory.getInstance().createNode(f.getLast(), currentNode, Collections.EMPTY_MAP, treeCache);
  -                this.currentNode.addChild(f.getLast(), newNode);
  +                newNode = (NodeImpl) NodeFactory.getInstance().createNode(f.getLast(), currentNode, Collections.EMPTY_MAP, treeCache);
  +                treeCache._addChild(gtx, currentNode.getFqn(), f.getLast(), newNode);
                   retval = new TreeCacheProxyImpl(treeCache, newNode);
               }
               else
  @@ -310,12 +313,14 @@
                   NodeImpl currentParent = currentNode;
                   for (Object o : f.peekElements())
                   {
  -                    NodeImpl newNode = (NodeImpl) NodeFactory.getInstance().createNode(o, currentParent, Collections.EMPTY_MAP, treeCache);
  -                    currentParent.addChild(o, newNode);
  +                    newNode = (NodeImpl) NodeFactory.getInstance().createNode(o, currentParent, Collections.EMPTY_MAP, treeCache);
  +                    //currentParent.addChild(o, newNode);
  +                    treeCache._addChild(gtx, currentParent.getFqn(), o, newNode);
                       currentParent = newNode;
                   }
                   retval = new TreeCacheProxyImpl(treeCache, currentParent);
               }
  +
               InvocationContext.getOptionOverrides().setBypassInterceptorChain(false);
               return retval;
           }
  @@ -501,6 +506,11 @@
           throw new RuntimeException("TODO: Need to figure out how to deal with these.");
       }
   
  +    public Notifier getNotifier()
  +    {
  +        return treeCache.getNotifier();
  +    }
  +
       public GlobalTransaction getCurrentTransaction(Transaction tx)
       {
           return treeCache.getCurrentTransaction(tx);
  
  
  
  1.13      +2 -2      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.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- TreeCacheView.java	19 Jul 2006 21:34:45 -0000	1.12
  +++ TreeCacheView.java	16 Aug 2006 10:52:51 -0000	1.13
  @@ -55,7 +55,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.12 $
  + * @version $Revision: 1.13 $
    * @author<a href="mailto:bela at jboss.org">Bela Ban</a> March 27 2003
    */
   public class TreeCacheView extends ServiceMBeanSupport implements TreeCacheViewMBean {
  @@ -228,7 +228,7 @@
               c.setReplQueueMaxElements(queue_max_elements);
            }
   
  -         tree.addTreeCacheListener(new MyListener());
  +         tree.getNotifier().addCacheListener(new MyListener());
   
            log.info("registering the tree as " + mbean_name);
            srv.registerMBean(tree, new ObjectName(mbean_name));
  
  
  
  1.13      +3 -3      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.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- TreeCacheView2.java	20 Jul 2006 11:48:25 -0000	1.12
  +++ TreeCacheView2.java	16 Aug 2006 10:52:51 -0000	1.13
  @@ -54,7 +54,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.12 $
  + * @version $Revision: 1.13 $
    */
   public class TreeCacheView2 {
      static TreeCacheGui2 gui_=null;
  @@ -137,7 +137,7 @@
   				tree = new TreeCache();
   				tree.setConfiguration(new XmlConfigurationParser().parseFile(resource));
   
  -				tree.addTreeCacheListener(new TreeCacheView.MyListener());
  +				tree.getNotifier().addCacheListener(new TreeCacheView.MyListener());
   				tree.start();
   				demo = new TreeCacheView2(tree);
   				demo.start();
  @@ -286,7 +286,7 @@
   	   if(cache_!= null)
   	   {
   		   Runtime.getRuntime().addShutdownHook(new ShutdownThread(tree));
  -		   cache_.addTreeCacheListener(this);
  +		   cache_.getNotifier().addCacheListener(this);
   		   setTitle("TreeCacheGui2: mbr=" + getLocalAddress());
   		   tx_mgr=cache_.getTransactionManager();
   		   populateTree();
  
  
  



More information about the jboss-cvs-commits mailing list