4 Replies Latest reply on Jun 2, 2006 11:39 AM by manik

    TreeCacheListener doesn't receive all cache events

    sgielen

      I have a class that creates a TreeCache and registers a TreeCacheListener. All nodes created in this class trigger an event.
      But when I pass a Node object to another class and that one adds/updates a node I don't get the event (but it does end up in the tree).

      Is there a way to get all events, regardless of which object adds/updates a node?

      I'm new to this forum (but did search all docos and forums for a solution to my issue), so let me know if you need any code snippets or other info.

        • 1. Re: TreeCacheListener doesn't receive all cache events
          brian.stansberry

          From what you wrote I'm guessing that the other class directly manipulated the Node object to do its update, rather than calling cache.put().

          You'll only get notifications if operations are performed on the cache. Directly manipulating Node objects will bypass all the logic that results in things like notifications, replication, locking, etc.

          In 2.0 we are going to change the JBossCache API won't even expose the Node object so people won't be tempted to bypass the cache.

          • 2. Re: TreeCacheListener doesn't receive all cache events
            sgielen

            You guessed right...

            So that means I have to pass a reference to the TreeCache object instead? The nice thing of being able to just pass the Node is that the class doesn't have to worry about the location in the tree. Now I'll need to pass the Fqn of the branch as well as a reference point. Because I didn't want the whole tree exposed in the sub class, just the branch it's allowed to use.
            Is that correct?

            • 3. Re: TreeCacheListener doesn't receive all cache events
              brian.stansberry

              If you don't want to expose the cache, pass an object that talks to the cache and exposes the API you need.

              • 4. Re: TreeCacheListener doesn't receive all cache events
                manik

                 


                In 2.0 we are going to change the JBossCache API won't even expose the Node object so people won't be tempted to bypass the cache.


                This is not actually true at all. We're changing it so that the Node becomes a top level construct, and the Cache is just a wrapper around the root Node. All listeners, interceptors, etc. will intercept calls on the Node.

                The reason for doing this is that it leads to a far cleaner object model, and allows for each Node to act independently of the overall Cache - a bit like a JNDI context.

                See http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheHabanero for more info.

                Cheers,
                Manik