[jbosscache-commits] JBoss Cache SVN: r4984 - in core/trunk/src/main/java/org/jboss/cache: marshall and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Jan 4 10:57:04 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-01-04 10:57:04 -0500 (Fri, 04 Jan 2008)
New Revision: 4984

Modified:
   core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
   core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
   core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java
Log:
JBCACHE-1230 - reduced noisy toString() impls

Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java	2008-01-04 15:56:39 UTC (rev 4983)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java	2008-01-04 15:57:04 UTC (rev 4984)
@@ -1910,7 +1910,7 @@
 
       if (trace)
       {
-         log.trace("callRemoteMethods(): valid members are " + validMembers + " methods: " + method_call.getArgs()[0]);
+         log.trace("callRemoteMethods(): valid members are " + validMembers + " methods: " + method_call);
       }
 
       if (channel.flushSupported())
@@ -1927,7 +1927,7 @@
       if (rsps == null)
       {
          // return null;
-         throw new NotSerializableException("RpcDispatcher returned a null.  This is most often caused by args for " + method_call + " not being serializable.");
+         throw new NotSerializableException("RpcDispatcher returned a null.  This is most often caused by args for " + method_call.getName() + " not being serializable.");
       }
       if (mode == GroupRequest.GET_NONE)
       {

Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2008-01-04 15:56:39 UTC (rev 4983)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2008-01-04 15:57:04 UTC (rev 4984)
@@ -332,7 +332,7 @@
    @Override
    public String toString()
    {
-      StringBuffer sb = new StringBuffer();
+      StringBuilder sb = new StringBuilder();
       sb.append(getClass().getSimpleName());
       if (!valid) sb.append(" (INVALID!) ");
 
@@ -348,12 +348,61 @@
       {
          synchronized (data)
          {
-            sb.append(" data=").append(data.keySet());
+            sb.append(" data=[");
+            Set keys = data.keySet();
+            int i = 0;
+            for (Object o : keys)
+            {
+               i++;
+               sb.append(o);
+
+               if (i == 5)
+               {
+                  int more = keys.size() - 5;
+                  if (more > 1)
+                  {
+                     sb.append(", and ");
+                     sb.append(more);
+                     sb.append(" more");
+                     break;
+                  }
+               }
+               else
+               {
+                  sb.append(", ");
+               }
+            }
+            sb.append("]");
          }
       }
       if (children != null && !children.isEmpty())
       {
-         sb.append(" child=").append(getChildrenNamesDirect());
+         sb.append(" children=[");
+         Set names = getChildrenNamesDirect();
+         int i = 0;
+         for (Object o : names)
+         {
+            i++;
+            sb.append(o);
+
+            if (i == 5)
+            {
+               int more = names.size() - 5;
+               if (more > 1)
+               {
+                  sb.append(", and ");
+                  sb.append(more);
+                  sb.append(" more");
+                  break;
+               }
+            }
+            else
+            {
+               sb.append(", ");
+            }
+         }
+         sb.append("]");
+
       }
       if (lock_ != null)
       {

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java	2008-01-04 15:56:39 UTC (rev 4983)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java	2008-01-04 15:57:04 UTC (rev 4984)
@@ -37,21 +37,21 @@
       // for serialization
    }
 
-    /**
-     * This only works for prepare() and optimisticPrepare() method calls.
-     */
-    public boolean isOnePhaseCommitPrepareMehod()
-    {
-       switch (this.getMethodId())
-       {
-          case MethodDeclarations.prepareMethod_id:
-             return (Boolean) this.getArgs()[3];
-          case MethodDeclarations.optimisticPrepareMethod_id:
-             return (Boolean) this.getArgs()[4];
-          default:
-             return false;
-       }
-    }
+   /**
+    * This only works for prepare() and optimisticPrepare() method calls.
+    */
+   public boolean isOnePhaseCommitPrepareMehod()
+   {
+      switch (this.getMethodId())
+      {
+         case MethodDeclarations.prepareMethod_id:
+            return (Boolean) this.getArgs()[3];
+         case MethodDeclarations.optimisticPrepareMethod_id:
+            return (Boolean) this.getArgs()[4];
+         default:
+            return false;
+      }
+   }
 
 
    protected MethodCall(Method method, Object... arguments)
@@ -90,23 +90,13 @@
       ret.append("; MethodIdInteger: ");
       ret.append(methodIdInteger);
       ret.append("; Args: (");
-      if (args != null)
+      if (args != null && args.length > 0)
       {
-         for (Object arg : args)
-         {
-            if (first)
-            {
-               first = false;
-            }
-            else
-            {
-               ret.append(", ");
-            }
-            ret.append(arg);
-         }
+         ret.append(" arg[0] = ");
+         ret.append(args[0]);
+         if (args.length > 1) ret.append(" ...");
       }
       ret.append(')');
       return ret.toString();
-
    }
 }




More information about the jbosscache-commits mailing list