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
#$(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
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;
}
*/
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) {
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;
/**
* 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;
/**
* 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();
// Receive method info
methodBytes = rmiServer.receiveBytes(methodBytes);
+ System.out.println("Method: " + Arrays.toString(methodBytes));
return methodBytes;
}
/**
- * 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];
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;
}
}
- public int ___printInt() {
- return printInt();
+ public void ___printInt(IoTRMIObject rmiObj) throws IOException {
+ Object retObj = printInt();
+ rmiObj.sendReturnObj(retObj);
}
}
- 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!");
+ }
}
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);
}
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);
}
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);
}
}
}
*/
public CallBack_Stub(int _port, String _address, int _rev) throws IOException {
- rmiCall = new IoTRMICall(_port, _address, _rev, methodSignatures);
+ rmiCall = new IoTRMICall(_port, _address, _rev);
}
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);
}
}
}
};
- thread2.start();*/
+ thread2.start();
- //return 1;
+ return 1;*/
return sum;
}
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;
tc = _tc;
port = _port;
- rmiObj = new IoTRMIObject(_port, methodSignatures);
+ rmiObj = new IoTRMIObject(_port);
___waitRequestInvokeMethod();
}
}
- 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);
}
}
- 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);
}
}
- 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);
}
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");
}
}
- public int ___callBack() {
+ public void ___callBack() throws IOException {
- return callBack();
+ Object retObj = callBack();
+ rmiObj.sendReturnObj(retObj);
}
Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
new Class<?>[] { null }, new Class<?>[] { null });
- return (int) paramObj[0];
+ return (int) paramObj[0];
}
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);
}
}
}
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
};
/**
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();
}
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){
};
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]);
// 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);*/
}
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;
}
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];
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);
}
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 };
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++) {