Using methodId directly without method signature; placing sendReturnObj in individual...
authorrtrimana <rtrimana@uci.edu>
Sat, 5 Nov 2016 20:35:42 +0000 (13:35 -0700)
committerrtrimana <rtrimana@uci.edu>
Sat, 5 Nov 2016 20:35:42 +0000 (13:35 -0700)
iotjava/Makefile
iotjava/iotrmi/C++/sample/TestClass.hpp
iotjava/iotrmi/Java/IoTRMICall.java
iotjava/iotrmi/Java/IoTRMIObject.java
iotjava/iotrmi/Java/sample/CallBack_CBSkeleton.java
iotjava/iotrmi/Java/sample/CallBack_CBStub.java
iotjava/iotrmi/Java/sample/CallBack_Skeleton.java
iotjava/iotrmi/Java/sample/CallBack_Stub.java
iotjava/iotrmi/Java/sample/TestClass.java
iotjava/iotrmi/Java/sample/TestClass_Skeleton.java
iotjava/iotrmi/Java/sample/TestClass_Stub.java

index 70bce37..7427642 100644 (file)
@@ -31,8 +31,8 @@ runtime:
 PHONY += rmi
 rmi:
        mkdir -p $(BIN_DIR)
-#      $(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/*.java
-#      $(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/sample/*.java
+       $(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/*.java
+       $(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/sample/*.java
 #      mkdir -p $(BIN_DIR)/iotrmi/C++
        #$(G++) iotrmi/C++/IoTSocketServer.cpp -o $(BIN_DIR)/iotrmi/C++/IoTSocketServer.out
        #$(G++) iotrmi/C++/IoTSocketClient.cpp -o $(BIN_DIR)/iotrmi/C++/IoTSocketClient.out
@@ -43,11 +43,11 @@ rmi:
        #$(G++) iotrmi/C++/sample/CallBack.hpp -o $(BIN_DIR)/iotrmi/C++/sample/CallBack.out --std=c++11
        #$(G++) iotrmi/C++/sample/CallBack_CBStub.hpp -o $(BIN_DIR)/iotrmi/C++/sample/CallBack_CBStub.out --std=c++11
        #$(G++) iotrmi/C++/sample/CallBack_CBSkeleton.hpp -o $(BIN_DIR)/iotrmi/C++/sample/CallBack_CBSkeleton.out --std=c++11
-       $(G++) iotrmi/C++/sample/CallBack_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/CallBack_Stub.out --std=c++11
-       $(G++) iotrmi/C++/sample/CallBack_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/CallBack_Skeleton.out --std=c++11
+#      $(G++) iotrmi/C++/sample/CallBack_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/CallBack_Stub.out --std=c++11
+#      $(G++) iotrmi/C++/sample/CallBack_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/CallBack_Skeleton.out --std=c++11
        #$(G++) iotrmi/C++/sample/TestClass.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass.out --std=c++11
-       $(G++) iotrmi/C++/sample/TestClass_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Stub.out --std=c++11 -pthread
-       $(G++) iotrmi/C++/sample/TestClass_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Skeleton.out --std=c++11 -pthread
+#      $(G++) iotrmi/C++/sample/TestClass_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Stub.out --std=c++11 -pthread
+#      $(G++) iotrmi/C++/sample/TestClass_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Skeleton.out --std=c++11 -pthread
        #$(G++) iotrmi/C++/sample/Test.cpp -o ../bin/iotrmi/C++/sample/Test.out --std=c++11 -lpthread
        #$(G++) iotrmi/C++/sample/Test2.cpp -o ../bin/iotrmi/C++/sample/Test2.out --std=c++11 -pthread -pg
 #      $(G++) iotrmi/C++/sample/StructC.cpp -o ../bin/iotrmi/C++/sample/StructC.out --std=c++11
index 0384f22..f8b9ffb 100644 (file)
@@ -145,17 +145,8 @@ int TestClass::callBack() {
 
        int sum = 0;
        for (CallBackInterface* cb : cbvec) {
-               //cout << "Sum: " << sum << endl;
                sum = sum + cb->printInt();
-               //cb->setInt(sum++);
        }
-       //CallBackInterface* cb = cbvec[0];
-       //sum = cb->printInt();
-       //sum = sum + cb->printInt();
-       //cb->printInt();
-       //CallBackInterface* cb1 = cbvec[0];
-       //cb1->printInt();
-
 
        return sum;
 }
index 2ec265c..842547d 100644 (file)
@@ -31,28 +31,27 @@ public class IoTRMICall {
         */
        private IoTRMIUtil rmiUtil;
        private IoTSocketClient rmiClient;
-       private List<String> listMethodId;      // Map from method ID to signature
+       //private List<String> listMethodId;    // Map from method ID to signature
 
 
        /**
         * Constructors
         */
-       public IoTRMICall(int _port, String _address, int _rev, String[] _methodSign) throws IOException {
+       public IoTRMICall(int _port, String _address, int _rev) throws IOException {
 
                rmiUtil = new IoTRMIUtil();
                rmiClient = new IoTSocketClient(_port, _address, _rev);
-               listMethodId = Arrays.asList(_methodSign); // Initialize the method ID map
        }
 
 
        /**
         * remoteCall() calls a method remotely by passing in parameters and getting a return Object
         */
-       public synchronized Object remoteCall(int objectId, String methodSign, Class<?> retType, Class<?> retGenTypeKey, 
+       public synchronized Object remoteCall(int objectId, int methodId, Class<?> retType, Class<?> retGenTypeKey, 
                        Class<?> retGenTypeVal, Class<?>[] paramCls, Object[] paramObj) {
 
                // Send method info
-               byte[] methodBytes = methodToBytes(objectId, methodSign, paramCls, paramObj);
+               byte[] methodBytes = methodToBytes(objectId, methodId, paramCls, paramObj);
                try {
                        rmiClient.sendBytes(methodBytes);
                } catch (IOException ex) {
@@ -69,6 +68,7 @@ public class IoTRMICall {
                                ex.printStackTrace();
                                throw new Error("IoTRMICall: Error when receiving bytes - rmiClient.receiveBytes()");
                        }
+                       System.out.println("Return object bytes: " + Arrays.toString(retObjBytes));
                        retObj = IoTRMIUtil.getParamObject(retType, retGenTypeKey, retGenTypeVal, retObjBytes);
                }
                return retObj;
@@ -78,13 +78,12 @@ public class IoTRMICall {
        /**
         * methodToBytes() returns byte representation of a method
         */
-       public byte[] methodToBytes(int objectId, String methodSign, Class<?>[] paramCls, Object[] paramObj) {
+       public byte[] methodToBytes(int objectId, int methId, Class<?>[] paramCls, Object[] paramObj) {
 
                // Initialized to the length of method ID
                int methodLen = IoTRMIUtil.OBJECT_ID_LEN;
                byte[] objId = IoTRMIUtil.intToByteArray(objectId);
                // Get method ID in bytes
-               int methId = listMethodId.indexOf(methodSign);
                byte[] methodId = IoTRMIUtil.intToByteArray(methId);
                // Get byte arrays and calculate method bytes length
                int numbParam = paramObj.length;
index 043c28a..317ed1f 100644 (file)
@@ -37,12 +37,11 @@ public class IoTRMIObject {
        /**
         * Constructors
         */
-       public IoTRMIObject(int _port, String[] _methodSign) throws  
+       public IoTRMIObject(int _port) throws  
                ClassNotFoundException, InstantiationException, 
                        IllegalAccessException, IOException {
 
                rmiUtil = new IoTRMIUtil();
-               listMethodId2Sign = Arrays.asList(_methodSign); // Initialize the method ID list
                methodBytes = null;
                rmiServer = new IoTSocketServer(_port);
                rmiServer.connect();
@@ -56,6 +55,7 @@ public class IoTRMIObject {
 
                // Receive method info
                methodBytes = rmiServer.receiveBytes(methodBytes);
+               System.out.println("Method: " + Arrays.toString(methodBytes));
                return methodBytes;
        }
 
@@ -99,9 +99,9 @@ public class IoTRMIObject {
 
 
        /**
-        * getSignature() gets method signature from bytes
+        * getMethodId() gets method Id from bytes
         */
-       public String getSignature() {
+       public int getMethodId() {
 
                // Get method Id bytes
                byte[] methodIdBytes = new byte[IoTRMIUtil.METHOD_ID_LEN];
@@ -109,8 +109,8 @@ public class IoTRMIObject {
                System.arraycopy(methodBytes, IoTRMIUtil.OBJECT_ID_LEN, methodIdBytes, 0, IoTRMIUtil.METHOD_ID_LEN);
                // Get method Id
                int methodId = IoTRMIUtil.byteArrayToInt(methodIdBytes);
-               // Get method signature from the list
-               return listMethodId2Sign.get(methodId);
+               // Get method Id
+               return methodId;
        }
 
 
index 2c8ece3..4149630 100644 (file)
@@ -34,8 +34,9 @@ public class CallBack_CBSkeleton implements CallBackInterface {
        }
        
        
-       public int ___printInt() {
-               return printInt();
+       public void ___printInt(IoTRMIObject rmiObj) throws IOException {
+               Object retObj = printInt();
+               rmiObj.sendReturnObj(retObj);
        }
 
 
@@ -51,21 +52,16 @@ public class CallBack_CBSkeleton implements CallBackInterface {
        }
        
 
-       public Object invokeMethod(IoTRMIObject rmiObj) throws IOException {
+       public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
 
-               String methodSign = rmiObj.getSignature();
-               Object[] paramObj = null;
-               Object retObj = null;
+               int methodId = rmiObj.getMethodId();
 
-               if (methodSign.equals("intprintInt()")) {
-                       retObj = ___printInt();
-               } else if (methodSign.equals("voidsetInt(int)")) {
-                       ___setInt(rmiObj);
-               } else
-                       throw new Error("Signature not recognized!");
-               System.out.println("Return object: " + retObj);
-
-               return retObj;
+               switch (methodId) {
+                       case 0: ___printInt(rmiObj); break;
+                       case 1: ___setInt(rmiObj); break;
+                       default: 
+                               throw new Error("Signature not recognized!");
+               }
        }
 
 
index 199595c..9c733e5 100644 (file)
@@ -36,22 +36,22 @@ public class CallBack_CBStub implements CallBackInterface {
 
        public int printInt() {
 
-               String sign = "intprintInt()";
+               int methodId = 0;
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] { };
                Object[] paramObj = new Object[] { };
-               Object retObj = rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
                return (int)retObj;
        }
 
 
        public void setInt(int _i) {
 
-               String sign = "voidsetInt(int)";
+               int methodId = 1;
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] { int.class };
                Object[] paramObj = new Object[] { _i };
-               rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
        }
 
 
index 8c587f8..d6d4ee0 100644 (file)
@@ -26,7 +26,7 @@ public class CallBack_Skeleton implements CallBackInterface {
 
                cb = _cb;
                System.out.println("Creating CallBack_Skeleton and waiting!");
-               rmiObj = new IoTRMIObject(_port, methodSignatures);
+               rmiObj = new IoTRMIObject(_port);
                ___waitRequestInvokeMethod();
        }
 
@@ -36,8 +36,9 @@ public class CallBack_Skeleton implements CallBackInterface {
        }
        
        
-       public int ___printInt() {
-               return printInt();
+       public void ___printInt() throws IOException {
+               Object retObj = printInt();
+               rmiObj.sendReturnObj(retObj);
        }
 
 
@@ -63,23 +64,14 @@ public class CallBack_Skeleton implements CallBackInterface {
                        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("Signature not recognized!");
                                }
-                               System.out.println("Servicing remote call for method: " + methodSign);
                        }
                }
        }
index 4b9b786..638f7da 100644 (file)
@@ -22,7 +22,7 @@ public class CallBack_Stub implements CallBackInterface {
         */
        public CallBack_Stub(int _port, String _address, int _rev) throws IOException {
 
-               rmiCall = new IoTRMICall(_port, _address, _rev, methodSignatures);
+               rmiCall = new IoTRMICall(_port, _address, _rev);
        }
 
 
@@ -35,22 +35,22 @@ public class CallBack_Stub implements CallBackInterface {
 
        public int printInt() {
 
-               String sign = "intprintInt()";
+               int methodId = 0;
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] { };
                Object[] paramObj = new Object[] { };
-               Object retObj = rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
                return (int)retObj;
        }
 
 
        public void setInt(int _i) {
 
-               String sign = "voidsetInt(int)";
+               int methodId = 1;
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] { int.class };
                Object[] paramObj = new Object[] { _i };
-               rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
        }
 
 
index a59518a..c1c397f 100644 (file)
@@ -139,9 +139,9 @@ public class TestClass implements TestClassInterface {
                    }
                }
            };
-               thread2.start();*/
+               thread2.start();
 
-               //return 1;
+               return 1;*/
                return sum;
        }
 
index a164740..7147073 100644 (file)
@@ -18,18 +18,18 @@ public class TestClass_Skeleton implements TestClassInterface {
        private static int objIdCnt = 0; // Counter for callback object Ids
        private final static String[] methodSignatures = {
 
-               "voidsetA(int)",
-               "voidsetB(float)",
-               "voidsetC(string)",
-               "sumArray(string[])",
-               "intsetAndGetA(int)",
-               "intsetACAndGetA(string,int)",
-               "intcallBack()",
-               "voidregisterCallBack(CallBackInterface)",
-               "voidregisterCallBack(CallBackInterface[])",
-               "registercallback",
-               "handleStruct(StructJ[])",
-               "structsize"
+               "voidsetA(int)", // 0
+               "voidsetB(float)", // 1
+               "voidsetC(string)", // 2
+               "sumArray(string[])", // 3
+               "intsetAndGetA(int)", // 4
+               "intsetACAndGetA(string,int)", // 5
+               "intcallBack()", // 6
+               "voidregisterCallBack(CallBackInterface)", // 7
+               "voidregisterCallBack(CallBackInterface[])", // 8
+               "registercallback", // 9
+               "handleStruct(StructJ[])", // 10
+               "structsize" // 11
        };
 
        private TestClassInterface tc;
@@ -48,7 +48,7 @@ public class TestClass_Skeleton implements TestClassInterface {
 
                tc = _tc;
                port = _port;
-               rmiObj = new IoTRMIObject(_port, methodSignatures);
+               rmiObj = new IoTRMIObject(_port);
                ___waitRequestInvokeMethod();
        }
 
@@ -101,11 +101,12 @@ public class TestClass_Skeleton implements TestClassInterface {
        }
        
        
-       public String ___sumArray() {
+       public void ___sumArray() throws IOException {
                
                Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { String[].class }, 
                        new Class<?>[] { null }, new Class<?>[] { null });
-               return sumArray((String[]) paramObj[0]);
+               Object retObj = sumArray((String[]) paramObj[0]);
+               rmiObj.sendReturnObj(retObj);
        }
        
        
@@ -115,11 +116,12 @@ public class TestClass_Skeleton implements TestClassInterface {
        }
        
        
-       public int ___setAndGetA() {
+       public void ___setAndGetA() throws IOException {
                
                Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
                        new Class<?>[] { null }, new Class<?>[] { null });
-               return setAndGetA((int) paramObj[0]);
+               Object retObj = setAndGetA((int) paramObj[0]);
+               rmiObj.sendReturnObj(retObj);
        }
        
        
@@ -129,11 +131,12 @@ public class TestClass_Skeleton implements TestClassInterface {
        }
        
        
-       public int ___setACAndGetA() {
+       public void ___setACAndGetA() throws IOException {
                
                Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { String.class, int.class }, 
                        new Class<?>[] { null, null }, new Class<?>[] { null, null });
-               return setACAndGetA((String) paramObj[0], (int) paramObj[1]);
+               Object retObj = setACAndGetA((String) paramObj[0], (int) paramObj[1]);
+               rmiObj.sendReturnObj(retObj);
        }
        
        
@@ -177,8 +180,8 @@ public class TestClass_Skeleton implements TestClassInterface {
                
                Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class, String.class, int.class }, 
                        new Class<?>[] { null, null, null }, new Class<?>[] { null, null, null });
-               String[] methodSignatures = CallBack_CBStub.getMethodSignatures();
-               rmiCall = new IoTRMICall((int) paramObj[0], (String) paramObj[1], (int) paramObj[2], methodSignatures);
+               //String[] methodSignatures = CallBack_CBStub.getMethodSignatures();
+               rmiCall = new IoTRMICall((int) paramObj[0], (String) paramObj[1], (int) paramObj[2]);
                System.out.println("Creating a new IoTRMICall object");
        }
        
@@ -189,9 +192,10 @@ public class TestClass_Skeleton implements TestClassInterface {
        }
        
        
-       public int ___callBack() {
+       public void ___callBack() throws IOException {
                
-               return callBack();
+               Object retObj = callBack();
+               rmiObj.sendReturnObj(retObj);
        }
        
 
@@ -205,7 +209,7 @@ public class TestClass_Skeleton implements TestClassInterface {
                
                Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
                        new Class<?>[] { null }, new Class<?>[] { null });
-               return (int) paramObj[0];               
+               return (int) paramObj[0];
        }
        
        
@@ -253,41 +257,26 @@ public class TestClass_Skeleton implements TestClassInterface {
                        int _objectId = rmiObj.getObjectId();
                        if (_objectId == objectId) {
                        // Multiplex based on object Id
-                               String methodSign = rmiObj.getSignature();
-                               Object retObj = null;
-                               if (methodSign.equals("voidsetA(int)")) {
-                                       ___setA();
-                               } else if (methodSign.equals("voidsetB(float)")) {
-                                       ___setB();
-                               } else if (methodSign.equals("voidsetC(string)")) {
-                                       ___setC();
-                               } else if (methodSign.equals("sumArray(string[])")) {
-                                       retObj = ___sumArray();
-                               } else if (methodSign.equals("intsetAndGetA(int)")) {
-                                       retObj = ___setAndGetA();
-                               } else if (methodSign.equals("intsetACAndGetA(string,int)")) {
-                                       retObj = ___setACAndGetA();
-                               } else if (methodSign.equals("voidregisterCallBack(CallBackInterface)")) {
-                                       ___registerCallback();
-                               } else if (methodSign.equals("voidregisterCallBack(CallBackInterface[])")) {
-                                       ____registerCallback();
-                               } else if (methodSign.equals("intcallBack()")) {
-                                       retObj = ___callBack();
-                               // Special option to register callback
-                               } else if (methodSign.equals("registercallback")) {
-                                       ___regCB();
-                               // Struct handling (3 is the size of the struct)
-                               } else if (methodSign.equals("structsize")) {
-                                       structsize1 = ___structSize();
-                               } else if (methodSign.equals("handleStruct(StructJ[])")) {
-                                       ___handleStruct(structsize1);
-                               } else
-                                       throw new Error("Signature not recognized!");
+                               int methodId = rmiObj.getMethodId();
+                               switch (methodId) {
 
-                               if (retObj != null) {
-                                       rmiObj.sendReturnObj(retObj);
+                                       case 0: ___setA(); break;
+                                       case 1: ___setB(); break;
+                                       case 2: ___setC(); break;
+                                       case 3: ___sumArray(); break;
+                                       case 4: ___setAndGetA(); break;
+                                       case 5: ___setACAndGetA(); break;
+                                       case 6: ___callBack(); break; 
+                                       case 7: ___registerCallback(); break;
+                                       case 8: ____registerCallback(); break;
+                                       // Special option to register callback
+                                       case 9: ___regCB(); break;
+                                       // Struct handling (3 is the size of the struct)
+                                       case 10: ___handleStruct(structsize1); break;
+                                       case 11: structsize1 = ___structSize(); break;
+                                       default:
+                                               throw new Error("Signature not recognized!");
                                }
-                               System.out.println("Servicing remote call for object: " + objectId + " - method: " + methodSign);
                        }
                }
        }
index adad218..3f70b0c 100644 (file)
@@ -29,18 +29,18 @@ public class TestClass_Stub implements TestClassInterface {
        private static int objIdCnt = 0; // Counter for callback object Ids
        private final static String[] methodSignatures = {
 
-               "voidsetA(int)",
-               "voidsetB(float)",
-               "voidsetC(string)",
-               "sumArray(string[])",
-               "intsetAndGetA(int)",
-               "intsetACAndGetA(string,int)",
-               "intcallBack()",
-               "voidregisterCallBack(CallBackInterface)",
-               "voidregisterCallBack(CallBackInterface[])",
-               "registercallback",
-               "handleStruct(StructJ[])",
-               "structsize"
+               "voidsetA(int)", // 0
+               "voidsetB(float)", // 1
+               "voidsetC(string)", // 2
+               "sumArray(string[])", // 3
+               "intsetAndGetA(int)", // 4
+               "intsetACAndGetA(string,int)", // 5
+               "intcallBack()", // 6
+               "voidregisterCallBack(CallBackInterface)", // 7
+               "voidregisterCallBack(CallBackInterface[])", // 8
+               "registercallback", // 9
+               "handleStruct(StructJ[])", // 10
+               "structsize" // 11
        };
 
        /**
@@ -50,7 +50,8 @@ public class TestClass_Stub implements TestClassInterface {
 
                address = _address;
                ports = _ports;
-               rmiCall = new IoTRMICall(_port, _address, _rev, methodSignatures);
+               //rmiCall = new IoTRMICall(_port, _address, _rev, methodSignatures);
+               rmiCall = new IoTRMICall(_port, _address, _rev);
                listCBObj = new ArrayList<CallBackInterface>();
                ___initCallBack();
        }
@@ -78,19 +79,17 @@ public class TestClass_Stub implements TestClassInterface {
                Thread thread = new Thread() {
                        public void run() {
                        try{
-                                       String[] methodSignatures = CallBack_CBSkeleton.getMethodSignatures();
-                                       rmiObj = new IoTRMIObject(ports[0], methodSignatures);
+                                       //String[] methodSignatures = CallBack_CBSkeleton.getMethodSignatures();
+                                       //rmiObj = new IoTRMIObject(ports[0], methodSignatures);
+                                       rmiObj = new IoTRMIObject(ports[0]);
                                        Object retObj = null;
                                        while (true) {
                                                byte[] method = rmiObj.getMethodBytes();
                                                int objId = IoTRMIObject.getObjectId(method);
                                                CallBack_CBSkeleton skel = (CallBack_CBSkeleton) listCBObj.get(objId);
                                                if (skel != null) {
-                                                       rmiObj.setMethodBytes(method);
-                                                       retObj = skel.invokeMethod(rmiObj);
-                                               }
-                                               if (retObj != null) {
-                                                       rmiObj.sendReturnObj(retObj);
+                                                       //rmiObj.setMethodBytes(method);
+                                                       skel.invokeMethod(rmiObj);
                                                }
                                        }
                                } catch (Exception ex){
@@ -101,19 +100,21 @@ public class TestClass_Stub implements TestClassInterface {
                };
                thread.start();
 
-               String sign = "registercallback";       // can be any string
+               //String sign = "registercallback";     // can be any string
+               int methodId = 9;
                Class<?> retType = void.class;
                // port, address, rev
                Class<?>[] paramCls = new Class<?>[] { int.class, String.class, int.class };
                Object[] paramObj = new Object[] { ports[0], address, 0 };
-               rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               //rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
        }
 
 
        // Single callback handling
        public void registerCallback(CallBackInterface _cb) {
 
-               Thread thread = new Thread() {
+               /*Thread thread = new Thread() {
                        public void run() {
                    try{
                                        CallBack_Skeleton cbskel = new CallBack_Skeleton(_cb, ports[0]);
@@ -130,7 +131,7 @@ public class TestClass_Stub implements TestClassInterface {
                // port, address, and rev
                Class<?>[] paramCls = new Class<?>[] { int.class, String.class, int.class };
                Object[] paramObj = new Object[] { ports[0], address, 0 };
-               rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);*/
        }
 
 
@@ -147,85 +148,88 @@ public class TestClass_Stub implements TestClassInterface {
                        throw new Error("Class not found / instantiation / illegal access / IO error!");
                }
 
-               String sign = "voidregisterCallBack(CallBackInterface[])";
+               //String sign = "voidregisterCallBack(CallBackInterface[])";
+               int methodId = 8;
                Class<?> retType = void.class;
                // port, address, rev, and number of objects
                Class<?>[] paramCls = new Class<?>[] { int.class };
                Object[] paramObj = new Object[] { _cb.length };
-               rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               //rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
        }
 
 
        public void setA(int _int) {
 
-               String sign = "voidsetA(int)";
+               //String sign = "voidsetA(int)";
+               int methodId = 0;
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] { int.class };
                Object[] paramObj = new Object[] { _int };
-               rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
        }
 
 
        public void setB(float _float) {
 
-               String sign = "voidsetB(float)";
+               int methodId = 1;
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] { float.class };
                Object[] paramObj = new Object[] { _float };
-               rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
        }
 
 
        public void setC(String _string) {
 
-               String sign = "voidsetC(string)";
+               int methodId = 2;
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] { String.class };
                Object[] paramObj = new Object[] { _string };
-               rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
        }
 
 
        // Getters
        public String sumArray(String[] newA) {
 
-               String sign = "sumArray(string[])";
+               int methodId = 3;
                Class<?> retType = String.class;
                Class<?>[] paramCls = new Class<?>[] { String[].class };
                Object[] paramObj = new Object[] { newA };
-               Object retObj = rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
                return (String)retObj;
        }
 
 
        public int setAndGetA(int newA) {
-               String sign = "intsetAndGetA(int)";
+               int methodId = 4;
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] { int.class };
                Object[] paramObj = new Object[] { newA };
-               Object retObj = rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
                return (int)retObj;
        }
 
 
        public int setACAndGetA(String newC, int newA) {
 
-               String sign = "intsetACAndGetA(string,int)";
+               int methodId = 5;
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] { String.class, int.class };
                Object[] paramObj = new Object[] { newC, newA };
-               Object retObj = rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
                return (int)retObj;
        }
 
 
        public int callBack() {
 
-               String sign = "intcallBack()";
+               int methodId = 6;
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] { };
                Object[] paramObj = new Object[] { };
-               Object retObj = rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
                return (int)retObj;
 
        }
@@ -233,13 +237,13 @@ public class TestClass_Stub implements TestClassInterface {
 
        public void handleStruct(StructJ[] data) {
 
-               String sign = "structsize";
+               int methodId = 11;
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] { int.class };
                Object[] paramObj = new Object[] { data.length };
-               rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
+               rmiCall.remoteCall(objectId, methodId, retType, null, null, paramCls, paramObj);
 
-               String sign2 = "handleStruct(StructJ[])";
+               int methodId2 = 10;
                Class<?> retType2 = void.class;
                // Calculate the size of the array
                Class<?>[] paramCls2 = new Class<?>[3*data.length];
@@ -255,7 +259,7 @@ public class TestClass_Stub implements TestClassInterface {
                        paramObj2[pos++] = data[i].year;
                }
                System.out.println(Arrays.toString(paramObj2));
-               rmiCall.remoteCall(objectId, sign2, retType2, null, null, paramCls2, paramObj2);
+               rmiCall.remoteCall(objectId, methodId2, retType2, null, null, paramCls2, paramObj2);
        }
 
 
@@ -276,7 +280,7 @@ public class TestClass_Stub implements TestClassInterface {
                System.out.println("Return value: " + tcstub.setACAndGetA("string", 123));
                System.out.println("Return value: " + tcstub.sumArray(new String[] { "123", "456", "987" }));
 
-               /*CallBackInterface cb1 = new CallBack(23);
+               CallBackInterface cb1 = new CallBack(23);
                CallBackInterface cb2 = new CallBack(33);
                CallBackInterface cb3 = new CallBack(43);
                CallBackInterface[] cb = { cb1, cb2, cb3 };
@@ -287,7 +291,7 @@ public class TestClass_Stub implements TestClassInterface {
                CallBackInterface cb6 = new CallBack(12);
                CallBackInterface[] cbt = { cb4, cb5, cb6 };
                tcstub.registerCallback(cbt);
-               System.out.println("Return value from callback: " + tcstub.callBack());*/
+               System.out.println("Return value from callback: " + tcstub.callBack());
 
                StructJ[] data = new StructJ[2];
                for (int i=0; i<2; i++) {