2 Replies Latest reply on Sep 25, 2005 4:24 PM by Christophe Lallement

    TreeCacheListerner use case question ?

    Christophe Lallement Newbie

      I have registered a TreeCacheListener on my aopcache:

      In method cacheStarted(TreeCache arg0)
      i call: myCache.putObject("/foo/bar", "42")

      And in the same listener in method nodeCreated(Fqn arg0)
      i call :
      if (arg0.equals(Fqn.fromString("/foo/bar"))
      System.err.println("find bis: "+myCache.getObject(arg0));
      // and the result here is null ?

      All is int the same process with the same instance of TreeCacheAop.
      The result is null, is it normal ?

      it shoud be fine if the nofication process for nodeCreated/visited could have a second argument : the value of the node.


        • 1. Re: TreeCacheListerner use case question ?
          Bela Ban Master

          Put the callback on nodeModified() not nodeCreated()

          • 2. Re: TreeCacheListerner use case question ?
            Christophe Lallement Newbie

            yes, i have read the code of TreeCache and TreeCacheAop
            and i have implemented the nodeModify callBack
            and this method is called many time for the same modification.

            another pb is we can not make the difference between node which has been created (modified the first time) and another modification.

            it seems this state comes from the interceptor pattern (and specially from the interceptor which create a node if not exists (before setting the data of the node) and from the method putObject which begin bu creating a node with a dummy map.

            My need is to have a callback when a data object for a given fqn is created (node not exist or node data is null) and a callback when a data for a node is modified)

            i suggest to add two new callback for TreeCacheListner:
            newData(Fqn fqn, Serializable data);
            updateData(Fqn fqn, Serializable data);

            this methods could be called in the _put(..., Object data, ...);
            and only one time.

            Is this modifcation make sens ?
            Tomorrow i patch my local cvs to see if i can works.