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 static shortIDprotected java.lang.reflect.Methodmethodprotected static shortMETHODprotected shortmethod_idprotected java.lang.Stringmethod_nameprotected shortmodeprotected java.lang.Class[]typesprotected static shortTYPES
-
Constructor Summary
Constructors Constructor Description MethodCall()Needed for deserializationMethodCall(short method_id, java.lang.Object... args)MethodCall(java.lang.reflect.Method method, 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 java.lang.Object[]args()MethodCallargs(java.lang.Object... args)java.util.function.Supplier<? extends MethodCall>create()Creates an instance of the class implementing this interfacestatic java.lang.reflect.MethodfindMethod(java.lang.Class target_class, java.lang.String method_name, java.lang.Object[] args)Called by the ProbeHandler impl.protected static java.lang.reflect.Method[]getAllMethods(java.lang.Class target)The method walks up the class hierarchy and returns all methods of this class and those inherited from superclasses and superinterfaces.java.lang.Object[]getArgs()java.lang.reflect.MethodgetMethod()protected static java.lang.reflect.MethodgetMethod(java.lang.Class target, java.lang.String methodName, java.lang.Class[] types)Returns the first method that matches the specified name and parameter types.shortgetMethodId()java.lang.StringgetMethodName()intgetMode()protected voidinit(java.lang.reflect.Method method)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 static booleanisPrimitiveType(java.lang.Class<?> type)java.lang.reflect.Methodmethod()MethodCallmethod(java.lang.reflect.Method m)shortmethodId()MethodCallmethodId(short id)java.lang.StringmethodName()MethodCallmethodName(java.lang.String n)intmode()protected voidreadArgs(java.io.DataInput in, Marshaller marshaller)voidreadFrom(java.io.DataInput in)Read the state of the current object (including superclasses) from instream Note that the input stream must not be closedvoidreadFrom(java.io.DataInput in, Marshaller marshaller)protected voidreadMethod(java.io.DataInput in)protected voidreadTypes(java.io.DataInput in)MethodCallsetArgs(java.lang.Object... args)MethodCallsetMethod(java.lang.reflect.Method m)MethodCallsetMethodId(short id)MethodCallsetMethodName(java.lang.String n)java.lang.StringtoString()java.lang.StringtoStringDetails()protected voidwriteArgs(java.io.DataOutput out, Marshaller marshaller)protected voidwriteMethod(java.io.DataOutput out)voidwriteTo(java.io.DataOutput out)Write the entire state of the current object (including superclasses) to outstream.voidwriteTo(java.io.DataOutput out, Marshaller marshaller)protected voidwriteTypes(java.io.DataOutput out)
-
-
-
Field Detail
-
mode
protected short mode
-
method_name
protected java.lang.String method_name
-
method_id
protected short method_id
-
args
protected java.lang.Object[] args
-
types
protected java.lang.Class[] types
-
method
protected java.lang.reflect.Method method
-
METHOD
protected static final short METHOD
- See Also:
- Constant Field Values
-
TYPES
protected static final short TYPES
- See Also:
- Constant Field Values
-
ID
protected static final short ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MethodCall
public MethodCall()
Needed for deserialization
-
MethodCall
public MethodCall(java.lang.reflect.Method method, 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>
-
getMode
public int getMode()
-
mode
public int mode()
-
getMethodName
public java.lang.String getMethodName()
-
methodName
public java.lang.String methodName()
-
setMethodName
public MethodCall setMethodName(java.lang.String n)
-
methodName
public MethodCall methodName(java.lang.String n)
-
getMethodId
public short getMethodId()
-
methodId
public short methodId()
-
setMethodId
public MethodCall setMethodId(short id)
-
methodId
public MethodCall methodId(short id)
-
getArgs
public java.lang.Object[] getArgs()
-
args
public java.lang.Object[] args()
-
args
public MethodCall args(java.lang.Object... args)
-
setArgs
public MethodCall setArgs(java.lang.Object... args)
-
getMethod
public java.lang.reflect.Method getMethod()
-
method
public java.lang.reflect.Method method()
-
setMethod
public MethodCall setMethod(java.lang.reflect.Method m)
-
method
public MethodCall method(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
-
findMethod
public static java.lang.reflect.Method findMethod(java.lang.Class target_class, java.lang.String method_name, java.lang.Object[] args) throws java.lang.ExceptionCalled by the ProbeHandler impl. All args are strings. Needs to find a method where all parameter types are primitive types, so the strings can be converted- 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
-
writeTo
public void writeTo(java.io.DataOutput out, Marshaller marshaller) throws java.io.IOException- 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
-
readFrom
public void readFrom(java.io.DataInput in, Marshaller marshaller) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
init
protected void init(java.lang.reflect.Method method)
-
getMethod
protected static java.lang.reflect.Method getMethod(java.lang.Class target, java.lang.String methodName, java.lang.Class[] types)Returns the first method that matches the specified name and parameter types. The overriding methods have priority. The method is chosen from all the methods of the current class and all its superclasses and superinterfaces.- Returns:
- the matching method or null if no matching method has been found.
-
writeArgs
protected void writeArgs(java.io.DataOutput out, Marshaller marshaller) throws java.io.IOException- Throws:
java.io.IOException
-
readArgs
protected void readArgs(java.io.DataInput in, Marshaller marshaller) 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
-
readMethod
protected void readMethod(java.io.DataInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
getAllMethods
protected static java.lang.reflect.Method[] getAllMethods(java.lang.Class target)
The method walks up the class hierarchy and returns all methods of this class and those inherited from superclasses and superinterfaces.
-
isPrimitiveType
protected static boolean isPrimitiveType(java.lang.Class<?> type)
-
-