[jboss-cvs] JBossCache/src/org/jboss/cache/marshall ...

Manik Surtani msurtani at jboss.com
Fri Aug 25 08:41:35 EDT 2006


  User: msurtani
  Date: 06/08/25 08:41:35

  Modified:    src/org/jboss/cache/marshall    Marshaller.java
                        MethodDeclarations.java TreeCacheMarshaller.java
  Log:
  - "modernised" MethodDeclarations
  - removed unnessary method maps in various interceptors, replaced with methods in MethodDeclarations
  - some work on replacing JGroups MethodCall with JBCMethodCall
  
  Revision  Changes    Path
  1.2       +1 -1      JBossCache/src/org/jboss/cache/marshall/Marshaller.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Marshaller.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/marshall/Marshaller.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- Marshaller.java	8 Jun 2006 00:42:23 -0000	1.1
  +++ Marshaller.java	25 Aug 2006 12:41:35 -0000	1.2
  @@ -131,7 +131,7 @@
               case MethodDeclarations.remoteRemoveFromBuddyGroupMethod_id:
                   break;
               default :
  -                if (MethodDeclarations.isCrudMethod(meth))
  +                if (MethodDeclarations.isCrudMethod(methodCall.getMethodId()))
                   {
                       Fqn fqn2 = (Fqn) args[1];
                       fqnStr = fqn2.toString();
  
  
  
  1.12      +79 -66    JBossCache/src/org/jboss/cache/marshall/MethodDeclarations.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MethodDeclarations.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/marshall/MethodDeclarations.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -b -r1.11 -r1.12
  --- MethodDeclarations.java	25 Aug 2006 11:59:02 -0000	1.11
  +++ MethodDeclarations.java	25 Aug 2006 12:41:35 -0000	1.12
  @@ -22,7 +22,6 @@
   import java.lang.reflect.Method;
   import java.util.HashMap;
   import java.util.HashSet;
  -import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
   import java.util.Set;
  @@ -32,20 +31,22 @@
    * allowing lookup operations both ways.
    *
    * @author <a href="galder.zamarreno at jboss.com">Galder Zamarreno</a>
  - * @version $Revision: 1.11 $
  + * @version $Revision: 1.12 $
    */
   public class MethodDeclarations
   {
       private static Log log = LogFactory.getLog(MethodDeclarations.class);
   
  -    private static Set crud_methods = new HashSet();
  -    private static Set crud_method_ids = new HashSet();
  +    static final Set<Integer> crudMethodIds = new HashSet<Integer>();
  +    static final Set<Integer> transactionLifecycleMethodIds = new HashSet<Integer>();
  +    static final Set<Integer> buddyGroupOrganisationMethodIds = new HashSet<Integer>();
  +    static final Set<Integer> putMethodIds = new HashSet<Integer>();
   
       // maintain a list of method IDs that correspond to Methods in TreeCache
  -    private static Map methods = new HashMap();
  +    static final Map<Integer, Method> methods = new HashMap<Integer, Method>();
   
       // and for reverse lookup
  -    private static Map methodIds = new HashMap();
  +    static final Map<Method, Integer> methodIds = new HashMap<Method, Integer>();
   
       public static final Method putDataMethodLocal;
   
  @@ -275,71 +276,73 @@
               throw new ExceptionInInitializerError(ex.toString());
           }
   
  -        crud_methods.add(putDataMethodLocal);
  -        crud_methods.add(putDataEraseMethodLocal);
  -        crud_methods.add(putKeyValMethodLocal);
  -        crud_methods.add(removeNodeMethodLocal);
  -        crud_methods.add(removeKeyMethodLocal);
  -        crud_methods.add(removeDataMethodLocal);
  -        crud_methods.add(dataGravitationCleanupMethod);
  -
  -        methods.put(new Integer(putDataMethodLocal_id), putDataMethodLocal);
  -        methods.put(new Integer(putDataEraseMethodLocal_id), putDataEraseMethodLocal);
  -        methods.put(new Integer(putKeyValMethodLocal_id), putKeyValMethodLocal);
  -        methods.put(new Integer(removeNodeMethodLocal_id), removeNodeMethodLocal);
  -        methods.put(new Integer(removeKeyMethodLocal_id), removeKeyMethodLocal);
  -        methods.put(new Integer(removeDataMethodLocal_id), removeDataMethodLocal);
  -        methods.put(new Integer(evictNodeMethodLocal_id), evictNodeMethodLocal);
  -        methods.put(new Integer(evictVersionedNodeMethodLocal_id), evictVersionedNodeMethodLocal);
  -        methods.put(new Integer(prepareMethod_id), prepareMethod);
  -        methods.put(new Integer(commitMethod_id), commitMethod);
  -        methods.put(new Integer(rollbackMethod_id), rollbackMethod);
  -        methods.put(new Integer(replicateMethod_id), replicateMethod);
  -        methods.put(new Integer(replicateAllMethod_id), replicateAllMethod);
  -        methods.put(new Integer(addChildMethodLocal_id), addChildMethodLocal);
  -        methods.put(new Integer(existsMethod_id), existsMethod);
  -        methods.put(new Integer(releaseAllLocksMethodLocal_id), releaseAllLocksMethodLocal);
  -        methods.put(new Integer(optimisticPrepareMethod_id), optimisticPrepareMethod);
  -        methods.put(new Integer(getPartialStateMethod_id), getPartialStateMethod);
  -        methods.put(new Integer(enqueueMethodCallMethod_id), enqueueMethodCallMethod);
  -        methods.put(new Integer(notifyCallOnInactiveMethod_id), notifyCallOnInactiveMethod);
  -        methods.put(new Integer(clusteredGetMethod_id), clusteredGetMethod);
  -        methods.put(new Integer(getChildrenNamesMethodLocal_id), getChildrenNamesMethodLocal);
  -        methods.put(new Integer(getDataMapMethodLocal_id), getDataMapMethodLocal);
  -        methods.put(new Integer(getKeysMethodLocal_id), getKeysMethodLocal);
  -        methods.put(new Integer(getKeyValueMethodLocal_id), getKeyValueMethodLocal);
  -        methods.put(new Integer(dispatchRpcCallMethod_id), RpcTreeCache.dispatchRpcCallMethod);
  -        methods.put(new Integer(remoteAnnounceBuddyPoolNameMethod_id), remoteAnnounceBuddyPoolNameMethod);
  -        methods.put(new Integer(remoteAssignToBuddyGroupMethod_id), remoteAssignToBuddyGroupMethod);
  -        methods.put(new Integer(remoteRemoveFromBuddyGroupMethod_id), remoteRemoveFromBuddyGroupMethod);
  +        methods.put(putDataMethodLocal_id, putDataMethodLocal);
  +        methods.put(putDataEraseMethodLocal_id, putDataEraseMethodLocal);
  +        methods.put(putKeyValMethodLocal_id, putKeyValMethodLocal);
  +        methods.put(removeNodeMethodLocal_id, removeNodeMethodLocal);
  +        methods.put(removeKeyMethodLocal_id, removeKeyMethodLocal);
  +        methods.put(removeDataMethodLocal_id, removeDataMethodLocal);
  +        methods.put(evictNodeMethodLocal_id, evictNodeMethodLocal);
  +        methods.put(evictVersionedNodeMethodLocal_id, evictVersionedNodeMethodLocal);
  +        methods.put(prepareMethod_id, prepareMethod);
  +        methods.put(commitMethod_id, commitMethod);
  +        methods.put(rollbackMethod_id, rollbackMethod);
  +        methods.put(replicateMethod_id, replicateMethod);
  +        methods.put(replicateAllMethod_id, replicateAllMethod);
  +        methods.put(addChildMethodLocal_id, addChildMethodLocal);
  +        methods.put(existsMethod_id, existsMethod);
  +        methods.put(releaseAllLocksMethodLocal_id, releaseAllLocksMethodLocal);
  +        methods.put(optimisticPrepareMethod_id, optimisticPrepareMethod);
  +        methods.put(getPartialStateMethod_id, getPartialStateMethod);
  +        methods.put(enqueueMethodCallMethod_id, enqueueMethodCallMethod);
  +        methods.put(notifyCallOnInactiveMethod_id, notifyCallOnInactiveMethod);
  +        methods.put(clusteredGetMethod_id, clusteredGetMethod);
  +        methods.put(getChildrenNamesMethodLocal_id, getChildrenNamesMethodLocal);
  +        methods.put(getDataMapMethodLocal_id, getDataMapMethodLocal);
  +        methods.put(getKeysMethodLocal_id, getKeysMethodLocal);
  +        methods.put(getKeyValueMethodLocal_id, getKeyValueMethodLocal);
  +        methods.put(dispatchRpcCallMethod_id, RpcTreeCache.dispatchRpcCallMethod);
  +        methods.put(remoteAnnounceBuddyPoolNameMethod_id, remoteAnnounceBuddyPoolNameMethod);
  +        methods.put(remoteAssignToBuddyGroupMethod_id, remoteAssignToBuddyGroupMethod);
  +        methods.put(remoteRemoveFromBuddyGroupMethod_id, remoteRemoveFromBuddyGroupMethod);
           /* Mappings added as they did not exist before refactoring */
  -        methods.put(new Integer(getNodeMethodLocal_id), getNodeMethodLocal);
  -        methods.put(new Integer(printMethodLocal_id), printMethodLocal);
  -        methods.put(new Integer(lockMethodLocal_id), lockMethodLocal);
  -
  -        methods.put(new Integer(dataGravitationCleanupMethod_id), dataGravitationCleanupMethod);
  -        methods.put(new Integer(dataGravitationMethod_id), dataGravitationMethod);
  -
  -        Iterator it = methods.keySet().iterator();
  -        while (it.hasNext())
  -        {
  -            Object id = it.next();
  -            Object method = methods.get(id);
  -            methodIds.put(method, id);
  -        }
  -
  -        crud_method_ids.add(new Integer(putDataMethodLocal_id));
  -        crud_method_ids.add(new Integer(putDataEraseMethodLocal_id));
  -        crud_method_ids.add(new Integer(putKeyValMethodLocal_id));
  -        crud_method_ids.add(new Integer(removeNodeMethodLocal_id));
  -        crud_method_ids.add(new Integer(removeKeyMethodLocal_id));
  -        crud_method_ids.add(new Integer(removeDataMethodLocal_id));
  -        crud_method_ids.add(new Integer(dataGravitationCleanupMethod_id));
  +        methods.put(getNodeMethodLocal_id, getNodeMethodLocal);
  +        methods.put(printMethodLocal_id, printMethodLocal);
  +        methods.put(lockMethodLocal_id, lockMethodLocal);
  +
  +        methods.put(dataGravitationCleanupMethod_id, dataGravitationCleanupMethod);
  +        methods.put(dataGravitationMethod_id, dataGravitationMethod);
  +
  +        for (Integer id : methods.keySet())
  +        {
  +            methodIds.put(methods.get(id), id);
  +        }
  +
  +
  +
  +        putMethodIds.add(putDataMethodLocal_id);
  +        putMethodIds.add(putDataEraseMethodLocal_id);
  +        putMethodIds.add(putKeyValMethodLocal_id);
  +
  +        crudMethodIds.addAll(putMethodIds);
  +        crudMethodIds.add(removeNodeMethodLocal_id);
  +        crudMethodIds.add(removeKeyMethodLocal_id);
  +        crudMethodIds.add(removeDataMethodLocal_id);
  +        crudMethodIds.add(dataGravitationCleanupMethod_id);
  +
  +        transactionLifecycleMethodIds.add(commitMethod_id);
  +        transactionLifecycleMethodIds.add(rollbackMethod_id);
  +        transactionLifecycleMethodIds.add(prepareMethod_id);
  +        transactionLifecycleMethodIds.add(optimisticPrepareMethod_id);
  +
  +        buddyGroupOrganisationMethodIds.add(remoteAnnounceBuddyPoolNameMethod_id);
  +        buddyGroupOrganisationMethodIds.add(remoteAssignToBuddyGroupMethod_id);
  +        buddyGroupOrganisationMethodIds.add(remoteRemoveFromBuddyGroupMethod_id);
       }
   
       protected static int lookupMethodId(Method method)
       {
  -        Integer methodIdInteger = (Integer) methodIds.get(method);
  +        Integer methodIdInteger = methodIds.get(method);
           int methodId = -1;
   
           if (methodIdInteger != null)
  @@ -359,7 +362,7 @@
   
       protected static Method lookupMethod(int id)
       {
  -        Method method = (Method) methods.get(new Integer(id));
  +        Method method = methods.get(new Integer(id));
           if (method == null)
           {
               if (log.isErrorEnabled())
  @@ -374,13 +377,23 @@
       /**
        * Returns true if the method is a CRUD method.
        */
  -    public static boolean isCrudMethod(Method m)
  +    public static boolean isCrudMethod(int id)
       {
  -        return crud_methods.contains(m);
  +        return crudMethodIds.contains(new Integer(id));
       }
   
  -    public static boolean isCrudMethod(int id)
  +    public static boolean isTransactionLifecycleMethod(int id)
  +    {
  +        return transactionLifecycleMethodIds.contains(id);
  +    }
  +
  +    public static boolean isBuddyGroupOrganisationMethod(int id)
  +    {
  +        return buddyGroupOrganisationMethodIds.contains(id);
  +    }
  +
  +    public static boolean isPutMethod(int id)
       {
  -        return crud_method_ids.contains(new Integer(id));
  +        return putMethodIds.contains(id);
       }
   }
  
  
  
  1.20      +2 -2      JBossCache/src/org/jboss/cache/marshall/TreeCacheMarshaller.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCacheMarshaller.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/marshall/TreeCacheMarshaller.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -b -r1.19 -r1.20
  --- TreeCacheMarshaller.java	6 Jun 2006 10:17:14 -0000	1.19
  +++ TreeCacheMarshaller.java	25 Aug 2006 12:41:35 -0000	1.20
  @@ -35,7 +35,7 @@
    *
    * @author Ben Wang
    *         Date: Aug 9, 2005
  - * @version $Id: TreeCacheMarshaller.java,v 1.19 2006/06/06 10:17:14 msurtani Exp $
  + * @version $Id: TreeCacheMarshaller.java,v 1.20 2006/08/25 12:41:35 msurtani Exp $
    */
   public class TreeCacheMarshaller implements RpcDispatcher.Marshaller {
   
  @@ -451,7 +451,7 @@
            case MethodDeclarations.remoteRemoveFromBuddyGroupMethod_id:
               break;
            default :
  -            if (MethodDeclarations.isCrudMethod(meth)) 
  +            if (MethodDeclarations.isCrudMethod(method_call.getMethodId())) 
               {
                  Fqn fqn2 = (Fqn)args[1];
                  fqnStr = fqn2.toString();
  
  
  



More information about the jboss-cvs-commits mailing list