JBoss Cache SVN: r4898 - in core/trunk/src: main/java/org/jboss/cache/factories and 5 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-12-20 12:14:25 -0500 (Thu, 20 Dec 2007)
New Revision: 4898
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/RemoveBeforeCreateTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java
Log:
Optimistic locking fixes
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -3777,7 +3777,7 @@
if (found)
{
componentRegistry.registerComponent(i);
- interceptors.add(position++, i);
+ interceptors.add(++position, i);
setInterceptorChain(factory.correctInterceptorChaining(interceptors));
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -589,8 +589,6 @@
*/
public Interceptor correctInterceptorChaining(List<Interceptor> interceptors)
{
- // re-wire
- componentRegistry.updateDependencies();
Interceptor first = null, last = null;
@@ -608,7 +606,10 @@
if (last != null) last.setNext(null);
// now set the 'last' pointer.
- return setLastInterceptorPointer(first, last);
+ Interceptor i = setLastInterceptorPointer(first, last);
+ // re-register this interceptor
+ componentRegistry.registerComponent(Interceptor.class.getName(), i);
+ return i;
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -16,6 +16,8 @@
@DefaultFactoryFor(classes = {TransactionManager.class})
public class TransactionManagerFactory extends ComponentFactory
{
+ boolean messageLogged = false;
+
@Override
@SuppressWarnings("unchecked")
protected <T> T construct(String componentName, Class<T> componentType)
@@ -49,14 +51,18 @@
}
else
{
- if (configuration.getNodeLockingScheme() == Configuration.NodeLockingScheme.OPTIMISTIC)
+ if (!messageLogged)
{
- log.fatal("No transaction manager lookup class has been defined. Transactions cannot be used and thus OPTIMISTIC locking cannot be used");
+ messageLogged = true;
+ if (configuration.getNodeLockingScheme() == Configuration.NodeLockingScheme.OPTIMISTIC)
+ {
+ log.fatal("No transaction manager lookup class has been defined. Transactions cannot be used and thus OPTIMISTIC locking cannot be used");
+ }
+ else
+ {
+ log.info("No transaction manager lookup class has been defined. Transactions cannot be used");
+ }
}
- else
- {
- log.info("No transaction manager lookup class has been defined. Transactions cannot be used");
- }
}
}
catch (Exception e)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -556,6 +556,10 @@
workspaceNode.setVersioningImplicit(false);
}
+ // now make sure all parents are in the wsp as well
+ if (workspaceNode != null && !fqn.isRoot())
+ fetchWorkspaceNode(fqn.getParent(), workspace, false, includeInvalidNodes);
+
return workspaceNode;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -3,21 +3,18 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.interceptors.ActivationInterceptor;
+import org.jboss.cache.interceptors.PassivationInterceptor;
import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.util.reflect.ReflectionUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
-/**
- * Created by IntelliJ IDEA.
- * User: bela
- * Date: Jun 9, 2004
- * Time: 9:05:19 AM
- */
+@Test(groups = {"functional"})
public class LocalDelegatingCacheLoaderTest extends CacheLoaderTestsBase
{
CacheSPI delegating_cache;
- @SuppressWarnings("deprecation")
protected void configureCache() throws Exception
{
delegating_cache = (CacheSPI) new DefaultCacheFactory().createCache(false);
@@ -31,8 +28,8 @@
// force our own cache loader instance
LocalDelegatingCacheLoader cacheLoader = new LocalDelegatingCacheLoader(delegating_cache);
- // don't actually alter the interceptor chain, but this will force a re-injection of all deps in all components.
- TestingUtil.replaceInterceptorChain(cache, cache.getInterceptorChain().get(0));
+ ReflectionUtil.setValue(TestingUtil.findInterceptor(cache, PassivationInterceptor.class), "loader", cacheLoader);
+ ReflectionUtil.setValue(TestingUtil.findInterceptor(cache, ActivationInterceptor.class), "loader", cacheLoader);
}
protected void postConfigure()
Modified: core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -17,7 +17,6 @@
import org.jboss.cache.invocation.RemoteCacheInvocationDelegate;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.util.CachePrinter;
import java.io.File;
import java.lang.reflect.Field;
@@ -90,20 +89,7 @@
*/
public static void injectInterceptor(CacheSPI<?, ?> cache, Interceptor interceptorToInject, Class<? extends Interceptor> interceptorAfterWhichToInject)
{
- System.out.println("Old interceptor chain: " + CachePrinter.printCacheInterceptors(cache));
- // make sure the new interceptor is wired
- ComponentRegistry cr = extractComponentRegistry(cache);
- cr.registerComponent(interceptorToInject);
- interceptorToInject.setCache(cache);
- int index = -1;
- for (Interceptor i : cache.getInterceptorChain())
- {
- index++;
- if (interceptorAfterWhichToInject.isInstance(i)) break;
- }
-
- cache.addInterceptor(interceptorToInject, index + 1);
- System.out.println("New interceptor chain: " + CachePrinter.printCacheInterceptors(cache));
+ cache.addInterceptor(interceptorToInject, interceptorAfterWhichToInject);
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -12,7 +12,6 @@
import org.jboss.cache.VersionedNode;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.invocation.NodeInvocationDelegate;
-import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -100,7 +99,6 @@
}
catch (Exception e)
{
- log.fatal("*** Thew an exception!!", e);
setException(e);
}
}
@@ -141,10 +139,8 @@
assertEquals(0, c.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, c.getTransactionTable().getNumLocalTransactions());
- SamplePojo pojo = new SamplePojo(21, "test");
+ c.put("/one/two", "key1", "value");
- c.put("/one/two", "key1", pojo);
-
mgr.commit();
assertNull(mgr.getTransaction());
@@ -174,9 +170,8 @@
assertEquals(0, c.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, c.getTransactionTable().getNumLocalTransactions());
- SamplePojo pojo = new SamplePojo(21, "test");
mgr.begin();
- c.put("/one/two", "key1", pojo);
+ c.put("/one/two", "key1", "value");
mgr.rollback();
assertNull(mgr.getTransaction());
assertEquals(0, c.getTransactionTable().getNumGlobalTransactions());
@@ -207,10 +202,8 @@
//this sets
c.getCurrentTransaction(tx, true);
- SamplePojo pojo = new SamplePojo(21, "test");
+ c.put("/one/two", "key1", "value");
- c.put("/one/two", "key1", pojo);
-
GlobalTransaction gtx = c.getCurrentTransaction(tx, true);
TransactionTable table = c.getTransactionTable();
OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
@@ -263,10 +256,8 @@
mgr.begin();
//this sets
- SamplePojo pojo = new SamplePojo(21, "test");
+ cache.put("/one/two", "key1", "value");
- cache.put("/one/two", "key1", pojo);
-
//GlobalTransaction gtx = cache.getCurrentTransaction(tx);
assertNotNull(mgr.getTransaction());
mgr.commit();
@@ -279,14 +270,14 @@
assertTrue(cache.exists(Fqn.fromString("/one/two")));
assertTrue(cache.exists(Fqn.fromString("/one")));
- assertEquals(pojo, cache.get(Fqn.fromString("/one/two"), "key1"));
+ assertEquals("value", cache.get(Fqn.fromString("/one/two"), "key1"));
assertEquals(0, cache2.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache2.getTransactionTable().getNumLocalTransactions());
assertTrue(cache2.exists(Fqn.fromString("/one/two")));
assertTrue(cache2.exists(Fqn.fromString("/one")));
- assertEquals(pojo, cache2.get(Fqn.fromString("/one/two"), "key1"));
+ assertEquals("value", cache2.get(Fqn.fromString("/one/two"), "key1"));
destroyCache(cache);
destroyCache(cache2);
@@ -310,10 +301,8 @@
//this sets
cache.getCurrentTransaction(tx, true);
- SamplePojo pojo = new SamplePojo(21, "test");
+ cache.put("/one/two", "key1", "value");
- cache.put("/one/two", "key1", pojo);
-
assertNotNull(mgr.getTransaction());
mgr.commit();
@@ -325,7 +314,7 @@
assertTrue(cache.exists(Fqn.fromString("/one/two")));
assertTrue(cache.exists(Fqn.fromString("/one")));
- assertEquals(pojo, cache.get(Fqn.fromString("/one/two"), "key1"));
+ assertEquals("value", cache.get(Fqn.fromString("/one/two"), "key1"));
assertEquals(0, cache2.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache2.getTransactionTable().getNumLocalTransactions());
@@ -333,41 +322,13 @@
assertTrue(cache2.exists(Fqn.fromString("/one/two")));
assertTrue(cache2.exists(Fqn.fromString("/one")));
- assertEquals(pojo, cache2.get(Fqn.fromString("/one/two"), "key1"));
+ assertEquals("value", cache2.get(Fqn.fromString("/one/two"), "key1"));
destroyCache(cache);
destroyCache(cache2);
}
- // public void testRemotePessCacheBroadcast() throws Exception
- // {
- // destroyCache(c);
- //
- // CacheSPI cache = createPessimisticCache();
- // CacheSPI cache2 = createPessimisticCache();
- //
- // TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
- //
- // //start local transaction
- // mgr.begin();
- // Transaction tx = mgr.getTransaction();
- //
- // //this sets
- // cache.getCurrentTransaction(tx);
- //
- // SamplePojo pojo = new SamplePojo(21, "test");
- //
- // cache.put("/one/two", "key1", pojo);
- //
- //
- // mgr.commit();
- //
- // destroyCache(cache);
- // destroyCache(cache2);
- //
- // }
-
public void testConcurrentNodeRemoval() throws Exception
{
c.put(fqn, "key", "value");
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -2,6 +2,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.Interceptor;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
@@ -11,6 +12,8 @@
import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.transaction.Transaction;
@@ -23,23 +26,42 @@
@Test(groups = {"functional"})
public class NodeInterceptorGetChildrenNamesTest extends AbstractOptimisticTestCase
{
- public void testTransactionGetNamesMethod() throws Exception
+ TestListener listener;
+ CacheSPI<Object, Object> cache;
+ MockInterceptor dummy;
+ TransactionManager mgr;
+
+ @BeforeMethod
+ public void setUp() throws Exception
{
+ listener = new TestListener();
+ cache = createCacheWithListener(listener);
- TestListener listener = new TestListener();
- final CacheSPI<Object, Object> cache = createCacheWithListener(listener);
+ ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
+ cr.registerComponent(interceptor);
Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
- MockInterceptor dummy = new MockInterceptor();
+ cr.registerComponent(nodeInterceptor);
+ dummy = new MockInterceptor();
+ cr.registerComponent(dummy);
interceptor.setNext(nodeInterceptor);
nodeInterceptor.setNext(dummy);
TestingUtil.replaceInterceptorChain(cache, interceptor);
-// first set up a node with a pojo
- TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+ mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+ }
+
+ @AfterMethod
+ public void tearDown()
+ {
+ TestingUtil.killCaches(cache);
+ }
+
+ public void testTransactionGetNamesMethod() throws Exception
+ {
mgr.begin();
Transaction tx = mgr.getTransaction();
@@ -87,27 +109,11 @@
assertEquals(0, cache.getRoot().getChildrenNames().size());
mgr.commit();
- cache.stop();
}
public void testTransactionGetNoNamesMethod() throws Exception
{
-
- TestListener listener = new TestListener();
- final CacheSPI<Object, Object> cache = createCacheWithListener(listener);
-
- Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
- Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
- MockInterceptor dummy = new MockInterceptor();
-
- interceptor.setNext(nodeInterceptor);
- nodeInterceptor.setNext(dummy);
-
- TestingUtil.replaceInterceptorChain(cache, interceptor);
-
-// first set up a node with a pojo
- TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
mgr.begin();
Transaction tx = mgr.getTransaction();
@@ -132,29 +138,11 @@
assertEquals(0, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
assertEquals(null, dummy.getCalled());
-
-
- cache.stop();
}
public void testTransactionGetNamesIteratorMethod() throws Exception
{
-
- TestListener listener = new TestListener();
- final CacheSPI<Object, Object> cache = createCacheWithListener(listener);
-
- Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
- Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
- MockInterceptor dummy = new MockInterceptor();
-
- interceptor.setNext(nodeInterceptor);
- nodeInterceptor.setNext(dummy);
-
- TestingUtil.replaceInterceptorChain(cache, interceptor);
-
-// first set up a node with a pojo
- TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
mgr.begin();
Transaction tx = mgr.getTransaction();
@@ -204,8 +192,5 @@
assertEquals(1, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
assertEquals(null, dummy.getCalled());
-
-
- cache.stop();
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -9,10 +9,8 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
-import org.jboss.cache.factories.InterceptorChainFactory;
import org.jboss.cache.interceptors.CallInterceptor;
-import org.jboss.cache.interceptors.Interceptor;
-import org.jboss.cache.loader.SamplePojo;
+import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
@@ -31,7 +29,7 @@
/**
* @author xenephon
*/
-@Test(groups = {"functional"})
+@Test(groups = "functional")
@SuppressWarnings("unchecked")
public class NodeInterceptorRemoveNodeTest extends AbstractOptimisticTestCase
{
@@ -49,19 +47,9 @@
dummy = new MockInterceptor();
dummy.setCache(cache);
- Interceptor interceptor = cache.getInterceptorChain().get(0); // get the first interceptor
- // replace the last (call) interceptor with the mock interceptor.
- Interceptor next = interceptor, prev = interceptor;
- while (!(next instanceof CallInterceptor))
- {
- prev = next;
- next = next.getNext();
- }
+ cache.addInterceptor(dummy, CallInterceptor.class);
+ cache.removeInterceptor(CallInterceptor.class);
- prev.setNext(dummy);
-
- InterceptorChainFactory.setLastInterceptorPointer(interceptor, dummy);
-
mgr = cache.getTransactionManager();
}
@@ -90,15 +78,17 @@
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
mgr.commit();
- assertEquals(null, dummy.getCalled());
+ assert 2 == dummy.getAllCalled().size();
+ assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
+ assert dummy.getAllCalled().contains(MethodDeclarations.optimisticPrepareMethod);
+
//assert what should be the results of our call
assertEquals(0, workspace.getNodes().size());
assertTrue(entry.getLocks().isEmpty());
assertEquals(1, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
- assertEquals(null, dummy.getCalled());
assertEquals(0, listener.getNodesAdded());
}
@@ -111,13 +101,15 @@
cache.getInvocationContext().setTransaction(tx);
cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
- SamplePojo pojo = new SamplePojo(21, "test");
+
Map temp = new HashMap();
- temp.put("key1", pojo);
+ temp.put("key1", "value");
cache.put("/one/two", temp);
cache.removeNode("/one/two");
- assertEquals(null, dummy.getCalled());
+
+ assert dummy.getAllCalled().isEmpty();
+
TransactionTable table = cache.getTransactionTable();
GlobalTransaction gtx = table.get(tx);
@@ -140,7 +132,6 @@
System.out.println(entry.getModifications());
assertEquals(2, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
- assertEquals(null, dummy.getCalled());
}
public void testTransactionRemoveIntermediateNodeMethod() throws Exception
@@ -152,9 +143,9 @@
cache.getInvocationContext().setTransaction(tx);
cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
- SamplePojo pojo = new SamplePojo(21, "test");
+
Map temp = new HashMap();
- temp.put("key1", pojo);
+ temp.put("key1", "value");
cache.put("/one/two", temp);
cache.removeNode("/one");
@@ -179,7 +170,10 @@
assertEquals(1, workspace.getNode(Fqn.fromString("/one")).getMergedChildren().get(0).size());
assertEquals(2, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
- assertEquals(null, dummy.getCalled());
+ assert 2 == dummy.getAllCalled().size();
+ assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
+ assert dummy.getAllCalled().contains(MethodDeclarations.optimisticPrepareMethod);
+
}
public void testTransactionRemoveTwiceMethod() throws Exception
@@ -191,9 +185,9 @@
cache.getInvocationContext().setTransaction(tx);
cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
- SamplePojo pojo = new SamplePojo(21, "test");
+
Map temp = new HashMap();
- temp.put("key1", pojo);
+ temp.put("key1", "value");
cache.put("/one/two", temp);
// get the transaction stuff
@@ -234,7 +228,9 @@
assertEquals(3, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
- assertEquals(null, dummy.getCalled());
+ assert 2 == dummy.getAllCalled().size();
+ assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
+ assert dummy.getAllCalled().contains(MethodDeclarations.optimisticPrepareMethod);
}
@@ -247,9 +243,9 @@
cache.getInvocationContext().setTransaction(tx);
cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
- SamplePojo pojo = new SamplePojo(21, "test");
+
Map temp = new HashMap();
- temp.put("key1", pojo);
+ temp.put("key1", "value");
cache.put("/one/two", temp);
// get the transaction stuff
@@ -292,7 +288,9 @@
assertEquals(3, entry.getModifications().size());
- assertEquals(null, dummy.getCalled());
+ assert 2 == dummy.getAllCalled().size();
+ assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
+ assert dummy.getAllCalled().contains(MethodDeclarations.optimisticPrepareMethod);
assertEquals(2, listener.getNodesAdded());
}
@@ -306,9 +304,9 @@
cache.getInvocationContext().setTransaction(tx);
cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
- SamplePojo pojo = new SamplePojo(21, "test");
+
Map temp = new HashMap();
- temp.put("key1", pojo);
+ temp.put("key1", "value");
cache.put("/one/two", temp);
// get the transaction stuff
@@ -331,8 +329,7 @@
assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isDeleted());
//now put /one back in
- SamplePojo pojo2 = new SamplePojo(21, "test");
- cache.put(new Fqn("one"), "key1", pojo2);
+ cache.put(new Fqn("one"), "key1", "value2");
WorkspaceNode oneAfter = workspace.getNode(Fqn.fromString("/one"));
WorkspaceNode twoAfter = workspace.getNode(Fqn.fromString("/one/two"));
@@ -346,14 +343,17 @@
mgr.commit();
- assertEquals(pojo2, workspace.getNode(Fqn.fromString("/one")).get("key1"));
+ assertEquals("value2", workspace.getNode(Fqn.fromString("/one")).get("key1"));
//assert what should be the results of our call
assertEquals(3, workspace.getNodes().size());
assertEquals(3, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
- assertEquals(null, dummy.getCalled());
+ assert 2 == dummy.getAllCalled().size();
+ assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
+ assert dummy.getAllCalled().contains(MethodDeclarations.optimisticPrepareMethod);
+
assertEquals(2, listener.getNodesAdded());
}
@@ -366,9 +366,9 @@
cache.getInvocationContext().setTransaction(tx);
cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
- SamplePojo pojo = new SamplePojo(21, "test");
+
Map temp = new HashMap();
- temp.put("key1", pojo);
+ temp.put("key1", "value");
cache.put("/one/two", temp);
// get the transaction stuff
@@ -401,7 +401,10 @@
assertEquals(2, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
- assertEquals(null, dummy.getCalled());
+ assert 2 == dummy.getAllCalled().size();
+ assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
+ assert dummy.getAllCalled().contains(MethodDeclarations.optimisticPrepareMethod);
+
assertEquals(2, listener.getNodesAdded());
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -21,9 +21,11 @@
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import javax.transaction.RollbackException;
import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.ObjectInput;
@@ -35,6 +37,7 @@
* @author xenephon
*/
@SuppressWarnings("unchecked")
+@Test(groups = "functional")
public class OptimisticReplicationInterceptorTest extends AbstractOptimisticTestCase
{
private CacheSPI cache;
@@ -459,10 +462,10 @@
CacheSPI cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
MockInterceptor dummy2 = new MockInterceptor();
- setAlteredInterceptorChain(dummy, cache);
+ setAlteredInterceptorChain(dummy2, cache2);
- DummyTransactionManager mgr = DummyTransactionManager.getInstance();
+ TransactionManager mgr = cache.getTransactionManager();
//start local transaction
mgr.begin();
@@ -478,7 +481,6 @@
assertNotNull(mgr.getTransaction());
mgr.commit();
-
assertNull(mgr.getTransaction());
//assert that the local cache is in the right state
@@ -491,6 +493,7 @@
List calls = dummy.getAllCalled();
+
assertEquals(MethodDeclarations.optimisticPrepareMethod, calls.get(0));
assertEquals(MethodDeclarations.commitMethod, calls.get(1));
@@ -515,7 +518,7 @@
List failures = new ArrayList();
failures.add(MethodDeclarations.optimisticPrepareMethod);
dummy2.setFailurelist(failures);
- setAlteredInterceptorChain(dummy, cache);
+ setAlteredInterceptorChain(dummy2, cache2);
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/RemoveBeforeCreateTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/RemoveBeforeCreateTest.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/RemoveBeforeCreateTest.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -9,12 +9,14 @@
import static org.testng.AssertJUnit.assertNull;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
/**
* Tests removal of a node before the node is even created.
*/
+@Test(groups = "functional")
public class RemoveBeforeCreateTest extends AbstractOptimisticTestCase
{
CacheSPI<Object, Object>[] c = null;
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java 2007-12-20 17:09:38 UTC (rev 4897)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java 2007-12-20 17:14:25 UTC (rev 4898)
@@ -3,10 +3,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.interceptors.ActivationInterceptor;
+import org.jboss.cache.interceptors.PassivationInterceptor;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.LocalDelegatingCacheLoader;
import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.util.reflect.ReflectionUtil;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
/**
* Runs a test against using delegated cache loader
@@ -14,6 +18,7 @@
* @author <a href="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
* @version $Id$
*/
+@Test(groups = "functional")
public class PassivationToLocalDelegatingCacheLoaderTest extends PassivationTestsBase
{
CacheSPI delegating_cache;
@@ -31,8 +36,8 @@
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig("", "org.jboss.cache.loader.LocalDelegatingCacheLoader", "", false, false));
cache.getCacheLoaderManager().setCacheLoader(cache_loader);
- // don't actually alter the interceptor chain, but this will force a re-injection of all deps in all components.
- TestingUtil.replaceInterceptorChain(cache, cache.getInterceptorChain().get(0));
+ ReflectionUtil.setValue(TestingUtil.findInterceptor(cache, PassivationInterceptor.class), "loader", cache_loader);
+ ReflectionUtil.setValue(TestingUtil.findInterceptor(cache, ActivationInterceptor.class), "loader", cache_loader);
}
@AfterMethod(alwaysRun = true)
17 years
JBoss Cache SVN: r4897 - core/branches/1.4.X/src/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-12-20 12:09:38 -0500 (Thu, 20 Dec 2007)
New Revision: 4897
Modified:
core/branches/1.4.X/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
Log:
Simplified
Modified: core/branches/1.4.X/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2007-12-20 14:53:11 UTC (rev 4896)
+++ core/branches/1.4.X/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2007-12-20 17:09:38 UTC (rev 4897)
@@ -398,10 +398,7 @@
}
// now make sure all parents are in the wsp as well
- if (workspaceNode != null)
- {
- if (!fqn.isRoot()) getOrCreateWorkspaceNode(fqn.getParent(), workspace, false);
- }
+ if (workspaceNode != null && !fqn.isRoot()) getOrCreateWorkspaceNode(fqn.getParent(), workspace, false);
return workspaceNode;
}
17 years
JBoss Cache SVN: r4896 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-12-20 09:53:11 -0500 (Thu, 20 Dec 2007)
New Revision: 4896
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
Log:
Ability to add and remove interceptors based on interceptor type, not just position
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-12-20 14:19:44 UTC (rev 4895)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-12-20 14:53:11 UTC (rev 4896)
@@ -3735,6 +3735,54 @@
setInterceptorChain(factory.correctInterceptorChaining(i));
}
+ public synchronized void removeInterceptor(Class<? extends Interceptor> interceptorType)
+ {
+ InterceptorChainFactory factory = componentRegistry.getComponent(InterceptorChainFactory.class);
+ List<Interceptor> interceptors = getInterceptors();
+ int position = -1;
+ boolean found = false;
+ for (Interceptor interceptor : interceptors)
+ {
+ position++;
+ if (interceptor.getClass().equals(interceptorType))
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (found)
+ {
+ interceptors.remove(position);
+ setInterceptorChain(factory.correctInterceptorChaining(interceptors));
+ }
+ }
+
+ public synchronized void addInterceptor(Interceptor i, Class<? extends Interceptor> afterInterceptor)
+ {
+ InterceptorChainFactory factory = componentRegistry.getComponent(InterceptorChainFactory.class);
+ List<Interceptor> interceptors = getInterceptors();
+ int position = -1;
+ boolean found = false;
+ for (Interceptor interceptor : interceptors)
+ {
+ position++;
+ if (interceptor.getClass().equals(afterInterceptor))
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (found)
+ {
+ componentRegistry.registerComponent(i);
+ interceptors.add(position++, i);
+ setInterceptorChain(factory.correctInterceptorChaining(interceptors));
+ }
+ }
+
+
public RPCManager getRPCManager()
{
return configuration.getRuntimeConfig().getRPCManager();
Modified: core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2007-12-20 14:19:44 UTC (rev 4895)
+++ core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2007-12-20 14:53:11 UTC (rev 4896)
@@ -100,6 +100,15 @@
void addInterceptor(Interceptor i, int position);
/**
+ * Adds a custom interceptor to the interceptor chain, after an instance of the specified interceptor type. Throws a
+ * cache exception if it cannot find an interceptor of the specified type.
+ *
+ * @param i interceptor to add
+ * @param afterInterceptor interceptor type after which to place custom interceptor
+ */
+ void addInterceptor(Interceptor i, Class<? extends Interceptor> afterInterceptor);
+
+ /**
* Removes the interceptor at a specified position, where the first interceptor in the chain
* is at position 0 and the last one at getInterceptorChain().size() - 1.
*
@@ -108,6 +117,13 @@
void removeInterceptor(int position);
/**
+ * Removes the interceptor of specified type.
+ *
+ * @param interceptorType type of interceptor to remove
+ */
+ void removeInterceptor(Class<? extends Interceptor> interceptorType);
+
+ /**
* Retrieves the current CacheCacheLoaderManager instance associated with the current Cache instance.
* <p/>
* From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java 2007-12-20 14:19:44 UTC (rev 4895)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java 2007-12-20 14:53:11 UTC (rev 4896)
@@ -27,11 +27,11 @@
* <p/>
* Implementation notes:
* Current implementation checks to see the methods that are overwritten and does only perform calls to those methods.
- * This is for avoiding the casts needed to build parameter list. If a non overwritten method is invoked,
+ * This is for avoiding the casts needed to build parameter list. If a non-overridden method is invoked,
* then next interceptor will be called.
*
* @author Mircea.Markus(a)jboss.com
- * @version 2.2
+ * @version 2.1.0
* todo - Refactor stuff in txint
* todo - revisit backward compatibility
*/
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2007-12-20 14:19:44 UTC (rev 4895)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2007-12-20 14:53:11 UTC (rev 4896)
@@ -121,11 +121,21 @@
cache.addInterceptor(i, position);
}
+ public void addInterceptor(Interceptor i, Class<? extends Interceptor> afterInterceptor)
+ {
+ cache.addInterceptor(i, afterInterceptor);
+ }
+
public void removeInterceptor(int position)
{
cache.removeInterceptor(position);
}
+ public void removeInterceptor(Class<? extends Interceptor> interceptorType)
+ {
+ cache.removeInterceptor(interceptorType);
+ }
+
public CacheLoaderManager getCacheLoaderManager()
{
return cacheLoaderManager;
Modified: core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2007-12-20 14:19:44 UTC (rev 4895)
+++ core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2007-12-20 14:53:11 UTC (rev 4896)
@@ -13,7 +13,6 @@
import org.jboss.cache.CacheStatus;
import org.jboss.cache.Fqn;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.InterceptorChainFactory;
import org.jboss.cache.interceptors.Interceptor;
import org.jboss.cache.invocation.RemoteCacheInvocationDelegate;
import org.jboss.cache.loader.CacheLoader;
@@ -527,15 +526,8 @@
ComponentRegistry cr = extractComponentRegistry(cache);
// This will replace the previous interceptor chain in the component registry
+ // as well as update dependencies!
cr.registerComponent(Interceptor.class.getName(), interceptor);
-
- // update all component dependencies
- cr.updateDependencies();
-
- InterceptorChainFactory factory = cr.getComponent(InterceptorChainFactory.class);
-
- // make sure the new interceptors have their deps satisfied.
- factory.correctInterceptorChaining(interceptor);
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2007-12-20 14:19:44 UTC (rev 4895)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2007-12-20 14:53:11 UTC (rev 4896)
@@ -10,12 +10,13 @@
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.interceptors.CacheMgmtInterceptor;
+import org.jboss.cache.interceptors.CallInterceptor;
import org.jboss.cache.interceptors.Interceptor;
-import org.jboss.cache.interceptors.InvocationContextInterceptor;
-import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
+import org.jboss.cache.interceptors.NotificationInterceptor;
+import org.jboss.cache.interceptors.OptimisticLockingInterceptor;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
-import org.jboss.cache.interceptors.OptimisticReplicationInterceptor;
-import org.jboss.cache.interceptors.TxInterceptor;
+import org.jboss.cache.interceptors.OptimisticValidatorInterceptor;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
@@ -284,37 +285,14 @@
}
}
- protected Interceptor getAlteredInterceptorChain(Interceptor newLast, CacheSPI<Object, Object> spi, boolean replicated)
+ protected void setAlteredInterceptorChain(Interceptor newLast, CacheSPI<Object, Object> spi)
{
- Interceptor ici = new InvocationContextInterceptor();
- ici.setCache(spi);
-
- Interceptor txInterceptor = new TxInterceptor();
- txInterceptor.setCache(spi);
-
- Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
- replicationInterceptor.setCache(spi);
-
- Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
- createInterceptor.setCache(spi);
-
- Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
- nodeInterceptor.setCache(spi);
-
- ici.setNext(txInterceptor);
- if (replicated)
- {
- txInterceptor.setNext(replicationInterceptor);
- replicationInterceptor.setNext(createInterceptor);
- }
- else
- {
- txInterceptor.setNext(createInterceptor);
- }
- createInterceptor.setNext(nodeInterceptor);
- nodeInterceptor.setNext(newLast);
-
- return ici;
+ spi.removeInterceptor(CacheMgmtInterceptor.class);
+ spi.removeInterceptor(NotificationInterceptor.class);
+ spi.removeInterceptor(OptimisticLockingInterceptor.class);
+ spi.removeInterceptor(OptimisticValidatorInterceptor.class);
+ spi.removeInterceptor(CallInterceptor.class);
+ spi.addInterceptor(newLast, OptimisticNodeInterceptor.class);
}
public abstract class ExceptionThread extends Thread
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2007-12-20 14:19:44 UTC (rev 4895)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2007-12-20 14:53:11 UTC (rev 4896)
@@ -131,7 +131,7 @@
public void testLocalTransaction() throws Exception
{
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(c, getAlteredInterceptorChain(dummy, c, true));
+ setAlteredInterceptorChain(dummy, c);
TransactionManager mgr = c.getConfiguration().getRuntimeConfig().getTransactionManager();
assertNull(mgr.getTransaction());
@@ -166,7 +166,7 @@
c = createCacheWithListener();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(c, getAlteredInterceptorChain(dummy, c, true));
+ setAlteredInterceptorChain(dummy, c);
TransactionManager mgr = c.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -196,7 +196,7 @@
c = createCacheWithListener();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(c, getAlteredInterceptorChain(dummy, c, true));
+ setAlteredInterceptorChain(dummy, c);
TransactionManager mgr = c.getConfiguration().getRuntimeConfig().getTransactionManager();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2007-12-20 14:19:44 UTC (rev 4895)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2007-12-20 14:53:11 UTC (rev 4896)
@@ -55,7 +55,7 @@
public void testLocalTransaction() throws Exception
{
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
assertNull(mgr.getTransaction());
@@ -86,7 +86,7 @@
public void testRollbackTransaction() throws Exception
{
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
assertNull(mgr.getTransaction());
@@ -112,7 +112,7 @@
public void testRemotePrepareTransaction() throws Exception
{
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
@@ -177,7 +177,7 @@
public void testRemoteRollbackTransaction() throws Exception
{
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
@@ -256,7 +256,7 @@
public void testRemoteCommitNoPrepareTransaction() throws Exception
{
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
@@ -317,7 +317,7 @@
public void testRemoteRollbackNoPrepareTransaction() throws Throwable
{
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
@@ -372,7 +372,7 @@
public void testRemoteCommitTransaction() throws Exception
{
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
@@ -455,11 +455,11 @@
cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
CacheSPI cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
MockInterceptor dummy2 = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache2, getAlteredInterceptorChain(dummy2, cache2, true));
+ setAlteredInterceptorChain(dummy, cache);
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
@@ -508,14 +508,14 @@
cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
CacheSPI cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
MockFailureInterceptor dummy2 = new MockFailureInterceptor();
List failures = new ArrayList();
failures.add(MethodDeclarations.optimisticPrepareMethod);
dummy2.setFailurelist(failures);
- TestingUtil.replaceInterceptorChain(cache2, getAlteredInterceptorChain(dummy2, cache2, true));
+ setAlteredInterceptorChain(dummy, cache);
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
@@ -571,11 +571,11 @@
cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
MockFailureInterceptor dummy = new MockFailureInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
CacheSPI cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
MockInterceptor dummy2 = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache2, getAlteredInterceptorChain(dummy2, cache2, true));
+ setAlteredInterceptorChain(dummy, cache);
List failures = new ArrayList();
failures.add(MethodDeclarations.optimisticPrepareMethod);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2007-12-20 14:19:44 UTC (rev 4895)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2007-12-20 14:53:11 UTC (rev 4896)
@@ -38,7 +38,7 @@
{
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, false));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
assertNull(mgr.getTransaction());
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
@@ -66,7 +66,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, false));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -103,7 +103,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, false));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -134,7 +134,7 @@
{
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, false));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -162,7 +162,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, false));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -190,7 +190,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, false));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -233,7 +233,7 @@
{
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, false));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -270,7 +270,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, false));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -339,7 +339,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, false));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -421,7 +421,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -510,7 +510,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -598,7 +598,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -690,7 +690,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, true));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -777,7 +777,7 @@
CacheSPI<Object, Object> cache = createCache();
MockInterceptor dummy = new MockInterceptor();
- TestingUtil.replaceInterceptorChain(cache, getAlteredInterceptorChain(dummy, cache, false));
+ setAlteredInterceptorChain(dummy, cache);
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
17 years
JBoss Cache SVN: r4895 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-12-20 09:19:44 -0500 (Thu, 20 Dec 2007)
New Revision: 4895
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java
Log:
Why does the overriddenMethods collection need to be a TreeSet?
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java 2007-12-20 14:18:19 UTC (rev 4894)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java 2007-12-20 14:19:44 UTC (rev 4895)
@@ -11,10 +11,10 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.TreeSet;
/**
* The purpose of this interceptor is to supply a nicer way of handling the interception of desired methods:
@@ -40,7 +40,7 @@
/**
* List of the method the extending interceptor pverwrites. It is only those methods that will be called.
*/
- private Set<Integer> overriddenMethods = new TreeSet<Integer>();
+ private Set<Integer> overriddenMethods = new HashSet<Integer>();
protected MethodDispacherInterceptor()
{
17 years
JBoss Cache SVN: r4894 - in core/trunk/src: test/java/org/jboss/cache/loader and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-12-20 09:18:19 -0500 (Thu, 20 Dec 2007)
New Revision: 4894
Removed:
core/trunk/src/test/java/org/jboss/cache/loader/DummyCacheLoader.java
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
Log:
Updated
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java 2007-12-20 14:03:02 UTC (rev 4893)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java 2007-12-20 14:18:19 UTC (rev 4894)
@@ -40,11 +40,11 @@
/**
* List of the method the extending interceptor pverwrites. It is only those methods that will be called.
*/
- private Set<Integer> overwrittenMethods = new TreeSet<Integer>();
+ private Set<Integer> overriddenMethods = new TreeSet<Integer>();
protected MethodDispacherInterceptor()
{
- processOverwritternMethods();
+ findOverriddenMethods();
}
/**
@@ -61,7 +61,7 @@
return nextInterceptor(ctx);
}
MethodCall m = ctx.getMethodCall();
- if (!overwrittenMethods.contains(m.getMethodId()))
+ if (!overriddenMethods.contains(m.getMethodId()))
{
log.trace("Not registered for any handlers, passing up the chain.");
return nextInterceptor(ctx);
@@ -371,7 +371,7 @@
}
/**
- * Handles {@link org.jboss.cache.CacheImpl#getKeys(Fqn)}
+ * Handles {@link org.jboss.cache.Cache#getKeys(Fqn)}
*/
protected Object handleGetKeysMethod(InvocationContext ctx, Fqn fqn) throws Throwable
{
@@ -481,46 +481,46 @@
/**
* Builds the list of methods that are overwiritten.
*/
- private void processOverwritternMethods()
+ private void findOverriddenMethods()
{
- checkIfOverwritten(MethodDeclarations.putDataEraseMethodLocal_id, "handlePutDataEraseMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, boolean.class, boolean.class);
- checkIfOverwritten(MethodDeclarations.putDataMethodLocal_id, "handlePutDataMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, boolean.class);
- checkIfOverwritten(MethodDeclarations.putForExternalReadMethodLocal_id, "handlePutForExternalReadMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class);
- checkIfOverwritten(MethodDeclarations.putKeyValMethodLocal_id, "handlePutKeyValueMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class, boolean.class);
- checkIfOverwritten(MethodDeclarations.moveMethodLocal_id, "handleMoveMethod", InvocationContext.class, Fqn.class, Fqn.class);
- checkIfOverwritten(MethodDeclarations.addChildMethodLocal_id, "handleAddChildMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Node.class, boolean.class);
- checkIfOverwritten(MethodDeclarations.getKeyValueMethodLocal_id, "handleGetKeyValueMethod", InvocationContext.class, Fqn.class, Object.class, boolean.class);
- checkIfOverwritten(MethodDeclarations.getNodeMethodLocal_id, "handleGetNodeMethod", InvocationContext.class, Fqn.class);
- checkIfOverwritten(MethodDeclarations.getChildrenNamesMethodLocal_id, "handleGetChildrenNamesMethod", InvocationContext.class, Fqn.class);
- checkIfOverwritten(MethodDeclarations.releaseAllLocksMethodLocal_id, "handleReleaseAllLocksMethod", InvocationContext.class, Fqn.class);
- checkIfOverwritten(MethodDeclarations.printMethodLocal_id, "handlePrintMethod", InvocationContext.class, Fqn.class);
- checkIfOverwritten(MethodDeclarations.getKeysMethodLocal_id, "handleGetKeysMethod", InvocationContext.class, Fqn.class);
- checkIfOverwritten(MethodDeclarations.getDataMapMethodLocal_id, "handleGetDataMapMethod", InvocationContext.class, Fqn.class);
- checkIfOverwritten(MethodDeclarations.rollbackMethod_id, "handleRollbackMethod", InvocationContext.class, GlobalTransaction.class);
- checkIfOverwritten(MethodDeclarations.removeNodeMethodLocal_id, "handleRemoveNodeMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class);
- checkIfOverwritten(MethodDeclarations.removeKeyMethodLocal_id, "handleRemoveKeyMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, boolean.class);
- checkIfOverwritten(MethodDeclarations.removeDataMethodLocal_id, "handleRemoveDataMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class);
- checkIfOverwritten(MethodDeclarations.commitMethod_id, "handleCommitMethod", InvocationContext.class, GlobalTransaction.class);
- checkIfOverwritten(MethodDeclarations.optimisticPrepareMethod_id, "handleOptimisticPrepareMethod", InvocationContext.class, GlobalTransaction.class, List.class, Map.class, Address.class, boolean.class);
- checkIfOverwritten(MethodDeclarations.prepareMethod_id, "handlePrepareMethod", InvocationContext.class, GlobalTransaction.class, List.class, Address.class, boolean.class);
- checkIfOverwritten(MethodDeclarations.evictNodeMethodLocal_id, "handleEvictMethod", InvocationContext.class, Fqn.class);
- checkIfOverwritten(MethodDeclarations.evictVersionedNodeMethodLocal_id, "handleEvictVersionedNodeMethod", InvocationContext.class, Fqn.class, DataVersion.class);
- checkIfOverwritten(MethodDeclarations.existsMethod_id, "handleExistsMethod", InvocationContext.class, Fqn.class);
- checkIfOverwritten(MethodDeclarations.putDataEraseVersionedMethodLocal_id, "handlePutDataEraseVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, boolean.class, boolean.class, DataVersion.class);
- checkIfOverwritten(MethodDeclarations.putDataVersionedMethodLocal_id, "handlePutDataVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, Boolean.class, DataVersion.class);
- checkIfOverwritten(MethodDeclarations.putKeyValVersionedMethodLocal_id, "handlePutKeyValueVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class, boolean.class, DataVersion.class);
- checkIfOverwritten(MethodDeclarations.putForExternalReadVersionedMethodLocal_id, "handlePutForExternalReadVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class, DataVersion.class);
- checkIfOverwritten(MethodDeclarations.dataGravitationCleanupMethod_id, "handleDataGravitationCleanupMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Fqn.class);
- checkIfOverwritten(MethodDeclarations.removeNodeVersionedMethodLocal_id, "handleRemoveNodeVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class, DataVersion.class);
- checkIfOverwritten(MethodDeclarations.removeKeyVersionedMethodLocal_id, "handleRemoveKeyVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, boolean.class, DataVersion.class);
- checkIfOverwritten(MethodDeclarations.removeDataVersionedMethodLocal_id, "handleRemoveDataVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class, DataVersion.class);
- checkIfOverwritten(MethodDeclarations.blockChannelMethodLocal_id, "handleBlockChannelMethod", InvocationContext.class);
- checkIfOverwritten(MethodDeclarations.unblockChannelMethodLocal_id, "handleUnblockChannelMethod", InvocationContext.class);
- checkIfOverwritten(MethodDeclarations.lockMethodLocal_id, "handleLockMethod", InvocationContext.class, Fqn.class, NodeLock.LockType.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.putDataEraseMethodLocal_id, "handlePutDataEraseMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, boolean.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.putDataMethodLocal_id, "handlePutDataMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.putForExternalReadMethodLocal_id, "handlePutForExternalReadMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class);
+ checkIfOverridden(MethodDeclarations.putKeyValMethodLocal_id, "handlePutKeyValueMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.moveMethodLocal_id, "handleMoveMethod", InvocationContext.class, Fqn.class, Fqn.class);
+ checkIfOverridden(MethodDeclarations.addChildMethodLocal_id, "handleAddChildMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Node.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.getKeyValueMethodLocal_id, "handleGetKeyValueMethod", InvocationContext.class, Fqn.class, Object.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.getNodeMethodLocal_id, "handleGetNodeMethod", InvocationContext.class, Fqn.class);
+ checkIfOverridden(MethodDeclarations.getChildrenNamesMethodLocal_id, "handleGetChildrenNamesMethod", InvocationContext.class, Fqn.class);
+ checkIfOverridden(MethodDeclarations.releaseAllLocksMethodLocal_id, "handleReleaseAllLocksMethod", InvocationContext.class, Fqn.class);
+ checkIfOverridden(MethodDeclarations.printMethodLocal_id, "handlePrintMethod", InvocationContext.class, Fqn.class);
+ checkIfOverridden(MethodDeclarations.getKeysMethodLocal_id, "handleGetKeysMethod", InvocationContext.class, Fqn.class);
+ checkIfOverridden(MethodDeclarations.getDataMapMethodLocal_id, "handleGetDataMapMethod", InvocationContext.class, Fqn.class);
+ checkIfOverridden(MethodDeclarations.rollbackMethod_id, "handleRollbackMethod", InvocationContext.class, GlobalTransaction.class);
+ checkIfOverridden(MethodDeclarations.removeNodeMethodLocal_id, "handleRemoveNodeMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.removeKeyMethodLocal_id, "handleRemoveKeyMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.removeDataMethodLocal_id, "handleRemoveDataMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.commitMethod_id, "handleCommitMethod", InvocationContext.class, GlobalTransaction.class);
+ checkIfOverridden(MethodDeclarations.optimisticPrepareMethod_id, "handleOptimisticPrepareMethod", InvocationContext.class, GlobalTransaction.class, List.class, Map.class, Address.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.prepareMethod_id, "handlePrepareMethod", InvocationContext.class, GlobalTransaction.class, List.class, Address.class, boolean.class);
+ checkIfOverridden(MethodDeclarations.evictNodeMethodLocal_id, "handleEvictMethod", InvocationContext.class, Fqn.class);
+ checkIfOverridden(MethodDeclarations.evictVersionedNodeMethodLocal_id, "handleEvictVersionedNodeMethod", InvocationContext.class, Fqn.class, DataVersion.class);
+ checkIfOverridden(MethodDeclarations.existsMethod_id, "handleExistsMethod", InvocationContext.class, Fqn.class);
+ checkIfOverridden(MethodDeclarations.putDataEraseVersionedMethodLocal_id, "handlePutDataEraseVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, boolean.class, boolean.class, DataVersion.class);
+ checkIfOverridden(MethodDeclarations.putDataVersionedMethodLocal_id, "handlePutDataVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, Boolean.class, DataVersion.class);
+ checkIfOverridden(MethodDeclarations.putKeyValVersionedMethodLocal_id, "handlePutKeyValueVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class, boolean.class, DataVersion.class);
+ checkIfOverridden(MethodDeclarations.putForExternalReadVersionedMethodLocal_id, "handlePutForExternalReadVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class, DataVersion.class);
+ checkIfOverridden(MethodDeclarations.dataGravitationCleanupMethod_id, "handleDataGravitationCleanupMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Fqn.class);
+ checkIfOverridden(MethodDeclarations.removeNodeVersionedMethodLocal_id, "handleRemoveNodeVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class, DataVersion.class);
+ checkIfOverridden(MethodDeclarations.removeKeyVersionedMethodLocal_id, "handleRemoveKeyVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, boolean.class, DataVersion.class);
+ checkIfOverridden(MethodDeclarations.removeDataVersionedMethodLocal_id, "handleRemoveDataVersionedMethod", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class, DataVersion.class);
+ checkIfOverridden(MethodDeclarations.blockChannelMethodLocal_id, "handleBlockChannelMethod", InvocationContext.class);
+ checkIfOverridden(MethodDeclarations.unblockChannelMethodLocal_id, "handleUnblockChannelMethod", InvocationContext.class);
+ checkIfOverridden(MethodDeclarations.lockMethodLocal_id, "handleLockMethod", InvocationContext.class, Fqn.class, NodeLock.LockType.class, boolean.class);
}
- private void checkIfOverwritten(int putDataEraseMethodLocal_id, String methodName, Class... args)
+ private void checkIfOverridden(int methodId, String methodName, Class... args)
{
Class currentClass = getClass();
//if this is a > 1 inheritace deepth and the method was overwritten in the parent. We also have to look into parents
@@ -529,7 +529,7 @@
try
{
currentClass.getDeclaredMethod(methodName, args);
- this.overwrittenMethods.add(putDataEraseMethodLocal_id);
+ this.overriddenMethods.add(methodId);
}
catch (NoSuchMethodException e)
{
Deleted: core/trunk/src/test/java/org/jboss/cache/loader/DummyCacheLoader.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/DummyCacheLoader.java 2007-12-20 14:03:02 UTC (rev 4893)
+++ core/trunk/src/test/java/org/jboss/cache/loader/DummyCacheLoader.java 2007-12-20 14:18:19 UTC (rev 4894)
@@ -1,231 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.loader;
-
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.cache.CacheImpl;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-
-/**
- * Dummy cache loader that captures the number of times each method is called.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- */
-public class DummyCacheLoader extends AbstractCacheLoader
-{
- private int getChildrenNamesCount = 0, getCount = 0, putCount = 0, existsCount = 0, removeCount = 0;
-
- public int getGetChildrenNamesCount()
- {
- return getChildrenNamesCount;
- }
-
- public int getGetCount()
- {
- return getCount;
- }
-
- public int getPutCount()
- {
- return putCount;
- }
-
- public int getExistsCount()
- {
- return existsCount;
- }
-
- public int getRemoveCount()
- {
- return removeCount;
- }
-
-
- /**
- * Sets the configuration. Will be called before {@link #create()} and {@link #start()}
- */
- public void setConfig(IndividualCacheLoaderConfig config)
- {
- }
-
- public IndividualCacheLoaderConfig getConfig()
- {
- return null;
- }
-
- /**
- * This method allows the CacheLoader to set the CacheImpl, therefore allowing the CacheLoader to invoke
- * methods of the CacheImpl. It can also use the CacheImpl to fetch configuration information. Alternatively,
- * the CacheLoader could maintain its own configuration<br/>
- * This method will be called directly after the CacheLoader instance has been created
- *
- * @param c The cache on which this loader works
- */
- public void setCache(CacheImpl c)
- {
- }
-
- /**
- * Returns a list of children names, all names are <em>relative</em>. Returns null if the parent node is not found.
- * The returned set must not be modified, e.g. use Collections.unmodifiableSet(s) to return the result
- *
- * @param fqn The FQN of the parent
- * @return Set<String>. A list of children. Returns null if no children nodes are present, or the parent is
- * not present
- */
- public Set<String> getChildrenNames(Fqn fqn) throws Exception
- {
- getChildrenNamesCount++;
- return null;
- }
-
- /**
- * Returns the value for a given key. Returns null if the node doesn't exist, or the value is not bound
- *
- * @param name
- * @return
- * @throws Exception
- */
- public Object get(Fqn name, Object key) throws Exception
- {
- getCount++;
- return null;
- }
-
- /**
- * Returns all keys and values from the persistent store, given a fully qualified name
- *
- * @param name
- * @return Map<Object,Object> of keys and values for the given node. Returns null if the node was not found, or
- * if the node has no attributes
- * @throws Exception
- */
- public Map<Object, Object> get(Fqn name) throws Exception
- {
- getCount++;
- return null;
- }
-
- /**
- * Checks whether the CacheLoader has a node with Fqn
- *
- * @param name
- * @return True if node exists, false otherwise
- */
- public boolean exists(Fqn name) throws Exception
- {
- existsCount++;
- return false;
- }
-
- /**
- * Inserts key and value into the attributes hashmap of the given node. If the node does not exist, all
- * parent nodes from the root down are created automatically. Returns the old value
- */
- public Object put(Fqn name, Object key, Object value) throws Exception
- {
- putCount++;
- return null;
- }
-
- /**
- * Inserts all elements of attributes into the attributes hashmap of the given node, overwriting existing
- * attributes, but not clearing the existing hashmap before insertion (making it a union of existing and
- * new attributes)
- * If the node does not exist, all parent nodes from the root down are created automatically
- *
- * @param name The fully qualified name of the node
- * @param attributes A Map of attributes. Can be null
- */
- public void put(Fqn name, Map attributes) throws Exception
- {
- putCount++;
- }
-
- /**
- * Inserts all modifications to the backend store. Overwrite whatever is already in
- * the datastore.
- *
- * @param modifications A List<Modification> of modifications
- * @throws Exception
- */
- public void put(List<Modification> modifications) throws Exception
- {
- putCount++;
- }
-
- /**
- * Removes the given key and value from the attributes of the given node. No-op if node doesn't exist
- */
- public Object remove(Fqn name, Object key) throws Exception
- {
- removeCount++;
- return null;
- }
-
- /**
- * Removes the given node. If the node is the root of a subtree, this will recursively remove all subnodes,
- * depth-first
- */
- public void remove(Fqn name) throws Exception
- {
- removeCount++;
- }
-
- /**
- * Removes all attributes from a given node, but doesn't delete the node itself
- *
- * @param name
- * @throws Exception
- */
- public void removeData(Fqn name) throws Exception
- {
- removeCount++;
- }
-
- @Override
- public void loadEntireState(ObjectOutputStream os) throws Exception
- {
- //intentional no-op
- }
-
- @Override
- public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
- {
- // intentional no-op
- }
-
- @Override
- public void storeEntireState(ObjectInputStream is) throws Exception
- {
- // intentional no-op
- }
-
- @Override
- public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
- {
- // intentional no-op
- }
-
-
- @Override
- public void destroy()
- {
- getChildrenNamesCount = 0;
- getCount = 0;
- putCount = 0;
- existsCount = 0;
- removeCount = 0;
- }
-}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2007-12-20 14:03:02 UTC (rev 4893)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2007-12-20 14:18:19 UTC (rev 4894)
@@ -128,8 +128,7 @@
protected void destroyCache(Cache<Object, Object> c)
{
- c.stop();
- c.destroy();
+ TestingUtil.killCaches(c);
}
17 years
JBoss Cache SVN: r4893 - core/branches/1.4.X/etc.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-12-20 09:03:02 -0500 (Thu, 20 Dec 2007)
New Revision: 4893
Modified:
core/branches/1.4.X/etc/log4j.xml
Log:
Too verbose!
Modified: core/branches/1.4.X/etc/log4j.xml
===================================================================
--- core/branches/1.4.X/etc/log4j.xml 2007-12-20 13:55:39 UTC (rev 4892)
+++ core/branches/1.4.X/etc/log4j.xml 2007-12-20 14:03:02 UTC (rev 4893)
@@ -79,7 +79,7 @@
-->
<category name="org.jboss.cache">
- <priority value="TRACE"/>
+ <priority value="WARN"/>
</category>
<category name="org.jboss">
@@ -95,8 +95,8 @@
<!-- ======================= -->
<root>
- <appender-ref ref="CONSOLE"/>
- <!--<appender-ref ref="FILE"/>-->
+ <!--<appender-ref ref="CONSOLE"/>-->
+ <appender-ref ref="FILE"/>
</root>
</log4j:configuration>
17 years
JBoss Cache SVN: r4892 - core/branches/1.4.X.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-12-20 08:55:39 -0500 (Thu, 20 Dec 2007)
New Revision: 4892
Modified:
core/branches/1.4.X/build.xml
Log:
JUnit maxmem not adhered to with some unit tests
Modified: core/branches/1.4.X/build.xml
===================================================================
--- core/branches/1.4.X/build.xml 2007-12-20 03:30:36 UTC (rev 4891)
+++ core/branches/1.4.X/build.xml 2007-12-20 13:55:39 UTC (rev 4892)
@@ -536,7 +536,7 @@
<target name="functionaltests" depends="compile,test-jar,unittests-init"
description="Runs all non-AOP functional tests">
- <junit printsummary="yes" timeout="${junit.timeout}" fork="yes" maxmemory="256m">
+ <junit printsummary="yes" timeout="${junit.timeout}" fork="yes" maxmemory="${junit.maxmem}">
<classpath refid="library.classpath"/>
<classpath refid="output.classpath"/>
<jvmarg value="-Dbind.address=${bind.address}"/>
17 years