1 package iotrmi.Java.sample;
3 import java.io.IOException;
5 import java.util.Arrays;
6 import iotrmi.Java.IoTRMIObject;
8 public class CallBack_Skeleton implements CallBackInterface {
10 private int objectId = 0; // Default value is 0
11 private final static String[] methodSignatures = {
16 private CallBackInterface cb;
17 private IoTRMIObject rmiObj;
23 public CallBack_Skeleton(CallBackInterface _cb, int _port) throws
24 ClassNotFoundException, InstantiationException,
25 IllegalAccessException, IOException {
28 System.out.println("Creating CallBack_Skeleton and waiting!");
29 rmiObj = new IoTRMIObject(_port);
30 ___waitRequestInvokeMethod();
34 public int printInt() {
39 public void ___printInt() throws IOException {
40 Object retObj = printInt();
41 rmiObj.sendReturnObj(retObj);
45 public void setInt(int _i) {
50 public void ___setInt() {
51 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
52 new Class<?>[] { null }, new Class<?>[] { null });
53 setInt((int) paramObj[0]);
57 private void ___waitRequestInvokeMethod() throws IOException {
59 // Loop continuously waiting for incoming bytes
62 rmiObj.getMethodBytes();
63 int objId = rmiObj.getObjectId();
64 if (objId == objectId) {
65 // Multiplex based on object Id
66 rmiObj.getMethodBytes();
67 int methodId = rmiObj.getMethodId();
70 case 0: ___printInt(); break;
71 case 1: ___setInt(); break;
73 throw new Error("Signature not recognized!");
80 // Return method signatures
81 public static String[] getMethodSignatures() {
83 return methodSignatures;
87 public static void main(String[] args) throws Exception {
90 CallBack cb = new CallBack(23);
91 CallBack_Skeleton cbSkel = new CallBack_Skeleton(cb, port);
92 //cbSkel.waitRequestInvokeMethod();