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

Brian Stansberry brian.stansberry at jboss.com
Wed Feb 7 13:37:56 EST 2007


  User: bstansberry
  Date: 07/02/07 13:37:56

  Modified:    src/org/jboss/cache  Tag: Branch_JBossCache_1_4_0
                        TreeCache.java
  Log:
  [JBCACHE-970] Simplify anycast compatibility check
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.195.2.47 +21 -5     JBossCache/src/org/jboss/cache/Attic/TreeCache.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCache.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Attic/TreeCache.java,v
  retrieving revision 1.195.2.46
  retrieving revision 1.195.2.47
  diff -u -b -r1.195.2.46 -r1.195.2.47
  --- TreeCache.java	30 Jan 2007 20:22:42 -0000	1.195.2.46
  +++ TreeCache.java	7 Feb 2007 18:37:56 -0000	1.195.2.47
  @@ -99,7 +99,7 @@
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    * @author Brian Stansberry
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Id: TreeCache.java,v 1.195.2.46 2007/01/30 20:22:42 msurtani Exp $
  + * @version $Id: TreeCache.java,v 1.195.2.47 2007/02/07 18:37:56 bstansberry Exp $
    *          <p/>
    * @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
    */
  @@ -432,6 +432,12 @@
      protected final Set activationChangeNodes = new HashSet();
   
      /**
  +    * The JGroups 2.4.1 or higher "callRemoteMethods" overload that 
  +    * provides Anycast support.
  +    */
  +   protected Method anycastMethod;
  +
  +   /**
       * Creates a channel with the given cluster name, properties, and state fetch timeout.
       */
      public TreeCache(String cluster_name, String props, long state_fetch_timeout) throws Exception
  @@ -1479,6 +1485,17 @@
   */
               disp = new RpcDispatcher(channel, ml, this, this);
               disp.setMarshaller(getMarshaller());
  +            
  +            // See if Anycast is supported
  +            try
  +            {
  +               anycastMethod = disp.getClass().getMethod("callRemoteMethods", new Class[]{Vector.class, MethodCall.class, int.class, long.class, boolean.class});
  +            }
  +            catch (Throwable ignored)
  +            {
  +               log.debug("JGroups release " + org.jgroups.Version.version + 
  +                         " does not support anycast; will not use it");
  +            }
               break;
            default:
               throw new IllegalArgumentException("cache mode " + cache_mode + " is invalid");
  @@ -4379,11 +4396,10 @@
   
      private RspList callRemoteMethodsViaReflection(Vector validMembers, MethodCall method_call, int mode, long timeout, boolean anycast) throws Exception
      {
  -      if (anycast && org.jgroups.Version.version >= 241)
  +      if (anycast && anycastMethod != null)
         {
  -         // now consider using reflection since we need JGroups >= 2.4.1 for this.
  -         Method m = disp.getClass().getMethod("callRemoteMethods", new Class[]{Vector.class, MethodCall.class, int.class, long.class, boolean.class});
  -         return (RspList) m.invoke(disp, new Object[]{validMembers, method_call, new Integer(mode), new Long(timeout), Boolean.valueOf(anycast)});
  +         // Using reflection since we need JGroups >= 2.4.1 for this.
  +         return (RspList) anycastMethod.invoke(disp, new Object[]{validMembers, method_call, new Integer(mode), new Long(timeout), Boolean.valueOf(anycast)});
         }
         else return disp.callRemoteMethods(validMembers, method_call, mode, timeout);
      }
  
  
  



More information about the jboss-cvs-commits mailing list