org.jgroups.blocks

Class MethodCall

Implemented Interfaces:
Externalizable

public class MethodCall
extends java.lang.Object
implements Externalizable

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.
Version:
$Revision: 1.19 $
Author:
Bela Ban

Field Summary

protected static short
ID
Use an ID to map to a method
protected static short
METHOD
Explicitly ship the method, caller has to determine method himself.
protected static short
OLD
Infer the method from the arguments.
protected static short
SIGNATURE
Provide a signature, similar to JMX.
protected static short
TYPES
Use class information.
protected Object[]
args
The arguments of the method.
protected static Log
log
protected Method
method
The Method of the call.
protected short
method_id
The ID of a method, maps to a java.lang.reflect.Method
protected String
method_name
The name of the method, case sensitive.
protected short
mode
Which mode to use.
protected Map
payload
To carry arbitrary data with a method call, data needs to be serializable if sent across the wire
protected String[]
signature
The signature, e.g., new String[]{String.class.getName(), int.class.getName()}.
protected Class[]
types
The class types, e.g., new Class[]{String.class, int.class}.

Constructor Summary

MethodCall()
Creates an empty method call, this is always invalid, until setName() has been called.
MethodCall(Method method)
MethodCall(Method method, Object[] arguments)
MethodCall(String method_name, Object[] args)
Deprecated. Use one of the constructors that take class types as arguments
MethodCall(String method_name, Object[] args, Class[] types)
MethodCall(String method_name, Object[] args, String[] signature)
MethodCall(short method_id, Object[] args)

Method Summary

Object
get(Object key)
Object[]
getArgs()
returns an ordered list of arguments used for the method invokation
short
getId()
Method
getMethod()
int
getMode()
String
getName()
returns the name of the method to be invoked using this method call object
Object
invoke(Object target)
Invokes the method with the supplied arguments against the target object.
Object
invoke(Object target, Object[] args)
Object
put(Object key, Object value)
void
readExternal(ObjectInput in)
void
setArgs(Object[] args)
void
setId(short method_id)
void
setMethod(Method m)
void
setName(String n)
sets the name for this MethodCall and allowing you to reuse the same object for a different method invokation of a different method
String
toString()
String
toStringDetails()
void
writeExternal(ObjectOutput out)

Field Details

ID

protected static final short ID
Use an ID to map to a method
Field Value:
5

METHOD

protected static final short METHOD
Explicitly ship the method, caller has to determine method himself.
Field Value:
2

OLD

protected static final short OLD
Infer the method from the arguments.
Field Value:
1

SIGNATURE

protected static final short SIGNATURE
Provide a signature, similar to JMX.
Field Value:
4

TYPES

protected static final short TYPES
Use class information.
Field Value:
3

args

protected Object[] args
The arguments of the method.

log

protected static final Log log

method

protected Method method
The Method of the call.

method_id

protected short method_id
The ID of a method, maps to a java.lang.reflect.Method

method_name

protected String method_name
The name of the method, case sensitive.

mode

protected short mode
Which mode to use.

payload

protected Map payload
To carry arbitrary data with a method call, data needs to be serializable if sent across the wire

signature

protected String[] signature
The signature, e.g., new String[]{String.class.getName(), int.class.getName()}.

types

protected Class[] types
The class types, e.g., new Class[]{String.class, int.class}.

Constructor Details

MethodCall

public MethodCall()
Creates an empty method call, this is always invalid, until setName() has been called.

MethodCall

public MethodCall(Method method)

MethodCall

public MethodCall(Method method,
                  Object[] arguments)

MethodCall

public MethodCall(String method_name,
                  Object[] args)

Deprecated. Use one of the constructors that take class types as arguments

Parameters:
method_name -
args -

MethodCall

public MethodCall(String method_name,
                  Object[] args,
                  Class[] types)

MethodCall

public MethodCall(String method_name,
                  Object[] args,
                  String[] signature)

MethodCall

public MethodCall(short method_id,
                  Object[] args)

Method Details

get

public Object get(Object key)

getArgs

public Object[] getArgs()
returns an ordered list of arguments used for the method invokation
Returns:
returns the list of ordered arguments

getId

public short getId()

getMethod

public Method getMethod()

getMode

public int getMode()

getName

public String getName()
returns the name of the method to be invoked using this method call object
Returns:
a case sensitive name, can be null for an invalid method call

invoke

public Object invoke(Object target)
            throws Throwable
Invokes the method with the supplied arguments against the target object. If a method lookup is provided, it will be used. Otherwise, the default method lookup will be used.
Parameters:
target - - the object that you want to invoke the method on
Returns:
an object

invoke

public Object invoke(Object target,
                     Object[] args)
            throws Throwable

put

public Object put(Object key,
                  Object value)

readExternal

public void readExternal(ObjectInput in)
            throws IOException,
                   ClassNotFoundException

setArgs

public void setArgs(Object[] args)

setId

public void setId(short method_id)

setMethod

public void setMethod(Method m)

setName

public void setName(String n)
sets the name for this MethodCall and allowing you to reuse the same object for a different method invokation of a different method
Parameters:
n - - a case sensitive method name

toString

public String toString()

toStringDetails

public String toStringDetails()

writeExternal

public void writeExternal(ObjectOutput out)
            throws IOException

Copyright B) 1998-2005 Bela Ban. All Rights Reserved.