package org.jboss.cache.interceptors;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.util.BitEncodedIntegerSet;
import org.jgroups.Address;
import java.util.List;
import java.util.Map;
/**
* The purpose of this interceptor is to supply a nicer way of handling the interception of desired methods:
* <pre>
* - one can regiter to be notified on an particular method call by extending handle<i>CalledMethod</i> method.
* This would result in removal of switch statemenets in invoke
* - the parameters of the hendler methods are passes in strongly typed, rather than as an array of Objects
* </pre>
* This interceptor acts as a switch that delegates method calls to handlers/methods.
* <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-overridden method is invoked,
* then next interceptor will be called.
*
* @author Mircea.Markus@jboss.com
* @version 2.1.0
* todo - Refactor stuff in txint
*/
public abstract class MethodDispacherInterceptor extends Interceptor
{
/**
* Methods that have been overridden.
*/
private BitEncodedIntegerSet overriddenMethods = new BitEncodedIntegerSet();
protected MethodDispacherInterceptor()
{
findOverriddenMethods();
}
/**
* Acts like a 'switch case' that delegates the call to the appropriate method.
*/
public Object invoke(InvocationContext ctx) throws Throwable
{
if (trace) log.trace("Invoked with method call " + ctx.getMethodCall());
MethodCall m = ctx.getMethodCall();
if (!overriddenMethods.contains(m.getMethodId()) || skipMethodCall(ctx))
{
if (trace) log.trace("Not registered for any handlers, or instructed to skip call. Passing up the chain.");
return nextInterceptor(ctx);
}
Object[] args = m.getArgs();
Object result;
switch (m.getMethodId())
{
case MethodDeclarations.putDataEraseMethodLocal_id:
result = handlePutDataEraseMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Map) args[2], (Boolean) args[3], (Boolean) args[4]);
break;
case MethodDeclarations.putDataMethodLocal_id:
result = handlePutDataMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Map) args[2], (Boolean) args[3]);
break;
case MethodDeclarations.putForExternalReadMethodLocal_id:
result = handlePutForExternalReadMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], args[3]);
break;
case MethodDeclarations.putKeyValMethodLocal_id:
result = handlePutKeyValueMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], args[3], (Boolean) args[4]);
break;
case MethodDeclarations.moveMethodLocal_id:
result = handleMoveMethod(ctx, (Fqn) args[0], (Fqn) args[1]);
break;
case MethodDeclarations.addChildMethodLocal_id:
result = handleAddChildMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], (Node) args[3], (Boolean) args[4]);
break;
case MethodDeclarations.getKeyValueMethodLocal_id:
result = handleGetKeyValueMethod(ctx, (Fqn) args[0], args[1], (Boolean) args[2]);
break;
case MethodDeclarations.getNodeMethodLocal_id:
result = handleGetNodeMethod(ctx, (Fqn) args[0]);
break;
case MethodDeclarations.getChildrenNamesMethodLocal_id:
result = handleGetChildrenNamesMethod(ctx, (Fqn) args[0]);
break;
case MethodDeclarations.releaseAllLocksMethodLocal_id:
result = handleReleaseAllLocksMethod(ctx, (Fqn) args[0]);
break;
case MethodDeclarations.printMethodLocal_id:
result = handlePrintMethod(ctx, (Fqn) args[0]);
break;
case MethodDeclarations.getKeysMethodLocal_id:
result = handleGetKeysMethod(ctx, (Fqn) args[0]);
break;
case MethodDeclarations.getDataMapMethodLocal_id:
result = handleGetDataMapMethod(ctx, (Fqn) args[0]);
break;
case MethodDeclarations.rollbackMethod_id:
result = handleRollbackMethod(ctx, (GlobalTransaction) args[0]);
break;
case MethodDeclarations.removeNodeMethodLocal_id:
result = handleRemoveNodeMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Boolean) args[2]);
break;
case MethodDeclarations.removeKeyMethodLocal_id:
result = handleRemoveKeyMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], (Boolean) args[3]);
break;
case MethodDeclarations.removeDataMethodLocal_id:
result = handleRemoveDataMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Boolean) args[2]);
break;
case MethodDeclarations.commitMethod_id:
result = handleCommitMethod(ctx, (GlobalTransaction) args[0]);
break;
case MethodDeclarations.optimisticPrepareMethod_id:
result = handleOptimisticPrepareMethod(ctx, (GlobalTransaction) args[0], (List) args[1], (Map) args[2], (Address) args[3], (Boolean) args[4]);
break;
case MethodDeclarations.prepareMethod_id:
result = handlePrepareMethod(ctx, (GlobalTransaction) args[0], (List) args[1], (Address) args[2], (Boolean) args[3]);
break;
case MethodDeclarations.evictNodeMethodLocal_id:
result = handleEvictMethod(ctx, (Fqn) args[0]);
break;
case MethodDeclarations.evictVersionedNodeMethodLocal_id:
result = handleEvictVersionedNodeMethod(ctx, (Fqn) args[0], (DataVersion) args[1]);
break;
case MethodDeclarations.existsMethod_id:
result = handleExistsMethod(ctx, (Fqn) args[0]);
break;
case MethodDeclarations.putDataEraseVersionedMethodLocal_id:
result = handlePutDataEraseVersionedMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Map) args[2], (Boolean) args[3], (Boolean) args[4], (DataVersion) args[5]);
break;
case MethodDeclarations.putDataVersionedMethodLocal_id:
result = handlePutDataVersionedMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Map) args[2], (Boolean) args[3], (DataVersion) args[4]);
break;
case MethodDeclarations.putKeyValVersionedMethodLocal_id:
result = handlePutKeyValueVersionedMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], args[3], (Boolean) args[4], (DataVersion) args[5]);
break;
case MethodDeclarations.putForExternalReadVersionedMethodLocal_id:
result = handlePutForExternalReadVersionedMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], args[3], (DataVersion) args[5]);
break;
case MethodDeclarations.dataGravitationCleanupMethod_id:
result = handleDataGravitationCleanupMethod(ctx, (Fqn) args[0], (Fqn) args[1]);
break;
case MethodDeclarations.removeNodeVersionedMethodLocal_id:
result = handleRemoveNodeVersionedMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Boolean) args[2], (DataVersion) args[3]);
break;
case MethodDeclarations.removeKeyVersionedMethodLocal_id:
result = handleRemoveKeyVersionedMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], (Boolean) args[3], (DataVersion) args[4]);
break;
case MethodDeclarations.removeDataVersionedMethodLocal_id:
result = handleRemoveDataVersionedMethod(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Boolean) args[2], (DataVersion) args[3]);
break;
case MethodDeclarations.blockChannelMethodLocal_id:
result = handleBlockChannelMethod(ctx);
break;
case MethodDeclarations.unblockChannelMethodLocal_id:
result = handleUnblockChannelMethod(ctx);
break;
case MethodDeclarations.lockMethodLocal_id:
result = handleLockMethod(ctx, (Fqn) args[0], (NodeLock.LockType) args[1], (Boolean) args[2]);
break;
default:
return nextInterceptor(ctx);
}
return result;
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_lock(org.jboss.cache.Fqn, org.jboss.cache.lock.NodeLock.LockType, boolean)}
*/
protected Object handleLockMethod(InvocationContext ctx, Fqn fqn, NodeLock.LockType lockType, boolean recursive) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_unblock()}
*/
protected Object handleUnblockChannelMethod(InvocationContext ctx) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_block()}
*/
protected Object handleBlockChannelMethod(InvocationContext ctx) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_removeData(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, boolean, org.jboss.cache.optimistic.DataVersion)}
*/
protected Object handleRemoveDataVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, boolean createUndoOps, DataVersion dv) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_remove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, boolean, org.jboss.cache.optimistic.DataVersion)}
*/
protected Object handleRemoveKeyVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, boolean createUndoOps, DataVersion dv) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_remove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, boolean, org.jboss.cache.optimistic.DataVersion)}
*/
protected Object handleRemoveNodeVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, boolean createUndoOps, DataVersion dv) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.invocation.RemoteCacheInvocationDelegate#dataGravitationCleanup(org.jboss.cache.Fqn, org.jboss.cache.Fqn)}
*/
protected Object handleDataGravitationCleanupMethod(InvocationContext ctx, Fqn primary, Fqn backup) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_putForExternalRead(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, Object, org.jboss.cache.optimistic.DataVersion)}
*/
protected Object handlePutForExternalReadVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, Object value, DataVersion dv) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, Object, boolean, org.jboss.cache.optimistic.DataVersion)}
*/
protected Object handlePutKeyValueVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps, DataVersion dv) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, org.jboss.cache.optimistic.DataVersion)}
*/
protected Object handlePutDataVersionedMethod(InvocationContext ctx, GlobalTransaction globalTransaction, Fqn fqn, Map map, Boolean createUndoOps, DataVersion dataVersion) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, boolean, org.jboss.cache.optimistic.DataVersion)}
*/
protected Object handlePutDataEraseVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Map data, boolean createUndoOps, boolean eraseContent, DataVersion dv) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#exists(String)}
*/
protected Object handleExistsMethod(InvocationContext ctx, Fqn fqn) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Each interceptor should extend this if it does not need any processing for current call.
* An sample usage would be: this interceptor is only interested if thre is one transaction going on. If so all
* handleXYZ would know that we have a transaction going and would not check its state.
*/
protected boolean skipMethodCall(InvocationContext ctx)
{
return false;
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_evict(org.jboss.cache.Fqn, org.jboss.cache.optimistic.DataVersion)}
*/
protected Object handleEvictVersionedNodeMethod(InvocationContext ctx, Fqn fqn, DataVersion dataVersion) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles evict()
*/
protected Object handleEvictMethod(InvocationContext ctx, Fqn fqn) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#prepare(org.jboss.cache.transaction.GlobalTransaction, java.util.List, org.jgroups.Address, boolean)}
*/
protected Object handlePrepareMethod(InvocationContext ctx, GlobalTransaction gtx, List modification, Address coordinator, boolean onePhaseCommit) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#optimisticPrepare(org.jboss.cache.transaction.GlobalTransaction, java.util.List, java.util.Map, org.jgroups.Address, boolean)}
*/
protected Object handleOptimisticPrepareMethod(InvocationContext ctx, GlobalTransaction gtx, List modifications, Map data, Address address, boolean onePhaseCommit) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#commit(org.jboss.cache.transaction.GlobalTransaction)}
*/
protected Object handleCommitMethod(InvocationContext ctx, GlobalTransaction globalTransaction) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_removeData(org.jboss.cache.transaction.GlobalTransaction, Fqn, boolean)}
*/
protected Object handleRemoveDataMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, boolean createUndoOps) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_remove(org.jboss.cache.transaction.GlobalTransaction, String, Object, boolean)}
*/
protected Object handleRemoveKeyMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Object key, boolean createUndoOps) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_remove(org.jboss.cache.transaction.GlobalTransaction, String, boolean)}
*/
protected Object handleRemoveNodeMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, boolean createUndoOps) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#rollback(org.jboss.cache.transaction.GlobalTransaction)}
*/
protected Object handleRollbackMethod(InvocationContext ctx, GlobalTransaction globalTransaction) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_getData(org.jboss.cache.Fqn)}
*/
protected Object handleGetDataMapMethod(InvocationContext ctx, Fqn fqn) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.Cache#getKeys(Fqn)}
*/
protected Object handleGetKeysMethod(InvocationContext ctx, Fqn fqn) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_print(org.jboss.cache.Fqn)}
*/
protected Object handlePrintMethod(InvocationContext ctx, Fqn fqn) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_releaseAllLocks(org.jboss.cache.Fqn)}
*/
protected Object handleReleaseAllLocksMethod(InvocationContext ctx, Fqn fqn) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_getChildrenNames(org.jboss.cache.Fqn)}
*/
protected Object handleGetChildrenNamesMethod(InvocationContext ctx, Fqn fqn) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_get(org.jboss.cache.Fqn)}
*/
protected Object handleGetNodeMethod(InvocationContext ctx, Fqn fqn) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_get(org.jboss.cache.Fqn, Object, boolean)}
*/
protected Object handleGetKeyValueMethod(InvocationContext ctx, Fqn fqn, Object key, boolean sendNodeEvent) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_addChild(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, org.jboss.cache.Node, boolean)}
*/
protected Object handleAddChildMethod(InvocationContext ctx, GlobalTransaction tx, Fqn parentFqn, Object childName, Node cn, boolean createUndoOps) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_move(org.jboss.cache.Fqn, org.jboss.cache.Fqn)}
*/
protected Object handleMoveMethod(InvocationContext ctx, Fqn from, Fqn to) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_put(org.jboss.cache.transaction.GlobalTransaction, String, Object, Object, boolean)}
*/
protected Object handlePutKeyValueMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_putForExternalRead(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, Object)}
*/
protected Object handlePutForExternalReadMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Object key, Object value) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_put(org.jboss.cache.transaction.GlobalTransaction, String, java.util.Map, boolean)}
*/
protected Object handlePutDataMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Map data, boolean createUndoOps) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handles {@link org.jboss.cache.CacheImpl#_put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, boolean)}
*/
protected Object handlePutDataEraseMethod(InvocationContext ctx, GlobalTransaction gt, Fqn fqn, Map newData, boolean createUndoOps, boolean eraseContents) throws Throwable
{
return defaultHandlersBehavior();
}
/**
* Handlers defined here should not be called directlly. There are two scenarios in which a handler might be called:
* 1 - DerivedInterceptor.super - pointless call
* 2 - if the logic that determines that an handler is overwritten fails. Throwing an exception by default is for
* guarding against this scenario
*/
private Object defaultHandlersBehavior()
{
throw new IllegalStateException("this is either called from a derived class or not overridden and accidentally called. Either way, is not correct.");
}
/**
* Builds the list of methods that are overwiritten.
*/
private void findOverriddenMethods()
{
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 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
while (currentClass != MethodDispacherInterceptor.class)
{
try
{
currentClass.getDeclaredMethod(methodName, args);
overriddenMethods.add(methodId);
}
catch (NoSuchMethodException e)
{
//ignore
}
currentClass = (Class) currentClass.getGenericSuperclass();
}
}
}