public class CallBack_Skeleton implements CallBackInterface {
private int objectId = 0; // Default value is 0
- private final static String[] methodSignatures = {
-
- "intprintInt()",
- "voidsetInt(int)"
- };
private CallBackInterface cb;
private IoTRMIObject rmiObj;
cb = _cb;
System.out.println("Creating CallBack_Skeleton and waiting!");
- rmiObj = new IoTRMIObject(_port, methodSignatures);
+ rmiObj = new IoTRMIObject(_port);
___waitRequestInvokeMethod();
}
}
- public int ___printInt() {
- return printInt();
+ public void ___printInt() throws IOException {
+ Object retObj = printInt();
+ rmiObj.sendReturnObj(retObj);
}
public void ___setInt() {
Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
- new Class<?>[] { null }, new Class<?>[] { null });
+ new Class<?>[] { null });
setInt((int) paramObj[0]);
}
if (objId == objectId) {
// Multiplex based on object Id
rmiObj.getMethodBytes();
- String methodSign = rmiObj.getSignature();
- Object[] paramObj = null;
- Object retObj = null;
- System.out.println("Method sign: " + methodSign);
-
- if (methodSign.equals("intprintInt()")) {
- retObj = ___printInt();
- } else if (methodSign.equals("voidsetInt(int)")) {
- ___setInt();
- } else
- throw new Error("Signature not recognized!");
- System.out.println("Return object: " + retObj);
-
- if (retObj != null) {
- rmiObj.sendReturnObj(retObj);
+ int methodId = rmiObj.getMethodId();
+
+ switch (methodId) {
+ case 0: ___printInt(); break;
+ case 1: ___setInt(); break;
+ default:
+ throw new Error("Method Id not recognized!");
}
- System.out.println("Servicing remote call for method: " + methodSign);
}
}
}
- // Return method signatures
- public static String[] getMethodSignatures() {
-
- return methodSignatures;
- }
-
-
public static void main(String[] args) throws Exception {
int port = 5010;