![]() |
JavaPartyA distributed companion to JavaCurrent release 1.9.5 Bernhard Haumacher, Thomas Moschny and Michael Philippsen |
|
Contents See also
Powered by
|
JavaParty Object ModelRemote classesRemote classes and their instances are the "first class" objects in JavaParty. JavaParty provides a runtime environment distributed over several machines that approximately behaves like a single Java virtual machine with respect to remote objects:
Local classesExisting regular Java classes can be reused in distributed JavaParty programs or can be written and compiled with the JavaParty compiler. Local classes are all classes that are not marked with the remote modifier. Local objects are always private to the remote object they are created in. If they are passed to methods of other remote objects or stored into instance variables of other remote objects, they are always copied. Local classes and objects behave in the distributed environment according to the following rules:
Method invocations on remote objectsInvoking a method of a remote object not necessarily results in a remote method invocation. A method invocation is considered to be local, if it is syntactically evident that a method of the same remote object is invoked. In that case local method invocation semantics apply and all parameters of object type are passed by reference no matter whether they are remote or not. The following sections explain what is considered to be a remote invocation in JavaParty and what is not. I. Local invocationsThe method invocation occurs within a non-static method of a remote object and no explicit reference, the this, or the super reference is used. In that case it is syntactically clear that a method of a the same remote object is invoked. The following invocations of method bar() are considered to be non-remote method invocations, and local semantics apply: Any additional arguments would be passed by reference, even if they are local objects: remote class R {
void bar() { ... }
void foo() {
bar(); // local access
this.bar(); // local access
}
}
II. Remote invocationsIn contrast, the following invocation of method bar() is considered to be remote, and any additional local object parameters would be copied, even if at runtime a method of the same object will be invoked: remote class R {
void bar() { ... }
void foo() {
R r = this;
r.bar(); // remote access
}
}
The difference to the previous example is that from the syntax of the invocation it is not evident that a method of the same object will be invoked. Because an explicit reference to an arbitrary object r is used, this access is considered to be a remote access and remote semantics apply. From the above follows that an invocation of a static method of a remote class is always considered to be a remote invocation, unless it is from within a static method of the same class. In the following example a static method s_bar() is invoked from within a non-static method of the same class. In all three invocations of s_bar() remote semantics apply, because the object that currently executes the method foo() and the object representing the remote class R could be allocated on different nodes. remote class R {
static void s_bar() { ... }
void foo() {
R r = this;
s_bar(); // remote access
R.s_bar() // remote access
r.s_bar() // remote access
}
}
You can try the example "ObjectModel" to verify these descriptions of the JavaParty behavior. |
|||||||
| For comments and bug reports please use the JavaParty users mailing list. Page design & maintenance: Bernhard Haumacher. Last update: Fri Mar 30 18:46:00 GMT+01:00 2007 Java is a trademark of Sun Microsystems. |