import java.util.Arrays;
import iotrmi.Java.IoTRMIObject;
-public class CallBack_Skeleton {
+public class CallBack_Skeleton implements CallBackInterface {
- private String[] methodSignatures = {
+ private int objectId = 0; // Default value is 0
+ private final static String[] methodSignatures = {
"intprintInt()",
"voidsetInt(int)"
};
-
private CallBackInterface cb;
private IoTRMIObject rmiObj;
while (true) {
rmiObj.getMethodBytes();
- String methodSign = rmiObj.getSignature();
- Object[] paramObj = null;
- Object retObj = null;
- System.out.println("Method sign: " + methodSign);
-
- if (methodSign.equals("intprintInt()")) {
- //paramObj = rmiObj.getMethodParams(new Class<?>[] { },
- // new Class<?>[] { null }, new Class<?>[] { null });
- retObj = cb.printInt();
- } else if (methodSign.equals("voidsetInt(int)")) {
- paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
- new Class<?>[] { null }, new Class<?>[] { null });
- cb.setInt((int) paramObj[0]);
- } else
- throw new Error("Signature un-recognized!");
- System.out.println("Return object: " + retObj);
-
- if (retObj != null) {
- rmiObj.sendReturnObj(retObj);
+ int objId = rmiObj.getObjectId();
+ 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)")) {
+ paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
+ new Class<?>[] { null }, new Class<?>[] { null });
+ setInt((int) paramObj[0]);
+ } else
+ throw new Error("Signature not recognized!");
+ System.out.println("Return object: " + retObj);
+
+ if (retObj != null) {
+ rmiObj.sendReturnObj(retObj);
+ }
+ System.out.println("Servicing remote call for method: " + methodSign);
}
- System.out.println("Servicing remote call for method: " + methodSign);
}
}
+ // Return method signatures
+ public static String[] getMethodSignatures() {
+
+ return methodSignatures;
+ }
+
+
+ public int printInt() {
+ return cb.printInt();
+ }
+
+
+ public void setInt(int _i) {
+ cb.setInt(_i);
+ }
+
+
public static void main(String[] args) throws Exception {
int port = 5010;