Where parameter-type can be Int, Double, Boolean or Object.
depending on the type of the value returned.
The stub for ConcreteBuffer must be named ConcreteBufferStub.
public interface Buffer extends NetObj {
public void put(Object obj) throws NetException;
public Object get() throws NetException;
}
import netobj.*;
import java.io.*;
public class ConcreteBufferStub extends ConcreteNetObjStub
implements Buffer {
public void put(Object o) throws NetException {
// Serialization for method put
}
public Object get() throws NetException {
// Serialization for method get
}
ObjectOutputStream out= startRemoteCall(ConcreteBufferSkel.Put);
try {
out.writeObject(o); // One for each parameter
}
catch (IOException excp) {
throwNetException(excp);
}
waitRemoteRetVoid();
ObjectOutputStream out= startRemoteCall(ConcreteBufferSkel.Get);
return waitRemoteRetObject();
import netobj.*;
import java.io.*;
public class ConcreteBufferSkel extends ConcreteNetObjSkel {
final static int Put= 1; // method identifiers
final static int Get= 2;
public void dispatch(ObjectInputStream in, ClientConnection client,
ConcreteNetObj netObj, int methodId)
throws IOException, ClassNotFoundException {
ConcreteBuffer server= (ConcreteBuffer)netObj;
switch(methodId) {
case Put: { ... } // dispatching of method put
case Get: { ... } // dispatching of method get
} } }
Object o= (Object)in.readObject(); // get the parameter
client.checkTag(); // not really needed
try {
server.put(o); // invoke the method
}
catch (Exception excp) {
client.remoteRetException(excp);
return;
}
client.remoteRetVoid();
return;
// No parameters
client.checkTag();
Object o= null; // for the value returned
try {
o= server.get(); // invoke the method
}
catch (Exception excp) {
client.remoteRetException(excp);
return;
}
client.remoteRetObject(o);
return;