next up previous contents
Next: RequestCorrelator Up: Building blocks Previous: Example

   
MethodCall

This class (JavaGroups.MethodCall) represents a Java method plus its arguments that can be invoked against a target object. Its main differences from java.lang.reflect.Method are that it a) contains its parameter, so that Invoke does not need any arguments, and b) it allows to customize the method lookup algorithm. A method call is serializable which means that it can be sent over the network to some remote peer, and be invoked there (it takes its arguments with it). A message may contain a serialized method call object in its byte buffer3.5.

A MethodCall instance is created given the method name (string) and 0 or more arguments, depending on the number of formal parameters. For convenience, a number of constructors are provided, which take 1 to 3 arguments. If additional arguments are needed, the overloaded methods AddArg can be used to add more arguments.

Method Invoke is used to actually call the method against a target object. Its 2 parameters are the target object, which has to contain the method, and a method lookup instance which allows to override the default method lookup. If the second argument is null, the default method lookup algorithm will be used. Invoke essentially looks up the method to call (an instance of java.lang.reflect.Method) using the class of the target object and the number and types of the arguments of the method call object.

The second parameter to Invoke is a method lookup class which is supposed to return a java.lang.reflect.Method object, given the target's class, the method name and a number of arguments.

Method calls are an important concept in JavaGroups: they provide synchronous (or, if desired, asynchronous) method invocations on top of an inherently asynchronous transport (e.g. channels). Extending this concept to groups, it enables a client to make synchronous group method invocations on all members of a group, and retrieve the results as objects (see 3.4.4).


next up previous contents
Next: RequestCorrelator Up: Building blocks Previous: Example

1999-08-19