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"); } }
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()); } }
This is correct behaviour, as per the documentation. First a node is created (and is empty) and it is then modified to apply it's state.