![]() |
JavaPartyA distributed companion to JavaCurrent release 1.9.5 Bernhard Haumacher, Thomas Moschny and Michael Philippsen |
|
Contents See also
Powered by
|
JavaParty SyntaxExtended JavaParty SyntaxThe JavaParty language extends the Java language with only one new modifier called remote. By prepending a class declaration with the remote modifier, the class is declared to be a remote class. public remote class R {
/** instance variable of remote class */
public int x;
/** instance method of remote class */
public void foo() { ... }
/** static variable of remote class */
public static int y;
/** static method of remote class */
public static void bar() { ... }
}
The instances of a remote class are the "first class" members of a distributed JavaParty environment. They are able to interact with each other, even if they reside on different machines coupled to a JavaParty environment. Accessing Remote Objects and ClassesSyntactically, there is no further difference between remote classes and non-remote classes. Instances of remote classes are created with the new keyword, and the static and non-static members can be accessed like in regular Java. // create an instance of remote class R R r = new R() // access an instance variable of the created remote object r.x = 42; // call its method foo() r.foo() // access a static member of the remote class R R.y = 13; // call a static method of the remote class R.bar(); Runtime Type SystemThe instanceof operator is used in Java to test an object to be an instance of a certain class at runtime. This mechanism works in JavaParty, too. Remote objects can be assigned to any variable that is declared to be of type java.lang.Object. The contents of that variable can thereafter be tested to be of a certain remote class like any other Java class. Object obj = new R();
// Test whether obj is an instance of remote class R.
if (obj instanceof R) { ... }
|
|||||||
| 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. |