[jboss-cvs] JBossAS SVN: r58592 - trunk/testsuite/src/main/org/jboss/test/cache/bean
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Nov 18 06:48:09 EST 2006
Author: bstansberry at jboss.com
Date: 2006-11-18 06:48:08 -0500 (Sat, 18 Nov 2006)
New Revision: 58592
Modified:
trunk/testsuite/src/main/org/jboss/test/cache/bean/CacheObjectMeanTesterBean.java
trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopMBeanTesterBean.java
trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopTesterBean.java
trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheMBeanTesterBean.java
trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheTesterBean.java
Log:
Use JBC 2 API
Modified: trunk/testsuite/src/main/org/jboss/test/cache/bean/CacheObjectMeanTesterBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cache/bean/CacheObjectMeanTesterBean.java 2006-11-18 11:47:49 UTC (rev 58591)
+++ trunk/testsuite/src/main/org/jboss/test/cache/bean/CacheObjectMeanTesterBean.java 2006-11-18 11:48:08 UTC (rev 58592)
@@ -21,13 +21,15 @@
*/
package org.jboss.test.cache.bean;
-import javax.ejb.*;
+import javax.ejb.CreateException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
-import org.jboss.cache.*;
-import org.jboss.cache.aop.TreeCacheAop;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.pojo.PojoCache;
import org.jboss.test.cache.test.standAloneAop.CacheObject;
/**
@@ -46,9 +48,9 @@
public void bind(String id) throws Exception
{
MBeanServer server = (MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
- TreeCacheAop cache = (TreeCacheAop)server.getAttribute(new ObjectName("jboss.cache:service=testTreeCacheAop"),
- "Instance");
- cache.putObject(new Fqn(new Object[] {"sessions", id}), new CacheObject(id));
+ PojoCache cache = (PojoCache)server.getAttribute(new ObjectName("jboss.cache:service=testTreeCacheAop"),
+ "PojoCache");
+ cache.attach(new Fqn(new Object[] {"sessions", id}).toString(), new CacheObject(id));
}
public void ejbCreate() throws CreateException
Modified: trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopMBeanTesterBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopMBeanTesterBean.java 2006-11-18 11:47:49 UTC (rev 58591)
+++ trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopMBeanTesterBean.java 2006-11-18 11:48:08 UTC (rev 58592)
@@ -21,12 +21,14 @@
*/
package org.jboss.test.cache.bean;
-import org.jboss.cache.aop.TreeCacheAop;
-import org.jboss.logging.Logger;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.test.cache.test.standAloneAop.Address;
-import org.jboss.test.cache.test.standAloneAop.Person;
-import org.jboss.util.NestedRuntimeException;
+import java.lang.reflect.Field;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
@@ -34,10 +36,14 @@
import javax.ejb.SessionContext;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import java.lang.reflect.Field;
-import java.rmi.RemoteException;
-import java.util.*;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.logging.Logger;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.test.cache.test.standAloneAop.Address;
+import org.jboss.test.cache.test.standAloneAop.Person;
+import org.jboss.util.NestedRuntimeException;
+
/**
* Proxy to the TreeCacheAop MBean.
* The AOP framework requires that classes are loaded by special classloaders (e.g UCL).
@@ -59,7 +65,7 @@
ObjectName cacheService;
SessionContext ctx;
- TreeCacheAop cache;
+ PojoCache cache;
Logger logger_ = Logger.getLogger(TreeCacheAopMBeanTesterBean.class);
@@ -344,7 +350,7 @@
public Object getFieldValue(String key, String name)
{
try {
- Object object = cache.getObject(key);
+ Object object = cache.find(key);
Field f = object.getClass().getDeclaredField(name);
f.setAccessible(true);
return f.get(object);
Modified: trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopTesterBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopTesterBean.java 2006-11-18 11:47:49 UTC (rev 58591)
+++ trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheAopTesterBean.java 2006-11-18 11:48:08 UTC (rev 58592)
@@ -21,21 +21,29 @@
*/
package org.jboss.test.cache.bean;
+import java.lang.reflect.Field;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
import org.jboss.aop.Advised;
-import org.jboss.cache.aop.TreeCacheAop;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.PojoCacheFactory;
import org.jboss.logging.Logger;
import org.jboss.test.cache.test.standAloneAop.Address;
import org.jboss.test.cache.test.standAloneAop.Person;
import org.jboss.util.NestedRuntimeException;
-import javax.ejb.CreateException;
-import javax.ejb.EJBException;
-import javax.ejb.SessionBean;
-import javax.ejb.SessionContext;
-import java.lang.reflect.Field;
-import java.rmi.RemoteException;
-import java.util.*;
-
/**
* Proxy to the TreeCacheAop MBean.
* The AOP framework requires that classes are loaded by special classloaders (e.g UCL).
@@ -54,8 +62,8 @@
{
SessionContext ctx;
- TreeCacheAop cache;
- TreeCacheAop cache2;
+ PojoCache cache;
+ PojoCache cache2;
Logger logger_ = Logger.getLogger(TreeCacheAopTesterBean.class);
@@ -82,10 +90,14 @@
public void ejbCreate(String cluster_name, String props, int caching_mode) throws CreateException
{
try {
- cache = new TreeCacheAop(cluster_name, props, 10000);
- cache.startService();
- cache2 = new TreeCacheAop(cluster_name, props, 10000);
- cache2.startService();
+ Configuration config = new Configuration();
+ config.setClusterName(cluster_name);
+ config.setClusterConfig(props);
+ config.setCacheMode(Configuration.legacyModeToCacheMode(caching_mode));
+ cache = PojoCacheFactory.createCache(config, false);
+ cache.start();
+ cache2 = PojoCacheFactory.createCache(config, false);
+ cache2.start();
} catch (Exception e) {
throw new CreateException(e.toString());
}
@@ -119,7 +131,7 @@
p.setAge(age);
p.setAddress(new Address());
try {
- cache.putObject(key, p);
+ cache.attach(key, p);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -131,7 +143,7 @@
public void removePerson(String key)
{
try {
- cache.removeObject(key);
+ cache.detach(key);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -141,7 +153,7 @@
Object getPerson(String key)
{
try {
- return (Person) cache.getObject(key);
+ return (Person) cache.find(key);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -348,8 +360,8 @@
Address address = new Address();
address.setCity("Mannheim");
p.setAddress(address);
- cache.putObject("/person/harald", p);
- return (Person) cache.getObject("/person/harald");
+ cache.attach("/person/harald", p);
+ return (Person) cache.find("/person/harald");
} catch (Throwable t) {
throw new RuntimeException(t);
}
@@ -361,7 +373,7 @@
public void testDeserialization(String key, Object value)
{
try {
- cache.putObject(key, value);
+ cache.attach(key, value);
} catch (Throwable t) {
throw new RuntimeException(t);
}
@@ -389,7 +401,7 @@
public Object getFieldValue(String key, String name)
{
try {
- Object object = cache.getObject(key);
+ Object object = cache.find(key);
Field f = object.getClass().getDeclaredField(name);
f.setAccessible(true);
return f.get(object);
Modified: trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheMBeanTesterBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheMBeanTesterBean.java 2006-11-18 11:47:49 UTC (rev 58591)
+++ trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheMBeanTesterBean.java 2006-11-18 11:48:08 UTC (rev 58592)
@@ -21,9 +21,9 @@
*/
package org.jboss.test.cache.bean;
-import org.jboss.cache.TreeCacheMBean;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.mx.util.MBeanServerLocator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
@@ -31,10 +31,11 @@
import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+
/**
* EJB proxy to the TreeCache MBean service. Used to be able to transport
* user transactions from a test client to a TreeCache. Note that TreeCache MBean
@@ -54,7 +55,7 @@
static final String OBJECT_NAME = "jboss.cache:service=testTreeCache";
MBeanServer server;
ObjectName cacheService;
- TreeCacheMBean cache=null;
+ PojoCache cache=null;
/**
* @throws CreateException
@@ -87,7 +88,8 @@
try {
cacheService = new ObjectName(name);
server = MBeanServerLocator.locate();
- cache=(TreeCacheMBean)MBeanProxyExt.create(TreeCacheMBean.class, cacheService, server);
+ cache=(PojoCache)server.getAttribute(new ObjectName("jboss.cache:service=testTreeCacheAop"),
+ "PojoCache");
} catch (Exception ex) {
throw new CreateException(ex.toString());
}
@@ -116,7 +118,9 @@
*/
public Vector getMembers() throws Exception
{
- return cache.getMembers();
+ // FIXME restore after Cache exposes getMembers
+// return cache.getMembers();
+ throw new UnsupportedOperationException("See FIXME in bean code");
}
/**
Modified: trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheTesterBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheTesterBean.java 2006-11-18 11:47:49 UTC (rev 58591)
+++ trunk/testsuite/src/main/org/jboss/test/cache/bean/TreeCacheTesterBean.java 2006-11-18 11:48:08 UTC (rev 58592)
@@ -21,13 +21,20 @@
*/
package org.jboss.test.cache.bean;
+import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
import org.jboss.cache.TreeCache;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.DefaultCacheFactory;
import org.jboss.cache.lock.IsolationLevel;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
+
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
@@ -46,7 +53,7 @@
*/
public class TreeCacheTesterBean implements SessionBean
{
- TreeCache cache = null;
+ Cache cache = null;
/**
* @throws CreateException
@@ -70,12 +77,14 @@
{
try {
// cache=new TreeCache(cluster_name, props, 10000);
- cache = new TreeCache();
- cache.setClusterName(cluster_name);
- cache.setClusterProperties(props);
- cache.setCacheMode(caching_mode);
- cache.setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
- cache.startService();
+ Configuration config = new Configuration();
+ config.setClusterName(cluster_name);
+ config.setClusterConfig(props);
+ config.setCacheMode(Configuration.legacyModeToCacheMode(caching_mode));
+ config.setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
+
+ cache = DefaultCacheFactory.createCache(config);
+
} catch (Exception e) {
throw new CreateException(e.toString());
}
@@ -119,7 +128,8 @@
{
log("I'm being removed");
if (cache != null) {
- cache.stopService();
+ cache.stop();
+ cache.destroy();
cache = null;
}
}
@@ -135,7 +145,8 @@
*/
public Vector getMembers()
{
- return cache.getMembers();
+ List members = cache.getMembers();
+ return members == null ? null : new Vector(members);
}
@@ -145,7 +156,7 @@
*/
public void setCacheMode(int mode) throws Exception
{
- cache.setCacheMode(mode);
+ cache.getConfiguration().setCacheMode(Configuration.legacyModeToCacheMode(mode));
}
@@ -155,7 +166,7 @@
*/
public void setIsolationLevel(IsolationLevel level)
{
- cache.setIsolationLevel(level);
+ cache.getConfiguration().setIsolationLevel(level);
}
@@ -166,7 +177,8 @@
*/
public Set getKeys(String fqn) throws CacheException
{
- return cache.getKeys(fqn);
+ Node node = cache.getChild(Fqn.fromString(fqn));
+ return node == null ? null : node.getKeys();
}
/**
@@ -176,7 +188,7 @@
* @ejb.interface-method
*/
public Object get(String fqn, String key) throws CacheException {
- return cache.get(fqn, key);
+ return cache.get(Fqn.fromString(fqn), key);
}
/**
@@ -186,7 +198,7 @@
*/
public boolean exists(String fqn)
{
- return cache.exists(fqn);
+ return cache.hasChild(Fqn.fromString(fqn));
}
/**
@@ -210,7 +222,7 @@
*/
public Object put(String fqn, String key, Object value) throws Exception
{
- return cache.put(fqn, key, value);
+ return cache.put(Fqn.fromString(fqn), key, value);
}
/**
@@ -232,58 +244,59 @@
*/
public Object remove(String fqn, String key) throws Exception
{
- return cache.remove(fqn, key);
+ return cache.remove(Fqn.fromString(fqn), key);
}
- /**
- * @param fqn
- * @ejb.interface-method
- */
- public void releaseAllLocks(String fqn)
- {
- cache.releaseAllLocks(fqn);
- }
+// /**
+// * @param fqn
+// * @ejb.interface-method
+// */
+// public void releaseAllLocks(String fqn)
+// {
+// cache.releaseAllLocks(fqn);
+// }
+//
+// /**
+// * @param fqn
+// * @return
+// * @ejb.interface-method
+// */
+// public String print(String fqn)
+// {
+// return cache.print(fqn);
+// }
/**
* @param fqn
* @return
* @ejb.interface-method
*/
- public String print(String fqn)
- {
- return cache.print(fqn);
- }
-
- /**
- * @param fqn
- * @return
- * @ejb.interface-method
- */
public Set getChildrenNames(String fqn) throws CacheException
{
- return cache.getChildrenNames(fqn);
+ Node node = cache.getChild(Fqn.fromString(fqn));
+ return (node == null ? null : node.getChildrenNames());
}
- /**
- * @return
- * @ejb.interface-method
- */
- public String printDetails()
- {
- return cache.printDetails();
- }
+// /**
+// * @return
+// * @ejb.interface-method
+// */
+// public String printDetails()
+// {
+// return cache.printDetails();
+// }
+//
+// /**
+// * @return
+// * @ejb.interface-method
+// */
+// public String printLockInfo()
+// {
+// return cache.printLockInfo();
+// }
/**
- * @return
* @ejb.interface-method
- */
- public String printLockInfo()
- {
- return cache.printLockInfo();
- }
-
- /**
- * @ejb.interface-method
* @param members
* @param method
* @param args
More information about the jboss-cvs-commits
mailing list