org.javagroups.blocks
Class MethodCall

java.lang.Object
  |
  +--org.javagroups.blocks.MethodCall
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class MethodCall
extends java.lang.Object
implements java.io.Externalizable

A method call is the JavaGroup 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.15 $
Author:
Bela Ban
See Also:
Serialized Form

Field Summary
protected  java.lang.Object[] args
          the arguments of the method
protected  java.lang.reflect.Method method
          the Method of the call
protected static short METHOD
          explicitly ship the method, caller has to determine method himself
protected  java.lang.String method_name
          the name of the method, case sensitive
protected  short mode
          which mode to use
protected static short OLD
          infer the method from the arguments
protected  java.lang.String[] signature
          the signature, e.g.
protected static short SIGNATURE
          provide a signature, similar to JMX
protected  java.lang.Class[] types
          the class types, e.g.
protected static short TYPES
          use class information
 
Constructor Summary
MethodCall()
          creates an empty method call, this is always invalid, until SetName has been called
MethodCall(java.lang.reflect.Method method)
           
MethodCall(java.lang.reflect.Method method, java.lang.Object[] arguments)
           
MethodCall(java.lang.String name)
          Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments
MethodCall(java.lang.String name, java.lang.Object arg1)
          Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments
MethodCall(java.lang.String name, java.lang.Object[] args)
          Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments
MethodCall(java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types)
           
MethodCall(java.lang.String method_name, java.lang.Object[] args, java.lang.String[] signature)
           
MethodCall(java.lang.String name, java.lang.Object arg1, java.lang.Object arg2)
          Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments
MethodCall(java.lang.String name, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments
MethodCall(java.lang.String name, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
          Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments
MethodCall(java.lang.String name, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4, java.lang.Object arg5)
          Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments
 
Method Summary
 void addArg(boolean b)
          adds a primitive boolean as an argument to the end of the argument list
 void addArg(byte b)
          adds a primitive byte as an argument to the end of the argument list
 void addArg(char c)
          adds a primitive char as an argument to the end of the argument list
 void addArg(int i)
          adds a primitive int as an argument to the end of the argument list
 void addArg(long l)
          adds a primitive long as an argument to the end of the argument list
 void addArg(java.lang.Object arg)
          adds an argument to the end of the argument list
 void clearArgs()
           
 java.util.Vector getArgs()
          returns an ordered list of arguments used for the method invokation
 java.lang.reflect.Method getMethod()
           
 int getMode()
           
 java.lang.String getName()
          returns the name of the method to be invoked using this method call object
 void init(java.lang.reflect.Method method)
           
 java.lang.Object invoke(java.lang.Object target, MethodLookup lookup)
          Invokes the method with the supplied arguments against the target object.
static void main(java.lang.String[] args)
           
 void readExternal(java.io.ObjectInput in)
           
 void setArg(int index, java.lang.Object arg)
          Sets the argument at index to arg.
 void setName(java.lang.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
 void setNumArgs(int num)
          Allocates an array for a given number of arguments.
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

method_name

protected java.lang.String method_name
the name of the method, case sensitive


args

protected java.lang.Object[] args
the arguments of the method


types

protected java.lang.Class[] types
the class types, e.g. new Class[]{String.class, int.class}


signature

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


method

protected java.lang.reflect.Method method
the Method of the call


mode

protected short mode
which mode to use


OLD

protected static final short OLD
infer the method from the arguments

See Also:
Constant Field Values

METHOD

protected static final short METHOD
explicitly ship the method, caller has to determine method himself

See Also:
Constant Field Values

TYPES

protected static final short TYPES
use class information

See Also:
Constant Field Values

SIGNATURE

protected static final short SIGNATURE
provide a signature, similar to JMX

See Also:
Constant Field Values
Constructor Detail

MethodCall

public MethodCall()
creates an empty method call, this is always invalid, until SetName has been called


MethodCall

public MethodCall(java.lang.reflect.Method method)

MethodCall

public MethodCall(java.lang.reflect.Method method,
                  java.lang.Object[] arguments)

MethodCall

public MethodCall(java.lang.String name)
Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments

creates a method call without arguments for a certain method. Arguments can always be added using the AddArg method

Parameters:
name - the name of the method, cannot be null
See Also:
MethodCall(java.lang.reflect.Method)

MethodCall

public MethodCall(java.lang.String name,
                  java.lang.Object[] args)
Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments

creates a MethodCall with the given name and the given arguments

Parameters:
name - the name of the method, cannot be null
args - an array of the arguments, can be null (no arguments)
See Also:
MethodCall(java.lang.reflect.Method)

MethodCall

public MethodCall(java.lang.String name,
                  java.lang.Object arg1)
Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments

creates a MethodCall with the given name and the given arguments

Parameters:
name - the name of the method, cannot be null
arg1 - an object
See Also:
MethodCall(java.lang.reflect.Method)

MethodCall

public MethodCall(java.lang.String name,
                  java.lang.Object arg1,
                  java.lang.Object arg2)
Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments

creates a MethodCall with the given name and the given arguments

Parameters:
name - the name of the method, cannot be null
arg1 - first argument
See Also:
MethodCall(java.lang.reflect.Method)

MethodCall

public MethodCall(java.lang.String name,
                  java.lang.Object arg1,
                  java.lang.Object arg2,
                  java.lang.Object arg3)
Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments

creates a MethodCall with the given name and the given arguments

Parameters:
name - the name of the method, cannot be null
arg1 - first argument
arg2 - second argument
arg3 - third argument
See Also:
MethodCall(java.lang.reflect.Method)

MethodCall

public MethodCall(java.lang.String name,
                  java.lang.Object arg1,
                  java.lang.Object arg2,
                  java.lang.Object arg3,
                  java.lang.Object arg4)
Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments

creates a MethodCall with the given name and the given arguments

Parameters:
name - the name of the method, cannot be null
arg1 - first argument
arg2 - second argument
arg3 - third argument
arg4 - fourth argument
See Also:
MethodCall(java.lang.reflect.Method)

MethodCall

public MethodCall(java.lang.String name,
                  java.lang.Object arg1,
                  java.lang.Object arg2,
                  java.lang.Object arg3,
                  java.lang.Object arg4,
                  java.lang.Object arg5)
Deprecated. use the complete constructor with a java.lang.reflect.Method argument since null arguments can not be correctly handled using null arguments

creates a MethodCall with the given name and the given arguments

Parameters:
name - the name of the method, cannot be null
arg1 - first argument
arg2 - second argument
arg3 - third argument
arg4 - fourth argument
arg5 - firth argument
See Also:
MethodCall(java.lang.reflect.Method)

MethodCall

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

MethodCall

public MethodCall(java.lang.String method_name,
                  java.lang.Object[] args,
                  java.lang.String[] signature)
Method Detail

init

public void init(java.lang.reflect.Method method)

getMode

public int getMode()

setNumArgs

public void setNumArgs(int num)
Allocates an array for a given number of arguments. Using setArgs() will help us avoid argument array allocation/deallocation if the number of args is constant


getName

public java.lang.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

setName

public void setName(java.lang.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

getArgs

public java.util.Vector getArgs()
returns an ordered list of arguments used for the method invokation

Returns:
returns the list of ordered arguments

getMethod

public java.lang.reflect.Method getMethod()

addArg

public void addArg(java.lang.Object arg)
adds an argument to the end of the argument list

Parameters:
arg - - object argument for the method invokation

addArg

public void addArg(byte b)
adds a primitive byte as an argument to the end of the argument list

Parameters:
b - - a byte argument for the method invokation

addArg

public void addArg(char c)
adds a primitive char as an argument to the end of the argument list

Parameters:
c - - a char argument for the method invokation

addArg

public void addArg(boolean b)
adds a primitive boolean as an argument to the end of the argument list

Parameters:
b - - a boolean argument for the method invokation

addArg

public void addArg(int i)
adds a primitive int as an argument to the end of the argument list

Parameters:
i - - an int argument for the method invokation

addArg

public void addArg(long l)
adds a primitive long as an argument to the end of the argument list

Parameters:
l - - a long argument for the method invokation

setArg

public void setArg(int index,
                   java.lang.Object arg)
Sets the argument at index to arg. If index is smaller than args.length(), addArg() will be used instead


clearArgs

public void clearArgs()

invoke

public java.lang.Object invoke(java.lang.Object target,
                               MethodLookup lookup)
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
lookup - - an object that allows you to lookup the method on a target object if null is passed as a parameter, the internal FindMethod will be used using core reflection
Returns:
an object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
java.lang.Exception


Copyright ? 2001,2002 www.javagroups.com . All Rights Reserved.