[jboss-cvs] JBossCache/src/org/jboss/cache/marshall ...
Manik Surtani
msurtani at jboss.com
Fri Aug 25 10:10:08 EDT 2006
User: msurtani
Date: 06/08/25 10:10:08
Modified: src/org/jboss/cache/marshall
LegacyTreeCacheMarshaller.java Marshaller.java
MethodCallFactory.java MethodDeclarations.java
TreeCacheMarshaller.java
TreeCacheMarshaller140.java
Added: src/org/jboss/cache/marshall MethodCall.java
Removed: src/org/jboss/cache/marshall JBCMethodCall.java
Log:
More work on JBCACHE-734
Revision Changes Path
1.6 +7 -7 JBossCache/src/org/jboss/cache/marshall/LegacyTreeCacheMarshaller.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LegacyTreeCacheMarshaller.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/marshall/LegacyTreeCacheMarshaller.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- LegacyTreeCacheMarshaller.java 8 Jun 2006 22:00:35 -0000 1.5
+++ LegacyTreeCacheMarshaller.java 25 Aug 2006 14:10:08 -0000 1.6
@@ -9,7 +9,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jgroups.blocks.MethodCall;
+import org.jboss.cache.marshall.MethodCall;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -33,7 +33,7 @@
* @author Ben Wang
* @author Manik Surtani
*
- * @version $Id: LegacyTreeCacheMarshaller.java,v 1.5 2006/06/08 22:00:35 msurtani Exp $
+ * @version $Id: LegacyTreeCacheMarshaller.java,v 1.6 2006/08/25 14:10:08 msurtani Exp $
*/
public class LegacyTreeCacheMarshaller extends Marshaller
{
@@ -117,7 +117,7 @@
* 1. replicate. Argument is another MethodCall. The followings are the one that we need to handle:
* 2. replicateAll. List of MethodCalls. We can simply repeat the previous step by extract the first fqn only.
*/
- JBCMethodCall call = (JBCMethodCall) o; // either "replicate" or "replicateAll" now.
+ MethodCall call = (MethodCall) o; // either "replicate" or "replicateAll" now.
String fqn;
switch (call.getMethodId())
@@ -279,10 +279,10 @@
* Replace any deserialized MethodCall with our version that has
* the correct id.
*/
- private JBCMethodCall internMethodCall(MethodCall call)
+ private MethodCall internMethodCall(MethodCall call)
{
Object[] args = call.getArgs();
- JBCMethodCall result = MethodCallFactory.create(call.getMethod(), args);
+ MethodCall result = MethodCallFactory.create(call.getMethod(), args);
switch (result.getMethodId())
{
@@ -322,9 +322,9 @@
private Object externMethodCall(Object o)
{
Object toSerialize = o;
- if (o instanceof JBCMethodCall)
+ if (o instanceof MethodCall)
{
- JBCMethodCall call = (JBCMethodCall) o;
+ MethodCall call = (MethodCall) o;
toSerialize = new MethodCall(call.getMethod(), (Object[]) externMethodCall(call.getArgs()));
}
else if (o instanceof Object[])
1.3 +7 -6 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.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Marshaller.java 25 Aug 2006 12:41:35 -0000 1.2
+++ Marshaller.java 25 Aug 2006 14:10:08 -0000 1.3
@@ -11,6 +11,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.marshall.MethodCall;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -65,9 +66,9 @@
*
* @param call
*/
- protected String extractFqnFromMethodCall(JBCMethodCall call)
+ protected String extractFqnFromMethodCall(MethodCall call)
{
- JBCMethodCall c0 = (JBCMethodCall) call.getArgs()[0];
+ MethodCall c0 = (MethodCall) call.getArgs()[0];
return extractFqn(c0);
}
@@ -76,15 +77,15 @@
*
* @param call
*/
- protected String extractFqnFromListOfMethodCall(JBCMethodCall call)
+ protected String extractFqnFromListOfMethodCall(MethodCall call)
{
Object[] args = call.getArgs();
// We simply pick the first one and assume everyone will need to operate under the same region!
- JBCMethodCall c0 = (JBCMethodCall) ((List) args[0]).get(0);
+ MethodCall c0 = (MethodCall) ((List) args[0]).get(0);
return extractFqn(c0);
}
- protected String extractFqn(JBCMethodCall methodCall)
+ protected String extractFqn(MethodCall methodCall)
{
if (methodCall == null)
{
@@ -100,7 +101,7 @@
case MethodDeclarations.prepareMethod_id:
// Prepare method has a list of modifications. We will just take the first one and extract.
List modifications = (List) args[1];
- fqnStr = extractFqn((JBCMethodCall) modifications.get(0));
+ fqnStr = extractFqn((MethodCall) modifications.get(0));
// the last arg of a prepare call is the one-phase flag
boolean one_phase_commit = ((Boolean) args[args.length - 1]).booleanValue();
1.4 +4 -4 JBossCache/src/org/jboss/cache/marshall/MethodCallFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MethodCallFactory.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/marshall/MethodCallFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- MethodCallFactory.java 7 Jun 2006 22:28:08 -0000 1.3
+++ MethodCallFactory.java 25 Aug 2006 14:10:08 -0000 1.4
@@ -9,10 +9,10 @@
import java.lang.reflect.Method;
/**
- * Factory class to create instances of org.jgroups.blocks.MethodCall
+ * Factory class to create instances of org.jboss.cache.marshall.MethodCall
*
* @author <a href="galder.zamarreno at jboss.com">Galder Zamarreno</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class MethodCallFactory
{
@@ -23,9 +23,9 @@
* @param arguments list of parameters
* @return a new instance of MethodCall with the method id initialised
*/
- public static JBCMethodCall create(Method method, Object[] arguments)
+ public static MethodCall create(Method method, Object[] arguments)
{
- JBCMethodCall mc = new JBCMethodCall(method, arguments, MethodDeclarations.lookupMethodId(method));
+ MethodCall mc = new MethodCall(method, arguments, MethodDeclarations.lookupMethodId(method));
return mc;
}
}
1.13 +2 -2 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.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- MethodDeclarations.java 25 Aug 2006 12:41:35 -0000 1.12
+++ MethodDeclarations.java 25 Aug 2006 14:10:08 -0000 1.13
@@ -16,7 +16,7 @@
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.rpc.RpcTreeCache;
import org.jgroups.Address;
-import org.jgroups.blocks.MethodCall;
+import org.jboss.cache.marshall.MethodCall;
import org.jgroups.stack.IpAddress;
import java.lang.reflect.Method;
@@ -31,7 +31,7 @@
* allowing lookup operations both ways.
*
* @author <a href="galder.zamarreno at jboss.com">Galder Zamarreno</a>
- * @version $Revision: 1.12 $
+ * @version $Revision: 1.13 $
*/
public class MethodDeclarations
{
1.21 +10 -9 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.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- TreeCacheMarshaller.java 25 Aug 2006 12:41:35 -0000 1.20
+++ TreeCacheMarshaller.java 25 Aug 2006 14:10:08 -0000 1.21
@@ -15,6 +15,7 @@
import org.jboss.invocation.MarshalledValueInputStream;
import org.jboss.invocation.MarshalledValueOutputStream;
import org.jgroups.blocks.RpcDispatcher;
+import org.jboss.cache.marshall.MethodCall;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -35,7 +36,7 @@
*
* @author Ben Wang
* Date: Aug 9, 2005
- * @version $Id: TreeCacheMarshaller.java,v 1.20 2006/08/25 12:41:35 msurtani Exp $
+ * @version $Id: TreeCacheMarshaller.java,v 1.21 2006/08/25 14:10:08 msurtani Exp $
*/
public class TreeCacheMarshaller implements RpcDispatcher.Marshaller {
@@ -256,7 +257,7 @@
* 1. replicate. Argument is another MethodCall. The followings are the one that we need to handle:
* 2. replicateAll. List of MethodCalls. We can simply repeat the previous step by extract the first fqn only.
*/
- JBCMethodCall call = (JBCMethodCall) o; // either "replicate" or "replicateAll" now.
+ MethodCall call = (MethodCall) o; // either "replicate" or "replicateAll" now.
String fqn;
switch (call.getMethodId())
{
@@ -386,9 +387,9 @@
* This is "replicate" call with a single MethodCall argument.
* @param call
*/
- protected String extractFqnFromMethodCall(JBCMethodCall call)
+ protected String extractFqnFromMethodCall(MethodCall call)
{
- JBCMethodCall c0 = (JBCMethodCall)call.getArgs()[0];
+ MethodCall c0 = (MethodCall)call.getArgs()[0];
return extractFqn(c0);
}
@@ -396,15 +397,15 @@
* This is "replicate" call with a list of MethodCall argument.
* @param call
*/
- protected String extractFqnFromListOfMethodCall(JBCMethodCall call)
+ protected String extractFqnFromListOfMethodCall(MethodCall call)
{
Object[] args = call.getArgs();
// We simply pick the first one and assume everyone will need to operate under the same region!
- JBCMethodCall c0 = (JBCMethodCall)((List)args[0]).get(0);
+ MethodCall c0 = (MethodCall)((List)args[0]).get(0);
return extractFqn(c0);
}
- protected String extractFqn(JBCMethodCall method_call)
+ protected String extractFqn(MethodCall method_call)
{
if (method_call == null)
{
@@ -420,7 +421,7 @@
case MethodDeclarations.prepareMethod_id:
// Prepare method has a list of modifications. We will just take the first one and extract.
List modifications=(List)args[1];
- fqnStr = extractFqn((JBCMethodCall)modifications.get(0));
+ fqnStr = extractFqn((MethodCall)modifications.get(0));
// the last arg of a prepare call is the one-phase flag
boolean one_phase_commit = ((Boolean) args[args.length - 1]).booleanValue();
1.2 +7 -7 JBossCache/src/org/jboss/cache/marshall/TreeCacheMarshaller140.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCacheMarshaller140.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/marshall/TreeCacheMarshaller140.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- TreeCacheMarshaller140.java 8 Jun 2006 00:42:23 -0000 1.1
+++ TreeCacheMarshaller140.java 25 Aug 2006 14:10:08 -0000 1.2
@@ -13,7 +13,7 @@
import org.jboss.cache.GlobalTransaction;
import org.jboss.cache.rpc.RpcTreeCache;
import org.jgroups.Address;
-import org.jgroups.blocks.MethodCall;
+import org.jboss.cache.marshall.MethodCall;
import org.jgroups.stack.IpAddress;
import java.io.IOException;
@@ -69,7 +69,7 @@
if (useRegionBasedMarshalling)
{
// we first marshall the Fqn as a String (ugh!)
- JBCMethodCall call = (JBCMethodCall) o;
+ MethodCall call = (MethodCall) o;
String fqnAsString = extractFqnAsString(call);
marshallObject(fqnAsString, out, refMap);
}
@@ -149,7 +149,7 @@
return region;
}
- private String extractFqnAsString(JBCMethodCall call) throws Exception
+ private String extractFqnAsString(MethodCall call) throws Exception
{
String fqnAsString;
if (call.getMethod().equals(MethodDeclarations.replicateMethod))
@@ -162,7 +162,7 @@
}
else if (call.getMethod().equals(RpcTreeCache.dispatchRpcCallMethod))
{
- JBCMethodCall call2 = (JBCMethodCall) call.getArgs()[1];
+ MethodCall call2 = (MethodCall) call.getArgs()[1];
fqnAsString = extractFqn(call2);
}
else
@@ -186,10 +186,10 @@
out.writeByte(MAGICNUMBER_REF);
out.writeShort(((Integer) refMap.get(o)).intValue());
}
- else if (o instanceof JBCMethodCall)
+ else if (o instanceof MethodCall)
{
// first see if this is a 'known' method call.
- JBCMethodCall call = (JBCMethodCall) o;
+ MethodCall call = (MethodCall) o;
if (call.getMethodId() > -1)
{
@@ -275,7 +275,7 @@
return reference;
}
- private void marshallMethodCall(JBCMethodCall methodCall, ObjectOutputStream out, Map refMap) throws Exception
+ private void marshallMethodCall(MethodCall methodCall, ObjectOutputStream out, Map refMap) throws Exception
{
out.writeShort(methodCall.getMethodId());
Object[] args = methodCall.getArgs();
1.1 date: 2006/08/25 14:10:08; author: msurtani; state: Exp;JBossCache/src/org/jboss/cache/marshall/MethodCall.java
Index: MethodCall.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.marshall;
import java.lang.reflect.Method;
/**
* An extension of the JGroups MethodCall class. The reason for this subclass is a minor
* optimisation in the way method IDs are dealt with. The JGroups class of the same name uses
* a short as a method id, which is more efficient as far as network streaming is concerned.
*
* However, JBossCache uses this id for a lot of == and switch comparisons. Java, being an
* integer oriented virtual machine, goes through a lot of extra steps when performing such simple
* comparisons or arithmetic on non-integer numeric types.
*
* See <a href="http://www.liemur.com/Articles/FineTuningJavaCode-IntOrientedMachine.html">http://www.liemur.com/Articles/FineTuningJavaCode-IntOrientedMachine.html</a>
*
* Thanks to Elias Ross/genman for this info.
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
public class MethodCall extends org.jgroups.blocks.MethodCall
{
private int methodIdInteger = -1;
public MethodCall()
{
super();
}
public MethodCall(Method method, Object[] arguments)
{
super(method, arguments);
}
public MethodCall(Method method, Object[] arguments, int methodIdInteger)
{
super(method, arguments);
this.methodIdInteger = methodIdInteger;
}
public void setMethodId(int id)
{
methodIdInteger = id;
}
public int getMethodId()
{
return methodIdInteger;
}
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final MethodCall that = (MethodCall) o;
return methodIdInteger == that.methodIdInteger && super.equals(o);
}
public int hashCode()
{
return super.hashCode() * 10 + methodIdInteger;
}
public String toString()
{
StringBuffer ret=new StringBuffer();
boolean first=true;
ret.append("MethodName: ");
ret.append(method_name);
ret.append("; MethodIdInteger: ");
ret.append(methodIdInteger);
ret.append("; Args: (");
if(args != null) {
for(int i=0; i < args.length; i++) {
if (first)
{
first = false;
}
else
{
ret.append(", ");
}
ret.append(args[i]);
}
}
ret.append(')');
return ret.toString();
}
}
More information about the jboss-cvs-commits
mailing list