[jboss-user] [JBossCache] - Listener receives both a nodeCreated AND nodeModified for ne

jmcclure do-not-reply at jboss.com
Wed Feb 14 18:48:07 EST 2007


Using JBoss AS 4.0.5GA, JBoss Cache 1.4.1 SP1, Java 1.5.0_10, WinXP Pro

Hi, 

I have created a tree cache instance in which I am adding a node via the method put(fqn, key, value).  From the documentation, if that node does not exist, which is the situation in my test, a nodeCreated notification will be emitted.  However, this is not the case.  My listener receives both a nodeCreated AND nodeModified notification for that single action. 

My listener extends the abstract listener and overrides a couple of methods:
public class CacheListener extends AbstractTreeCacheListener
  | {
  |     public CacheListener()
  |     {
  |         System.err.println("listener created");
  |     }
  |     
  |     @Override
  |     public void nodeCreated(Fqn fqn)
  |     {
  |         System.err.println("node created");
  |     }
  |     
  |     @Override
  |     public void nodeModified(Fqn fqn)
  |     {
  |         System.err.println("node modified");
  |     }
  | }

My main class creates the cache instance, reigisters the listener and creates a node with data:
public static void main(String[] args)
  |     {
  |         try
  |         {
  |             System.err.println("starting test");
  |             TreeCache tree = new TreeCache();
  |             CacheListener listener = new CacheListener();
  |             tree.addTreeCacheListener(listener);
  |             
  |             tree.setClusterName("test");
  |             tree.setClusterProperties("default.xml");
  |             tree.setCacheMode(TreeCache.LOCAL);
  |             tree.createService();
  |             tree.startService();
  |             tree.put("/a", "name", "James");
  |             tree.stopService();
  |             tree.destroyService();
  |             System.err.println("end of test");
  |         }
  |         catch(Exception ex)
  |         {
  |             System.err.println("Got an exception: " + ex.getMessage());
  |         }
  |     }

The output is as follows:
starting test
listener created
node created
node modified
end of test

Is this the expected behavior with incorrect documentation? Or am I not utilizing the API properly?  Any pointers are appreciated.

Thanks.
James

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016751#4016751

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016751



More information about the jboss-user mailing list