Information Technology Reference
In-Depth Information
For example, given the class 6 in Figure 3.7 the portal:
portal BoundedBufferV1 {
int capacity();
void put(Book x);
Book take();
}
states that:
•Themethods capacity , put and take are remote methods.
•Themethod count , as it has not been defined in the portal, is a local method.
•The Book argument to the put method and the Book return value from the
take method are passed and returned respectively using the default transfer
strategy, copy-by-value.
If, instead, the programmer wishes to use the copy-by-reference semantics,
the following portal can be defined using the gref (for global reference) keyword:
portal BoundedBufferV1 {
int capacity();
void put(Book x) {
x: gref;
}
Book take() {
return: gref;
}
}
However by doing so, the Book class must now be defined as a remote object as
well:
portal Book {
void print();
}
The application that instantiates the bounded buffer class, defined in Fig-
ure 3.7, must export a reference to that instance in the name server as illustrated
below:
public class StartBuffer {
public static void main(String args[]) {
BoundedBufferV1 bb = new BoundedBufferV1(100);
try {
DJNaming.bind( "rmi://goblin/BB" ,bb);
} catch (Exception e) {
System.out.println( "StartBuffer err: " + e.getMessage());
e.printStackTrace();
}
}
}
6 The examples in this section are reproduced from Lopes [65].
 
Search WWH ::




Custom Search