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);
}