Completing stub and skeleton sides' APIs; Adding tests for C++ side; Still need to...
authorrtrimana <rtrimana@uci.edu>
Thu, 27 Oct 2016 19:14:35 +0000 (12:14 -0700)
committerrtrimana <rtrimana@uci.edu>
Thu, 27 Oct 2016 19:14:35 +0000 (12:14 -0700)
15 files changed:
iotjava/Makefile
iotjava/iotrmi/C++/IoTRMICall.hpp
iotjava/iotrmi/C++/IoTRMIObject.hpp
iotjava/iotrmi/C++/IoTRMIUtil.hpp
iotjava/iotrmi/C++/TestClass.hpp [deleted file]
iotjava/iotrmi/C++/sample/TestClass.cpp [new file with mode: 0644]
iotjava/iotrmi/C++/sample/TestClass.hpp [new file with mode: 0644]
iotjava/iotrmi/C++/sample/TestClassInterface.hpp [new file with mode: 0644]
iotjava/iotrmi/C++/sample/TestClass_Skeleton.cpp [new file with mode: 0644]
iotjava/iotrmi/C++/sample/TestClass_Skeleton.hpp [new file with mode: 0644]
iotjava/iotrmi/C++/sample/TestClass_Stub.cpp [new file with mode: 0644]
iotjava/iotrmi/C++/sample/TestClass_Stub.hpp [new file with mode: 0644]
iotjava/iotrmi/Java/sample/TestClass.java
iotjava/iotrmi/Java/sample/TestClassInterface.java [new file with mode: 0644]
iotjava/iotrmi/Java/sample/TestClass_Stub.java

index 7522db0..4f53798 100644 (file)
@@ -37,8 +37,12 @@ rmi:
        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
-       $(G++) iotrmi/C++/IoTRMICall.cpp -o $(BIN_DIR)/iotrmi/C++/IoTRMICall.out --std=c++11
-       $(G++) iotrmi/C++/IoTRMIObject.cpp -o $(BIN_DIR)/iotrmi/C++/IoTRMIObject.out --std=c++11
+       #$(G++) iotrmi/C++/IoTRMICall.cpp -o $(BIN_DIR)/iotrmi/C++/IoTRMICall.out --std=c++11
+       #$(G++) iotrmi/C++/IoTRMIObject.cpp -o $(BIN_DIR)/iotrmi/C++/IoTRMIObject.out --std=c++11
+       mkdir -p $(BIN_DIR)/iotrmi/C++/sample
+       $(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
+       $(G++) iotrmi/C++/sample/TestClass_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Skeleton.out --std=c++11
 
 PHONY += run-rmiserver
 run-rmiserver:
index 8503cdf..eb767dd 100644 (file)
@@ -90,7 +90,7 @@ void* IoTRMICall::remoteCall(string methodSign, string retType, string paramCls[
                int retLen = 0;
                char* retObjBytes = NULL;
                retObjBytes = rmiClient->receiveBytes(retObjBytes, &retLen);
-               retObj = IoTRMIUtil::getParamObject(retObj, retType.c_str(), retObjBytes);
+               retObj = IoTRMIUtil::getParamObject(retObj, retType.c_str(), retObjBytes, retLen);
        }
        
        return retObj;
@@ -110,6 +110,11 @@ int IoTRMICall::methodLength(string paramCls[], void* paramObj[], int numParam)
                        if (paramCls[i].compare("string") == 0) {
                                // Get the length of the string through void* casting to string*
                                paramLen = (*(string*)paramObj[i]).length();
+                       } else if (paramCls[i].compare("string[]") == 0) {
+                               paramLen = IoTRMIUtil::getByteStringLength(*(vector<string>*) paramObj[i]);
+                       } else {
+                               string error = "IoTRMICall: Unrecognizable type: " + paramCls[i];
+                               throw error;
                        }
                        // Some space for param length, i.e. 32 bits for integer                
                        methodLen = methodLen + IoTRMIUtil::PARAM_LEN;
@@ -139,6 +144,11 @@ char* IoTRMICall::methodToBytes(string methodSign, string paramCls[],
                        if (paramCls[i].compare("string") == 0) {
                                // Get the length of the string through void* casting to string*
                                paramLen = (*(string*)paramObj[i]).length();
+                       } else if (paramCls[i].compare("string[]") == 0) {
+                               paramLen = IoTRMIUtil::getByteStringLength(*(vector<string>*) paramObj[i]);
+                       } else {
+                               string error = "IoTRMICall: Unrecognizable type: " + paramCls[i];
+                               throw error;
                        }
                        // Write the parameter length
                        char prmLenBytes[IoTRMIUtil::METHOD_ID_LEN];
index a6e4cb1..a512dd2 100644 (file)
@@ -92,6 +92,11 @@ void IoTRMIObject::sendReturnObj(void* retObj, string type) {
                if (type.compare("string") == 0) {
                        // Get the length of the string through void* casting to string*
                        retLen = (*(string*)retObj).length();
+               } else if (type.compare("string[]") == 0) {
+                       retLen = IoTRMIUtil::getByteStringLength(*(vector<string>*) retObj);
+               } else {
+                       string error = "IoTRMICall: Unrecognizable type: " + type;
+                       throw error;
                }
        }
        // Need object bytes variable
@@ -107,7 +112,6 @@ void IoTRMIObject::getMethodBytes() {
        // Get method in bytes and update method length
        methodBytes = rmiServer->receiveBytes(methodBytes, &methodLen);
        fflush(NULL);
-       IoTRMIUtil::printBytes(methodBytes, methodLen, false);
 }
 
 
@@ -120,7 +124,6 @@ string IoTRMIObject::getSignature() {
        // Get method object 
        int methodId = 0;
        IoTRMIUtil::byteArrayToInt(&methodId, methodIdBytes);
-       cout << "Method Id: " << methodId << endl;
        
        return mapHash2Sign.find(methodId)->second;
 }
@@ -138,7 +141,6 @@ void** IoTRMIObject::getMethodParams(string paramCls[], int numParam, void* para
        // Byte scanning position
        int pos = IoTRMIUtil::METHOD_ID_LEN;
        for (int i = 0; i < numParam; i++) {
-
                int paramLen = rmiUtil->getTypeSize(paramCls[i]);
                // Get the 32-bit field in the byte array to get the actual
                //              length (this is a param with indefinite length)
@@ -152,8 +154,7 @@ void** IoTRMIObject::getMethodParams(string paramCls[], int numParam, void* para
                char paramBytes[paramLen];
                memcpy(paramBytes, methodBytes + pos, paramLen);
                pos = pos + paramLen;
-               paramObj[i] = IoTRMIUtil::getParamObject(paramObj[i], paramCls[i].c_str(), paramBytes);
-
+               paramObj[i] = IoTRMIUtil::getParamObject(paramObj[i], paramCls[i].c_str(), paramBytes, paramLen);
        }
        // Delete methodBytes
        delete[] methodBytes;
index c083a37..50e43bb 100644 (file)
@@ -62,7 +62,7 @@ class IoTRMIUtil {
                static string*  byteArrayToString(string* result, char* bytes, int len);
 
                // Get parameter object from byte array
-               static void*    getParamObject(void* retObj, const char* type, char* paramBytes);
+               static void*    getParamObject(void* retObj, const char* type, char* paramBytes, int len);
                static char*    getObjectBytes(char* retObjBytes, void* obj, const char* type);
 
                // Arrays to bytes
@@ -87,7 +87,7 @@ class IoTRMIUtil {
 
                // Aggregator functions
                static char*    getArrayObjectBytes(char* retObjBytes, void* obj, const char* type);
-               static void*    getParamObject(void* retObj, const char* type, char* paramBytes, int len);
+               static void*    getArrayParamObject(void* retObj, const char* type, char* paramBytes, int len);
 
                // Constants
                const static int        METHOD_ID_LEN = 4;      // 4 bytes = 32 bits
@@ -204,7 +204,7 @@ int IoTRMIUtil::getByteStringLength(vector<string> arrString) {
 // ****************************
 
 // Getting parameter object based on received byte array
-void* IoTRMIUtil::getParamObject(void* retObj, const char* type, char* paramBytes) {
+void* IoTRMIUtil::getParamObject(void* retObj, const char* type, char* paramBytes, int len) {
 
        if (strcmp(type, "b") == 0 ||
                strcmp(type, "byte") == 0) {
@@ -232,7 +232,10 @@ void* IoTRMIUtil::getParamObject(void* retObj, const char* type, char* paramByte
                retObj = (void*) byteArrayToChar((char*) retObj, paramBytes);
        } else if ( strcmp(type, "Ss") == 0 ||
                                strcmp(type, "string") == 0) {
-               retObj = (void*) byteArrayToString((string*) retObj, paramBytes);
+               retObj = (void*) byteArrayToString((string*) retObj, paramBytes, len);
+       } else if ( string(type).find("[]") != string::npos) {
+               // This is an array type, i.e. vector
+               retObj = getArrayParamObject(retObj, type, paramBytes, len);
        } else {
                string error = "IoTRMIUtil: Unrecognizable type: " + string(type);
                throw error;
@@ -243,7 +246,7 @@ void* IoTRMIUtil::getParamObject(void* retObj, const char* type, char* paramByte
 
 
 // Get array of objects from byte array - overload getParamObject function
-void* IoTRMIUtil::getParamObject(void* retObj, const char* type, char* paramBytes, int len) {
+void* IoTRMIUtil::getArrayParamObject(void* retObj, const char* type, char* paramBytes, int len) {
 
        if (strcmp(type, "byte[]") == 0) {
                retObj = (vector<char>*) paramBytes;
diff --git a/iotjava/iotrmi/C++/TestClass.hpp b/iotjava/iotrmi/C++/TestClass.hpp
deleted file mode 100644 (file)
index 8d3a3c9..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-#include <iostream>
-
-using namespace std;
-
-class TestClass {
-       public:
-               TestClass();
-               TestClass(int _int, float _float, string _string);
-               ~TestClass();
-
-               void                            setA(int _int);
-               void                            setB(float _float);
-               void                            setC(string _string);
-               string                          sumArray(const string newA[]);
-               int                                     setAndGetA(int newA);
-               int                                     setACAndGetA(string newC, int newA);
-               //void                          registerCallback(CallBackInterface _cb);
-               //int                           callBack();
-
-       private:                
-               int                                     intA;
-               float                           floatB;
-               string                          stringC;
-               //CallBackInterface cb;
-
-};
-
-
-TestClass::TestClass() {
-
-       intA = 1;
-       floatB = 2;
-       stringC = "345";
-       //cb = NULL;
-}
-
-
-TestClass::TestClass(int _int, float _float, string _string) {
-
-       intA = _int;
-       floatB = _float;
-       stringC = _string;
-       //cb = NULL;
-}
-
-
-void TestClass::setA(int _int) {
-
-       intA = _int;
-}
-
-
-void TestClass::setB(float _float) {
-
-       floatB = _float;
-}
-
-
-void TestClass::setC(string _string) {
-
-       stringC = _string;
-}
-
-
-string TestClass::sumArray(const string newA[]) {
-
-       string sum = "";
-       int len = sizeof(newA) / sizeof(string);
-       for(int c = 0; c < len; c++) {
-               sum = sum + newA[c];
-       }
-       return sum;
-}
-
-
-int TestClass::setAndGetA(int newA) {
-
-       intA = newA;
-       return intA;
-}
-
-
-int TestClass::setACAndGetA(string newC, int newA) {
-
-       stringC = newC;
-       intA = newA;
-       return intA;
-}
-
-
-/*void TestClass::registerCallback(CallBackInterface _cb) {
-
-       cb = _cb;
-}
-
-
-int TestClass::callBack() {
-
-       return cb.printInt();
-}*/
-
diff --git a/iotjava/iotrmi/C++/sample/TestClass.cpp b/iotjava/iotrmi/C++/sample/TestClass.cpp
new file mode 100644 (file)
index 0000000..b70d237
--- /dev/null
@@ -0,0 +1,23 @@
+#include <iostream>
+#include <string>
+#include "TestClass.hpp"
+
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+
+       TestClassInterface *tc = new TestClass();
+       cout << "Return value: " << tc->setAndGetA(123) << endl;
+       cout << "Return value: " << tc->setACAndGetA("string", 123) << endl;
+       vector<string> input;
+       input.push_back("123");
+       input.push_back("456");
+       input.push_back("987");
+
+       cout << "Return value: " << tc->sumArray(input) << endl;
+
+       delete tc;
+
+       return 0;
+}
diff --git a/iotjava/iotrmi/C++/sample/TestClass.hpp b/iotjava/iotrmi/C++/sample/TestClass.hpp
new file mode 100644 (file)
index 0000000..975481a
--- /dev/null
@@ -0,0 +1,102 @@
+#include <iostream>
+#include "TestClassInterface.hpp"
+
+using namespace std;
+
+class TestClass : public TestClassInterface {
+       public:
+               TestClass();
+               TestClass(int _int, float _float, string _string);
+               //~TestClass();
+
+               void                            setA(int _int);
+               void                            setB(float _float);
+               void                            setC(string _string);
+               string                          sumArray(vector<string> newA);
+               int                                     setAndGetA(int newA);
+               int                                     setACAndGetA(string newC, int newA);
+               //void                          registerCallback(CallBackInterface _cb);
+               //int                           callBack();
+
+       private:                
+               int                                     intA;
+               float                           floatB;
+               string                          stringC;
+               //CallBackInterface cb;
+
+};
+
+
+TestClass::TestClass() {
+
+       intA = 1;
+       floatB = 2;
+       stringC = "345";
+       //cb = NULL;
+}
+
+
+TestClass::TestClass(int _int, float _float, string _string) {
+
+       intA = _int;
+       floatB = _float;
+       stringC = _string;
+       //cb = NULL;
+}
+
+
+void TestClass::setA(int _int) {
+
+       intA = _int;
+}
+
+
+void TestClass::setB(float _float) {
+
+       floatB = _float;
+}
+
+
+void TestClass::setC(string _string) {
+
+       stringC = _string;
+}
+
+
+string TestClass::sumArray(vector<string> newA) {
+
+       string sum = "";
+       int len = newA.size();
+       for(int c = 0; c < len; c++) {
+               sum = sum + newA[c];
+       }
+       return sum;
+}
+
+
+int TestClass::setAndGetA(int newA) {
+
+       intA = newA;
+       return intA;
+}
+
+
+int TestClass::setACAndGetA(string newC, int newA) {
+
+       stringC = newC;
+       intA = newA;
+       return intA;
+}
+
+
+/*void TestClass::registerCallback(CallBackInterface _cb) {
+
+       cb = _cb;
+}
+
+
+int TestClass::callBack() {
+
+       return cb.printInt();
+}*/
+
diff --git a/iotjava/iotrmi/C++/sample/TestClassInterface.hpp b/iotjava/iotrmi/C++/sample/TestClassInterface.hpp
new file mode 100644 (file)
index 0000000..0f05a93
--- /dev/null
@@ -0,0 +1,17 @@
+#include <iostream>
+#include <vector>
+
+using namespace std;
+
+class TestClassInterface {
+       public:
+               virtual void    setA(int _int) = 0;
+               virtual void    setB(float _float) = 0;
+               virtual void    setC(string _string) = 0;
+               virtual string  sumArray(vector<string> newA) = 0;
+               virtual int             setAndGetA(int newA) = 0;
+               virtual int             setACAndGetA(string newC, int newA) = 0;
+               //virtual void  registerCallback(CallBackInterface _cb);
+               //virtual int   callBack();
+};
+
diff --git a/iotjava/iotrmi/C++/sample/TestClass_Skeleton.cpp b/iotjava/iotrmi/C++/sample/TestClass_Skeleton.cpp
new file mode 100644 (file)
index 0000000..23079c8
--- /dev/null
@@ -0,0 +1,18 @@
+#include <iostream>
+#include <string>
+#include "TestClass_Skeleton.hpp"
+
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+
+       int port = 5010;
+       TestClassInterface *tc = new TestClass(3, 5.0, "7911");
+       TestClass_Skeleton *tcSkel = new TestClass_Skeleton(tc, port);
+       tcSkel->waitRequestInvokeMethod();
+
+       delete tc;
+       delete tcSkel;
+       return 0;
+}
diff --git a/iotjava/iotrmi/C++/sample/TestClass_Skeleton.hpp b/iotjava/iotrmi/C++/sample/TestClass_Skeleton.hpp
new file mode 100644 (file)
index 0000000..95afe9b
--- /dev/null
@@ -0,0 +1,131 @@
+#include <iostream>
+#include "../IoTRMIObject.hpp"
+#include "TestClass.hpp"
+
+using namespace std;
+
+class TestClass_Skeleton {
+       public:
+               TestClass_Skeleton(TestClassInterface* _tc, int _port);
+               ~TestClass_Skeleton();
+
+               void    waitRequestInvokeMethod();
+
+       private:                
+               TestClassInterface              *tc;
+               IoTRMIObject                    *rmiObj;
+               //CallBackInterface cbstub;
+
+               const static int size = 8;
+               string methodSignatures[size] = {
+
+                       "voidsetA(int)",
+                       "voidsetB(float)",
+                       "voidsetC(string)",
+                       "sumArray(string[])",
+                       "intsetAndGetA(int)",
+                       "intsetACAndGetA(string,int)",
+                       "intcallBack()",
+                       "voidregisterCallBack(CallBackInterface)"
+               };
+};
+
+
+TestClass_Skeleton::TestClass_Skeleton(TestClassInterface* _tc, int _port) {
+
+       bool _bResult = false;
+       tc = _tc;
+       rmiObj = new IoTRMIObject(_port, &_bResult, methodSignatures, size);
+}
+
+
+TestClass_Skeleton::~TestClass_Skeleton() {
+
+       if (rmiObj != NULL) {
+               delete rmiObj;
+               rmiObj = NULL;
+       }
+}
+
+
+void TestClass_Skeleton::waitRequestInvokeMethod() {
+
+       // Loop continuously waiting for incoming bytes
+       while (true) {
+
+               rmiObj->getMethodBytes();
+               string methodSign = rmiObj->getSignature();
+               cout << "Method sign: " << methodSign << endl;
+               
+               if (methodSign.compare("voidsetA(int)") == 0) {
+                       string paramCls[] = { "int" };
+                       int numParam = 1;
+                       int param1 = 0;
+                       void* paramObj[] = { &param1 };
+                       rmiObj->getMethodParams(paramCls, numParam, paramObj);
+                       tc->setA(param1);
+               } else if (methodSign.compare("voidsetB(float)") == 0) {
+                       string paramCls[] = { "float" };
+                       int numParam = 1;
+                       float param1 = 0.0;
+                       void* paramObj[] = { &param1 };
+                       rmiObj->getMethodParams(paramCls, numParam, paramObj);
+                       tc->setB(param1);
+               } else if (methodSign.compare("voidsetC(string)") == 0) {
+                       string paramCls[] = { "string" };
+                       int numParam = 1;
+                       string param1 = "";
+                       void* paramObj[] = { &param1 };
+                       rmiObj->getMethodParams(paramCls, numParam, paramObj);
+                       tc->setC(param1);
+               } else if (methodSign.compare("sumArray(string[])") == 0) {
+                       string paramCls[] = { "string[]" };
+                       int numParam = 1;
+                       vector<string> param1;
+                       void* paramObj[] = { &param1 };
+                       rmiObj->getMethodParams(paramCls, numParam, paramObj);
+                       string retVal = tc->sumArray(param1);
+                       void* retObj = &retVal;
+                       rmiObj->sendReturnObj(retObj, "string");
+               } else if (methodSign.compare("intsetAndGetA(int)") == 0) {
+                       string paramCls[] = { "int" };
+                       int numParam = 1;
+                       int param1 = 0;
+                       void* paramObj[] = { &param1 };
+                       rmiObj->getMethodParams(paramCls, numParam, paramObj);
+                       int retVal = tc->setAndGetA(param1);
+                       void* retObj = &retVal;
+                       rmiObj->sendReturnObj(retObj, "int");
+               } else if (methodSign.compare("intsetACAndGetA(string,int)") == 0) {
+                       string paramCls[] = { "string", "int" };
+                       int numParam = 2;
+                       string param1 = "";
+                       int param2 = 0;
+                       void* paramObj[] = { &param1, &param2 };
+                       rmiObj->getMethodParams(paramCls, numParam, paramObj);
+                       int retVal = tc->setACAndGetA(param1, param2);
+                       void* retObj = &retVal;
+                       rmiObj->sendReturnObj(retObj, "int");
+               /*} else if (methodSign.compare("voidregisterCallBack(CallBackInterface)") == 0) {
+                       //
+               } else if (methodSign.compare("intcallBack()") == 0) {
+                       //*/
+               } else {
+                       string error = "Signature unreqcognized: " + string(methodSign);
+                       throw error;
+               }
+       }
+}
+
+
+/*void TestClass_Stub::registerCallback(CallBackInterface _cb) {
+
+       cb = _cb;
+}
+
+
+int TestClass_Stub::callBack() {
+
+       return cb.printInt();
+}*/
+
diff --git a/iotjava/iotrmi/C++/sample/TestClass_Stub.cpp b/iotjava/iotrmi/C++/sample/TestClass_Stub.cpp
new file mode 100644 (file)
index 0000000..77cea16
--- /dev/null
@@ -0,0 +1,28 @@
+#include <iostream>
+#include <string>
+#include "TestClass_Stub.hpp"
+
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+
+       int port = 5010;
+       const char* address = "localhost";
+       int rev = 0;
+       bool bResult = false;
+
+       TestClassInterface *tcStub = new TestClass_Stub(port, address, rev, &bResult);
+       cout << "Return value: " << tcStub->setAndGetA(123) << endl;
+       cout << "Return value: " << tcStub->setACAndGetA("string", 123) << endl;
+       vector<string> input;
+       input.push_back("123");
+       input.push_back("456");
+       input.push_back("987");
+
+       cout << "Return value: " << tcStub->sumArray(input) << endl;
+
+       delete tcStub;
+
+       return 0;
+}
diff --git a/iotjava/iotrmi/C++/sample/TestClass_Stub.hpp b/iotjava/iotrmi/C++/sample/TestClass_Stub.hpp
new file mode 100644 (file)
index 0000000..057643d
--- /dev/null
@@ -0,0 +1,144 @@
+#include <iostream>
+#include "../IoTRMICall.hpp"
+#include "TestClassInterface.hpp"
+
+using namespace std;
+
+class TestClass_Stub : public TestClassInterface {
+       public:
+               TestClass_Stub();
+               TestClass_Stub(int _port, const char* _address, int _rev, bool* _bResult);
+               ~TestClass_Stub();
+
+               void                            setA(int _int);
+               void                            setB(float _float);
+               void                            setC(string _string);
+               string                          sumArray(vector<string> newA);
+               int                                     setAndGetA(int newA);
+               int                                     setACAndGetA(string newC, int newA);
+               //void                          registerCallback(CallBackInterface _cb);
+               //int                           callBack();
+
+       private:                
+               int                                     intA;
+               float                           floatB;
+               string                          stringC;
+               //CallBackInterface cb;
+               IoTRMICall                      *rmiCall;
+               string                          address;
+               //vector<int>                   ports;
+};
+
+
+TestClass_Stub::TestClass_Stub() {
+
+       address = "";
+       rmiCall = NULL;
+}
+
+
+TestClass_Stub::TestClass_Stub(int _port, const char* _address, int _rev, bool* _bResult) {
+
+       address = _address;
+       rmiCall = new IoTRMICall(_port, _address, _rev, _bResult);
+}
+
+
+TestClass_Stub::~TestClass_Stub() {
+
+       if (rmiCall != NULL) {
+               delete rmiCall;
+               rmiCall = NULL;
+       }
+}
+
+
+void TestClass_Stub::setA(int _int) {
+
+       int numParam = 1;
+       string sign = "voidsetA(int)";
+       string retType = "void";
+       string paramCls[] = { "int" };
+       void* paramObj[] = { &_int };
+       void* retObj = NULL;
+       rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
+}
+
+
+void TestClass_Stub::setB(float _float) {
+
+       int numParam = 1;
+       string sign = "voidsetB(float)";
+       string retType = "void";
+       string paramCls[] = { "float" };
+       void* paramObj[] = { &_float };
+       void* retObj = NULL;
+       rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
+}
+
+
+void TestClass_Stub::setC(string _string) {
+
+       int numParam = 1;
+       string sign = "voidsetC(string)";
+       string retType = "void";
+       string paramCls[] = { "string" };
+       void* paramObj[] = { &_string };
+       void* retObj = NULL;
+       rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
+}
+
+
+string TestClass_Stub::sumArray(vector<string> newA) {
+
+       int numParam = 1;
+       string sign = "sumArray(string[])";
+       string retType = "string";
+       string paramCls[] = { "string[]" };
+       void* paramObj[] = { &newA };
+       string retVal = "";
+       void* retObj = &retVal;
+       rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
+       return retVal;
+}
+
+
+int TestClass_Stub::setAndGetA(int newA) {
+
+       int numParam = 1;
+       string sign = "intsetAndGetA(int)";
+       string retType = "int";
+       string paramCls[] = { "int" };
+       void* paramObj[] = { &newA };
+       int retVal = 0;
+       void* retObj = &retVal;
+       rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
+       return retVal;
+}
+
+
+int TestClass_Stub::setACAndGetA(string newC, int newA) {
+
+       int numParam = 2;
+       string sign = "intsetACAndGetA(string,int)";
+       string retType = "int";
+       string paramCls[] = { "string", "int" };
+       void* paramObj[] = { &newC, &newA };
+       int retVal = 0;
+       void* retObj = &retVal;
+       rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
+       return retVal;
+}
+
+
+/*void TestClass_Stub::registerCallback(CallBackInterface _cb) {
+
+       cb = _cb;
+}
+
+
+int TestClass_Stub::callBack() {
+
+       return cb.printInt();
+}*/
+
index 1d519dd..dc6f73e 100644 (file)
@@ -2,7 +2,7 @@ package iotrmi.Java.sample;
 
 import java.util.Set;
 
-public class TestClass {
+public class TestClass implements TestClassInterface {
 
        /**
         * Class Properties
diff --git a/iotjava/iotrmi/Java/sample/TestClassInterface.java b/iotjava/iotrmi/Java/sample/TestClassInterface.java
new file mode 100644 (file)
index 0000000..d41166d
--- /dev/null
@@ -0,0 +1,15 @@
+package iotrmi.Java.sample;
+
+import java.util.Set;
+
+public interface TestClassInterface {
+
+       public void setA(int _int);
+       public void setB(float _float);
+       public void setC(String _string);
+       public String sumArray(String[] newA);
+       public int setAndGetA(int newA);
+       public int setACAndGetA(String newC, int newA);
+       public void registerCallback(CallBackInterface _cb);
+       public int callBack();
+}
index a57f036..39411a7 100644 (file)
@@ -6,7 +6,7 @@ import iotruntime.master.CommunicationHandler;
 
 import java.util.Arrays;
 
-public class TestClass_Stub {
+public class TestClass_Stub implements TestClassInterface {
 
        /**
         * Class Properties
@@ -40,7 +40,7 @@ public class TestClass_Stub {
        }
 
 
-       private void registerCallback(CallBackInterface _cb) {
+       public void registerCallback(CallBackInterface _cb) {
 
                //int port = 5011;      // Send this info to the other end to start the stub
                //String address = "localhost";