Chapter 6. Plain cache

Chapter 6. Plain cache

Once you are in the shell, you can either execute the script to populate the cache, or type it in manually by command line. To run the script, type sourceRelative("plain.bsh"); under the interactive BSH shell. For this to work, you'll need to have your working directory set to the directory in which plain.bsh resides (otherwise give the full pathname of plain.bsh). Basically, the script will create cache entries that will be replicated onto the GUI. (You may have to type show() into the resulting beanshell window yourself) Here are the snippets for the script:

import org.jboss.cache.*;
         show(); // verbose mode for bean shell
         TreeCache tree = new TreeCache();
         PropertyConfigurator config = new PropertyConfigurator(); 
	 // configure tree cache. Needs to be in the classpath
         config.configure(tree, "META-INF/replSync-service.xml");
         tree.startService(); 
	 // kick start tree cache
         tree.put("/a/b/c", "ben", "me"); 
	 // create a cache entry.
         // Node "/a/b/c" will be created if it does not yet exist.
      

You should see in the GUI that a new entry of /a/b/c has been created. Click on the node c to see the content. You can modify the contents from the GUI as well. To create another node, for example, you can type in the shell:

tree.put("/a/b/c/d", "JBoss", "Open Source");
         tree.get("/a/b/c/d", "JBoss");