[jboss-cvs] JBossAS SVN: r58553 - in trunk/ejb3/src/test/org/jboss/ejb3/test: cache clusteredentity

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Nov 18 06:19:12 EST 2006


Author: bstansberry at jboss.com
Date: 2006-11-18 06:19:11 -0500 (Sat, 18 Nov 2006)
New Revision: 58553

Modified:
   trunk/ejb3/src/test/org/jboss/ejb3/test/cache/Tester.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java
Log:
Update to JBC 2.0.0.Alpha1

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/cache/Tester.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/cache/Tester.java	2006-11-18 11:18:51 UTC (rev 58552)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/cache/Tester.java	2006-11-18 11:19:11 UTC (rev 58553)
@@ -22,12 +22,14 @@
 package org.jboss.ejb3.test.cache;
 
 import java.io.File;
+
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
-import org.jboss.cache.TreeCacheMBean;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.jmx.CacheJmxWrapperMBean;
 import org.jboss.cache.loader.FileCacheLoader;
-//import org.jboss.ejb3.cache.tree.PassivationEvictionPolicy;
-import org.jboss.ejb3.cache.tree.PassivationTreeCache;
 import org.jboss.mx.util.MBeanProxy;
 import org.jboss.system.ServiceMBeanSupport;
 import org.jboss.system.server.ServerConfig;
@@ -43,12 +45,13 @@
    public void test() throws Exception
    {
       ObjectName cacheON = new ObjectName("jboss.cache:service=EJB3TreeCache");
-      TreeCacheMBean mbean = (TreeCacheMBean) MBeanProxy.get(TreeCacheMBean.class, cacheON, server);
-      PassivationTreeCache cache = (PassivationTreeCache) mbean.getInstance();
+      CacheJmxWrapperMBean mbean = (CacheJmxWrapperMBean) MBeanProxy.get(CacheJmxWrapperMBean.class, cacheON, server);
+      Cache cache = mbean.getCache();
 //      PassivationEvictionPolicy policy = (PassivationEvictionPolicy) cache.getEvictionPolicy();
 //      policy.createRegion("/mySFSB", 100, 1L);
 
-      cache.put("/mySFSB/1234", "hello", "world");
+      Fqn mysfbf1234 = Fqn.fromString("/mySFSB/1234");
+      cache.put(mysfbf1234, "hello", "world");
       System.out.println("After PUT");
       Thread.sleep(5000);
 
@@ -56,10 +59,10 @@
       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(cache.get(mysfbf1234, "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"))
+      if (cache.hasChild(mysfbf1234))
       {
          cache.remove("/mySFSB/1234");
 //         synchronized (policy)

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java	2006-11-18 11:18:51 UTC (rev 58552)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java	2006-11-18 11:19:11 UTC (rev 58553)
@@ -31,10 +31,11 @@
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 
+import org.jboss.cache.AbstractCacheListener;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.TreeCache;
-import org.jboss.cache.TreeCacheListener;
-import org.jboss.cache.TreeCacheMBean;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheListener;
+import org.jboss.cache.jmx.CacheJmxWrapperMBean;
 import org.jboss.mx.util.MBeanProxyExt;
 import org.jboss.mx.util.MBeanServerLocator;
 import org.jgroups.View;
@@ -59,11 +60,11 @@
       try
       {
          //Just to initialise the cache with a listener
-         TreeCache cache = getCache();
+         Cache cache = getCache();
          if (listener == null)
          {
             listener = new MyListener();
-            cache.addTreeCacheListener(listener);
+            cache.addCacheListener(listener);
          }
       }
       catch (Exception e)
@@ -155,16 +156,16 @@
       
    }
 
-   private TreeCache getCache() throws Exception
+   private Cache getCache() throws Exception
    {
       MBeanServer server = MBeanServerLocator.locateJBoss();
-      TreeCacheMBean proxy = (TreeCacheMBean)MBeanProxyExt.create(TreeCacheMBean.class, new ObjectName("jboss.cache:service=EJB3EntityTreeCache"), server);
-      TreeCache cache = proxy.getInstance();
+      CacheJmxWrapperMBean proxy = (CacheJmxWrapperMBean)MBeanProxyExt.create(CacheJmxWrapperMBean.class, new ObjectName("jboss.cache:service=EJB3EntityTreeCache"), server);
+      Cache cache = proxy.getCache();
       
       return cache;
    }
 
-   class MyListener implements TreeCacheListener
+   class MyListener extends AbstractCacheListener
    {
       HashSet visited = new HashSet(); 
       
@@ -173,48 +174,20 @@
          visited.clear();
       }
       
-      public void cacheStarted(TreeCache cache)
+      @Override
+      public void nodeVisited(Fqn fqn, boolean pre)
       {
+         if (!pre)
+         {
+            System.out.println("MyListener - Visiting node " + fqn.toString());
+            String name = fqn.toString();
+            String token = ".clusteredentity.";
+            int index = name.indexOf(token);
+            index += token.length();
+            name = name.substring(index);
+            System.out.println(name);
+            visited.add(name);
+         }
       }
-
-      public void cacheStopped(TreeCache cache)
-      {
-      }
-
-      public void nodeCreated(Fqn fqn)
-      {
-      }
-
-      public void nodeEvicted(Fqn fqn)
-      {
-      }
-
-      public void nodeLoaded(Fqn fqn)
-      {
-      }
-
-      public void nodeModified(Fqn fqn)
-      {
-      }
-
-      public void nodeRemoved(Fqn fqn)
-      {
-      }
-
-      public void nodeVisited(Fqn fqn)
-      {
-         System.out.println("MyListener - Visiting node " + fqn.toString());
-         String name = fqn.toString();
-         String token = ".clusteredentity.";
-         int index = name.indexOf(token);
-         index += token.length();
-         name = name.substring(index);
-         System.out.println(name);
-         visited.add(name);
-      }
-
-      public void viewChange(View new_view)
-      {
-      }
    }
 }




More information about the jboss-cvs-commits mailing list