ObjectName cacheON = new ObjectName("jboss.cache:service=EJB3TreeCache");
TreeCacheMBean mbean = (TreeCacheMBean) MBeanProxy.get(TreeCacheMBean.class, cacheON, server);
TreeCache cache = (TreeCache) mbean.getInstance();
// PassivationEvictionPolicy policy = (PassivationEvictionPolicy) cache.getEvictionPolicy();
// policy.createRegion("/mySFSB", 100, 1L);
cache.put("/mySFSB/1234", "hello", "world");
System.out.println("After PUT");
Thread.sleep(5000);
System.out.println("WAKE UP!");
File fp = new File(System.getProperty(ServerConfig.SERVER_TEMP_DIR) + "/stateful/mySFSB." + FileCacheLoader.DIR_SUFFIX + "/1234." + FileCacheLoader.DIR_SUFFIX);
System.out.println("exists in DB: " + fp.exists());
if (!fp.exists()) throw new RuntimeException("No passivation happened.");
System.out.println(cache.get("/mySFSB/1234", "hello"));
System.out.println("exists in DB: " + fp.exists());
if (fp.exists()) throw new RuntimeException("Should have been removed on activation.");
if (cache.exists("/mySFSB/1234"))
{
cache.remove("/mySFSB/1234");
// synchronized (policy)
// {
// policy.removeRegion("/mySFSB");
// }
cache.remove("/mySFSB");
}