import java.io.IOException;
import java.util.Arrays;
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
+
+import java.util.List;
import iotrmi.Java.IoTRMIObject;
import iotrmi.Java.IoTRMICall;
/**
* Class Constants
*/
- private int objectId = 0; // Default value is 0
- private static int objIdCnt = 0; // Counter for callback object Ids
private TestClassInterface tc;
private int port;
private IoTRMIObject rmiObj;
+
+ // Callback stuff
+ private static int objIdCnt = 0; // Counter for callback object Ids
private IoTRMICall rmiCall;
private CallBackInterface cbstub;
+ // Object permission
+ private int object0Id = 0;
+ private static Integer[] object0Permission = { 0, 1, 2, 3, 4, 5 };
+ private List<Integer> set0Allowed;
+
/**
* Constructors
tc = _tc;
port = _port;
rmiObj = new IoTRMIObject(_port);
+ set0Allowed = Arrays.asList(object0Permission);
___waitRequestInvokeMethod();
}
rmiObj.getMethodBytes();
int _objectId = rmiObj.getObjectId();
- if (_objectId == objectId) {
+ int methodId = rmiObj.getMethodId();
+ if (_objectId == object0Id) {
// Multiplex based on object Id
- int methodId = rmiObj.getMethodId();
- switch (methodId) {
-
- 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;
- case 12: ___handleEnum(); break;
- default:
- throw new Error("Method Id not recognized!");
- }
+ // Complain if the method is not allowed
+ if (!set0Allowed.contains(methodId))
+ throw new Error("TestClass_Skeleton: This object is not allowed to access method " + methodId);
+ // If we have more than 1 object Id...
+ //else if (_objectId == object1Id) {
+
+ } else
+ throw new Error("TestClass_Skeleton: Unrecognizable object Id: " + _objectId);
+
+ switch (methodId) {
+
+ 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;
+ case 12: ___handleEnum(); break;
+ default:
+ throw new Error("Method Id " + methodId + " not recognized!");
}
+
}
}