Package org.jgroups.blocks
Class MethodCall
- java.lang.Object
-
- org.jgroups.blocks.MethodCall
-
- All Implemented Interfaces:
Constructable<MethodCall>,Streamable
public class MethodCall extends java.lang.Object implements Streamable, Constructable<MethodCall>
A method call is the JGroups representation of a remote method. It includes the name of the method (case sensitive) and a list of arguments. A method call is serializable and can be passed over the wire.- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object[]argsprotected java.lang.reflect.Methodmethodprotected shortmethod_idprotected java.lang.Stringmethod_nameprotected java.lang.Class<?>[]types
-
Constructor Summary
Constructors Constructor Description MethodCall()Needed for deserializationMethodCall(short method_id, java.lang.Object... args)MethodCall(java.lang.reflect.Method m, java.lang.Object... arguments)MethodCall(java.lang.String method_name, java.lang.Object[] args, java.lang.Class<?>[] types)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static shortassertNotNegative(short num)java.util.function.Supplier<? extends MethodCall>create()Creates an instance of the class implementing this interfacejava.lang.Object[]getArgs()java.lang.reflect.MethodgetMethod()shortgetMethodId()java.lang.StringgetMethodName()java.lang.Objectinvoke(java.lang.Object target)Invokes the method with the supplied arguments against the target object.java.lang.Objectinvoke(java.lang.Object target, java.lang.Object[] args)protected java.lang.ObjectreadArg(java.io.DataInput in)protected voidreadArgs(java.io.DataInput in)voidreadFrom(java.io.DataInput in)Read the state of the current object (including superclasses) from instream Note that the input stream must not be closedprotected voidreadTypes(java.io.DataInput in)MethodCallsetArgs(java.lang.Object... args)MethodCallsetMethod(java.lang.reflect.Method m)MethodCallsetMethodId(short id)java.lang.StringtoString()java.lang.StringtoStringDetails()booleanuseIds()protected voidwriteArg(java.io.DataOutput out, java.lang.Object obj)protected voidwriteArgs(java.io.DataOutput out)protected voidwriteMethod(java.io.DataOutput out)voidwriteTo(java.io.DataOutput out)Write the entire state of the current object (including superclasses) to outstream.protected voidwriteTypes(java.io.DataOutput out)
-
-
-
Constructor Detail
-
MethodCall
public MethodCall()
Needed for deserialization
-
MethodCall
public MethodCall(java.lang.reflect.Method m, java.lang.Object... arguments)
-
MethodCall
public MethodCall(short method_id, java.lang.Object... args)
-
MethodCall
public MethodCall(java.lang.String method_name, java.lang.Object[] args, java.lang.Class<?>[] types)
-
-
Method Detail
-
create
public java.util.function.Supplier<? extends MethodCall> create()
Description copied from interface:ConstructableCreates an instance of the class implementing this interface- Specified by:
createin interfaceConstructable<MethodCall>
-
useIds
public boolean useIds()
-
getMethodName
public java.lang.String getMethodName()
-
getMethodId
public short getMethodId()
-
setMethodId
public MethodCall setMethodId(short id)
-
getArgs
public java.lang.Object[] getArgs()
-
setArgs
public MethodCall setArgs(java.lang.Object... args)
-
getMethod
public java.lang.reflect.Method getMethod()
-
setMethod
public MethodCall setMethod(java.lang.reflect.Method m)
-
invoke
public java.lang.Object invoke(java.lang.Object target) throws java.lang.ExceptionInvokes the method with the supplied arguments against the target object.- Parameters:
target- - the object that you want to invoke the method on- Returns:
- the result
- Throws:
java.lang.Exception
-
invoke
public java.lang.Object invoke(java.lang.Object target, java.lang.Object[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toStringDetails
public java.lang.String toStringDetails()
-
writeTo
public void writeTo(java.io.DataOutput out) throws java.io.IOExceptionDescription copied from interface:StreamableWrite the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed- Specified by:
writeToin interfaceStreamable- Throws:
java.io.IOException
-
readFrom
public void readFrom(java.io.DataInput in) throws java.io.IOException, java.lang.ClassNotFoundExceptionDescription copied from interface:StreamableRead the state of the current object (including superclasses) from instream Note that the input stream must not be closed- Specified by:
readFromin interfaceStreamable- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeArgs
protected void writeArgs(java.io.DataOutput out) throws java.io.IOException- Throws:
java.io.IOException
-
writeArg
protected void writeArg(java.io.DataOutput out, java.lang.Object obj) throws java.io.IOException- Throws:
java.io.IOException
-
readArgs
protected void readArgs(java.io.DataInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
readArg
protected java.lang.Object readArg(java.io.DataInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeTypes
protected void writeTypes(java.io.DataOutput out) throws java.io.IOException- Throws:
java.io.IOException
-
readTypes
protected void readTypes(java.io.DataInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeMethod
protected void writeMethod(java.io.DataOutput out) throws java.io.IOException- Throws:
java.io.IOException
-
assertNotNegative
protected static short assertNotNegative(short num)
-
-