- * registerStub() registers the skeleton to be woken up
- */
- public synchronized void registerStub(int objectId, int methodId, AtomicBoolean retValueReceived) {
-
- String strKey = objectId + "-" + methodId;
- System.out.println("Key exist? " + mapStubId.containsKey(strKey));
- mapStubId.put(strKey, retValueReceived);
- System.out.println("\n\nAdding keyBytes: " + strKey + " now size: " + mapStubId.size() + "\n\n");
- }
-
-
- /**
- * getObjectIdCounter() gets object Id counter
- */
- public int getObjectIdCounter() {
-
- return objectIdCounter;
- }
-
-
- /**
- * setObjectIdCounter() sets object Id counter
- */
- public void setObjectIdCounter(int objIdCounter) {
-
- objectIdCounter = objIdCounter;
- }
-
-
- /**
- * decrementObjectIdCounter() gets object Id counter
- */
- public void decrementObjectIdCounter() {
-
- objectIdCounter--;
- }
-
-
-
- /**
- * setGetReturnBytes() set boolean if there is a new return value already
- */
- public synchronized boolean setGetReturnBytes() {
-
- return didGetReturnBytes.compareAndSet(false, true);
- }
-
-
- /**
- * getObjectAndMethodIdBytes() extracts object Id and method Id from method bytes
- */
- public byte[] getObjectAndMethodIdBytes() {
-
- int objMethIdLen = IoTRMIUtil.OBJECT_ID_LEN + IoTRMIUtil.METHOD_ID_LEN;
- byte[] objectMethodIdBytes = new byte[objMethIdLen];
- System.arraycopy(retValueBytes, 0, objectMethodIdBytes, 0, objMethIdLen);
- return objectMethodIdBytes;
- }
-
-
- /**
- * getObjectAndMethodIdBytes() gets object and method Id in bytes
- */
- public byte[] getObjectAndMethodIdBytes(int objectId, int methodId) {
-
- int objMethIdLen = IoTRMIUtil.OBJECT_ID_LEN + IoTRMIUtil.METHOD_ID_LEN;
- byte[] objectMethodIdBytes = new byte[objMethIdLen];
- byte[] objIdBytes = IoTRMIUtil.intToByteArray(objectId);
- byte[] methIdBytes = IoTRMIUtil.intToByteArray(methodId);
- System.arraycopy(objIdBytes, 0, objectMethodIdBytes, 0, IoTRMIUtil.OBJECT_ID_LEN);
- System.arraycopy(methIdBytes, 0, objectMethodIdBytes, IoTRMIUtil.OBJECT_ID_LEN, IoTRMIUtil.METHOD_ID_LEN);
- return objectMethodIdBytes;
- }
-
-
- /**
- * getObjectId() gets object Id from bytes
- */
- public int getObjectId() {
-
- // Get object Id bytes
- byte[] objectIdBytes = new byte[IoTRMIUtil.OBJECT_ID_LEN];
- System.arraycopy(retValueBytes, 0, objectIdBytes, 0, IoTRMIUtil.OBJECT_ID_LEN);
- // Get object Id
- int objectId = IoTRMIUtil.byteArrayToInt(objectIdBytes);
- return objectId;
- }
-
-
- /**
- * getMethodId() gets method Id from bytes
- */
- public int getMethodId() {
-
- // Get method Id bytes
- byte[] methodIdBytes = new byte[IoTRMIUtil.METHOD_ID_LEN];
- // Method Id is positioned after object Id in the byte array
- System.arraycopy(retValueBytes, IoTRMIUtil.OBJECT_ID_LEN, methodIdBytes, 0, IoTRMIUtil.METHOD_ID_LEN);
- // Get method Id
- int methodId = IoTRMIUtil.byteArrayToInt(methodIdBytes);
- // Get method Id
- return methodId;
- }
-
-
- /**
- * remoteCall() calls a method remotely by passing in parameters and getting a return Object (DEPRECATED)