Updating stubs and skeletons for the second benchmark and drivers; tested the second...
authorrtrimana <rtrimana@uci.edu>
Thu, 23 Feb 2017 20:58:44 +0000 (12:58 -0800)
committerrtrimana <rtrimana@uci.edu>
Thu, 23 Feb 2017 20:58:44 +0000 (12:58 -0800)
40 files changed:
benchmarks/Java/IrrigationController/CameraCallback_CallbackSkeleton.java [deleted file]
benchmarks/Java/IrrigationController/CameraCallback_Skeleton.java [new file with mode: 0644]
benchmarks/Java/IrrigationController/CameraSmart_Stub.java
benchmarks/Java/IrrigationController/LawnSmart_Stub.java
benchmarks/Java/IrrigationController/MoistureSensorCallback_CallbackSkeleton.java [deleted file]
benchmarks/Java/IrrigationController/MoistureSensorCallback_Skeleton.java [new file with mode: 0644]
benchmarks/Java/IrrigationController/MoistureSensorSmart_Stub.java
benchmarks/Java/IrrigationController/SprinklerSmart_Stub.java
benchmarks/Java/IrrigationController/WeatherGatewayCallback_CallbackSkeleton.java [deleted file]
benchmarks/Java/IrrigationController/WeatherGatewayCallback_Skeleton.java [new file with mode: 0644]
benchmarks/Java/IrrigationController/WeatherGatewaySmart_Stub.java
benchmarks/Java/SpeakerController/GPSGatewayCallback_CallbackSkeleton.java [deleted file]
benchmarks/Java/SpeakerController/SpeakerCallback_CallbackSkeleton.java [deleted file]
benchmarks/drivers/Java/AudioRoom/Room_Skeleton.java
benchmarks/drivers/Java/EspSprinkler/Sprinkler_Skeleton.java
benchmarks/drivers/Java/GPSPhoneGateway/GPSGatewaySmartCallback_CallbackStub.java [deleted file]
benchmarks/drivers/Java/GPSPhoneGateway/GPSGatewaySmartCallback_Stub.java [new file with mode: 0644]
benchmarks/drivers/Java/GPSPhoneGateway/GPSGateway_Skeleton.java
benchmarks/drivers/Java/GreenLawn/Lawn_Skeleton.java
benchmarks/drivers/Java/HomeRoom/Room_Skeleton.java
benchmarks/drivers/Java/IHome/SpeakerSmartCallback_CallbackStub.java [deleted file]
benchmarks/drivers/Java/IHome/SpeakerSmartCallback_Stub.java [new file with mode: 0644]
benchmarks/drivers/Java/IHome/Speaker_Skeleton.java
benchmarks/drivers/Java/MotionSensor/SmartthingsSensorSmartCallback_CallbackStub.java [deleted file]
benchmarks/drivers/Java/MotionSensor/SmartthingsSensorSmartCallback_Stub.java [new file with mode: 0644]
benchmarks/drivers/Java/MotionSensor/SmartthingsSensor_Skeleton.java
benchmarks/drivers/Java/MultipurposeSensor/SmartthingsSensorSmartCallback_CallbackStub.java [deleted file]
benchmarks/drivers/Java/MultipurposeSensor/SmartthingsSensorSmartCallback_Stub.java [new file with mode: 0644]
benchmarks/drivers/Java/MultipurposeSensor/SmartthingsSensor_Skeleton.java
benchmarks/drivers/Java/SpruceSensor/MoistureSensorSmartCallback_CallbackStub.java [deleted file]
benchmarks/drivers/Java/SpruceSensor/MoistureSensorSmartCallback_Stub.java [new file with mode: 0644]
benchmarks/drivers/Java/SpruceSensor/MoistureSensor_Skeleton.java
benchmarks/drivers/Java/WaterLeakSensor/SmartthingsSensorSmartCallback_CallbackStub.java [deleted file]
benchmarks/drivers/Java/WaterLeakSensor/SmartthingsSensorSmartCallback_Stub.java [new file with mode: 0644]
benchmarks/drivers/Java/WaterLeakSensor/SmartthingsSensor_Skeleton.java
benchmarks/drivers/Java/WeatherPhoneGateway/WeatherGatewaySmartCallback_CallbackStub.java [deleted file]
benchmarks/drivers/Java/WeatherPhoneGateway/WeatherGatewaySmartCallback_Stub.java [new file with mode: 0644]
benchmarks/drivers/Java/WeatherPhoneGateway/WeatherGateway_Skeleton.java
iotjava/Makefile
localconfig/iotruntime/IoTMaster.config

diff --git a/benchmarks/Java/IrrigationController/CameraCallback_CallbackSkeleton.java b/benchmarks/Java/IrrigationController/CameraCallback_CallbackSkeleton.java
deleted file mode 100644 (file)
index afe1048..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package IrrigationController;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class CameraCallback_CallbackSkeleton implements CameraCallback {
-
-       private CameraCallback mainObj;
-       private int objectId = 0;
-       private String callbackAddress;
-       
-
-       public CameraCallback_CallbackSkeleton(CameraCallback _mainObj, String _callbackAddress, int _objectId) throws Exception {
-               callbackAddress = _callbackAddress;
-               mainObj = _mainObj;
-               objectId = _objectId;
-       }
-
-       public void newCameraFrameAvailable(byte latestFrame[], long timeStamp) {
-               mainObj.newCameraFrameAvailable(latestFrame, timeStamp);
-       }
-
-       public void ___newCameraFrameAvailable(IoTRMIObject rmiObj) {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { byte[].class, long.class }, 
-               new Class<?>[] { null, null });
-               newCameraFrameAvailable((byte[]) paramObj[0], (long) paramObj[1]);
-       }
-
-       public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
-               int methodId = rmiObj.getMethodId();
-               switch (methodId) {
-                       case 0: ___newCameraFrameAvailable(rmiObj); break;
-                       default: 
-                       throw new Error("Method Id " + methodId + " not recognized!");
-               }
-       }
-
-}
diff --git a/benchmarks/Java/IrrigationController/CameraCallback_Skeleton.java b/benchmarks/Java/IrrigationController/CameraCallback_Skeleton.java
new file mode 100644 (file)
index 0000000..a155f20
--- /dev/null
@@ -0,0 +1,116 @@
+package IrrigationController;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class CameraCallback_Skeleton implements CameraCallback {
+
+       private CameraCallback mainObj;
+       private int objectId = 3;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object3Permission = { 0 };
+       private static List<Integer> set3Allowed;
+       
+
+       public CameraCallback_Skeleton(CameraCallback _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set3Allowed = new ArrayList<Integer>(Arrays.asList(object3Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public CameraCallback_Skeleton(CameraCallback _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set3Allowed = new ArrayList<Integer>(Arrays.asList(object3Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
+       }
+
+       public void newCameraFrameAvailable(byte latestFrame[], long timeStamp) {
+               mainObj.newCameraFrameAvailable(latestFrame, timeStamp);
+       }
+
+       public void ___newCameraFrameAvailable() {
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { byte[].class, long.class }, new Class<?>[] { null, null }, localMethodBytes);
+               newCameraFrameAvailable((byte[]) paramObj[0], (long) paramObj[1]);
+       }
+
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
+               while (true) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set3Allowed.contains(methodId)) {
+                                       throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
+                               }
+                       }
+                       else {
+                               continue;
+                       }
+                       switch (methodId) {
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___newCameraFrameAvailable();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               default: 
+                               throw new Error("Method Id " + methodId + " not recognized!");
+                       }
+               }
+       }
+
+}
index 7c1783b..c995eb6 100644 (file)
@@ -4,35 +4,57 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class CameraSmart_Stub implements CameraSmart {
 
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private final static int objectId = 0;
-       // Callback properties
-       private IoTRMIObject rmiObj;
-       List<CameraCallback> listCallbackObj;
-       private static int objIdCnt = 0;
-       private final static int object0Id = 0; //CameraSmartCallback
-       private static Integer[] object0Permission = { 0 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 2;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       private AtomicBoolean retValueReceived8 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived7 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived9 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived6 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived4 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived3 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived5 = new AtomicBoolean(false);
        
 
-       public CameraSmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               ports = _ports;
-               rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               listCallbackObj = new ArrayList<CameraCallback>();
-               set0Allowed.add(-9999);
-               ___initCallBack();
+       public CameraSmart_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               rmiComm.registerStub(objectId, 8, retValueReceived8);
+               rmiComm.registerStub(objectId, 7, retValueReceived7);
+               rmiComm.registerStub(objectId, 9, retValueReceived9);
+               rmiComm.registerStub(objectId, 6, retValueReceived6);
+               rmiComm.registerStub(objectId, 4, retValueReceived4);
+               rmiComm.registerStub(objectId, 3, retValueReceived3);
+               rmiComm.registerStub(objectId, 5, retValueReceived5);
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public CameraSmart_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               rmiComm.registerStub(objectId, 8, retValueReceived8);
+               rmiComm.registerStub(objectId, 7, retValueReceived7);
+               rmiComm.registerStub(objectId, 9, retValueReceived9);
+               rmiComm.registerStub(objectId, 6, retValueReceived6);
+               rmiComm.registerStub(objectId, 4, retValueReceived4);
+               rmiComm.registerStub(objectId, 3, retValueReceived3);
+               rmiComm.registerStub(objectId, 5, retValueReceived5);
        }
 
        public int getMaxFPS() {
@@ -40,7 +62,13 @@ public class CameraSmart_Stub implements CameraSmart {
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived8.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived8.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (int)retObj;
        }
 
@@ -49,7 +77,13 @@ public class CameraSmart_Stub implements CameraSmart {
                Class<?> retType = boolean.class;
                Class<?>[] paramCls = new Class<?>[] { int.class };
                Object[] paramObj = new Object[] { _fps };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived7.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived7.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (boolean)retObj;
        }
 
@@ -58,7 +92,13 @@ public class CameraSmart_Stub implements CameraSmart {
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived9.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived9.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (int)retObj;
        }
 
@@ -69,7 +109,13 @@ public class CameraSmart_Stub implements CameraSmart {
                paramEnum0[0] = _res.ordinal();
                Class<?>[] paramCls = new Class<?>[] { int[].class };
                Object[] paramObj = new Object[] { paramEnum0 };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived6.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived6.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (boolean)retObj;
        }
 
@@ -78,7 +124,7 @@ public class CameraSmart_Stub implements CameraSmart {
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public void start() {
@@ -86,7 +132,7 @@ public class CameraSmart_Stub implements CameraSmart {
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public long getTimestamp() {
@@ -94,7 +140,13 @@ public class CameraSmart_Stub implements CameraSmart {
                Class<?> retType = long.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived4.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived4.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (long)retObj;
        }
 
@@ -103,7 +155,13 @@ public class CameraSmart_Stub implements CameraSmart {
                Class<?> retType = byte[].class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived3.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived3.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (byte[])retObj;
        }
 
@@ -112,13 +170,37 @@ public class CameraSmart_Stub implements CameraSmart {
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public void registerCallback(CameraCallback _callbackTo) {
+               int[] objIdSent0 = new int[1];
                try {
-                       CameraCallback_CallbackSkeleton skel0 = new CameraCallback_CallbackSkeleton(_callbackTo, callbackAddress, objIdCnt++);
-                       listCallbackObj.add(skel0);
+                       if (!IoTRMIUtil.mapSkel.containsKey(_callbackTo)) {
+                               int newObjIdSent = rmiComm.getObjectIdCounter();
+                               objIdSent0[0] = newObjIdSent;
+                               rmiComm.decrementObjectIdCounter();
+                               CameraCallback_Skeleton skel0 = new CameraCallback_Skeleton(_callbackTo, rmiComm, newObjIdSent);
+                               IoTRMIUtil.mapSkel.put(_callbackTo, skel0);
+                               IoTRMIUtil.mapSkelId.put(_callbackTo, newObjIdSent);
+                               Thread thread = new Thread() {
+                                       public void run() {
+                                               try {
+                                                       skel0.___waitRequestInvokeMethod();
+                                                       } catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                                       throw new Error("Exception when trying to run ___waitRequestInvokeMethod() for CameraCallback_Skeleton!");
+                                               }
+                                       }
+                               };
+                               thread.start();
+                               while(!skel0.didAlreadyInitWaitInvoke());
+                       }
+                       else
+                       {
+                               int newObjIdSent = IoTRMIUtil.mapSkelId.get(_callbackTo);
+                               objIdSent0[0] = newObjIdSent;
+                       }
                } catch (Exception ex) {
                        ex.printStackTrace();
                        throw new Error("Exception when generating skeleton objects!");
@@ -126,43 +208,9 @@ public class CameraSmart_Stub implements CameraSmart {
 
                int methodId = 10;
                Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int.class };
-               Object[] paramObj = new Object[] { new Integer(1) };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-       public void ___initCallBack() {
-               Thread thread = new Thread() {
-                       public void run() {
-                               try {
-                                       rmiObj = new IoTRMIObject(ports[0]);
-                                       while (true) {
-                                               byte[] method = rmiObj.getMethodBytes();
-                                               int objId = IoTRMIObject.getObjectId(method);
-                                               CameraCallback_CallbackSkeleton skel = (CameraCallback_CallbackSkeleton) listCallbackObj.get(objId);
-                                               if (skel != null) {
-                                                       int methodId = IoTRMIObject.getMethodId(method);
-                                                       if (!set0Allowed.contains(methodId)) {
-                                                               throw new Error("Callback object for CameraCallback is not allowed to access method: " + methodId);
-                                                       }
-                                                       skel.invokeMethod(rmiObj);
-                                               } else {
-                                                       throw new Error("CameraCallback: Object with Id " + objId + " not found!");
-                                               }
-                                       }
-                               } catch (Exception ex) {
-                                       ex.printStackTrace();
-                                       throw new Error("Error instantiating class CameraCallback_CallbackSkeleton!");
-                               }
-                       }
-               };
-               thread.start();
-
-               int methodId = -9998;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int[].class, String.class, int.class };
-               Object[] paramObj = new Object[] { ports, callbackAddress, 0 };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               Class<?>[] paramCls = new Class<?>[] { int[].class };
+               Object[] paramObj = new Object[] { objIdSent0 };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public List<Resolution> getSupportedResolutions() {
@@ -170,7 +218,13 @@ public class CameraSmart_Stub implements CameraSmart {
                Class<?> retType = int[].class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived5.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived5.set(false);
+               rmiComm.setGetReturnBytes();
+
                int[] retEnum = (int[]) retObj;
                Resolution[] enumVals = Resolution.values();
                int retLen = retEnum.length;
index 3e2043b..59d4501 100644 (file)
@@ -4,24 +4,36 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class LawnSmart_Stub implements LawnSmart {
 
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private final static int objectId = 0;
+       private int objectId = 1;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
        
 
-       public LawnSmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               ports = _ports;
-               rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
+       public LawnSmart_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public LawnSmart_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
        }
 
 }
diff --git a/benchmarks/Java/IrrigationController/MoistureSensorCallback_CallbackSkeleton.java b/benchmarks/Java/IrrigationController/MoistureSensorCallback_CallbackSkeleton.java
deleted file mode 100644 (file)
index a82ae71..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package IrrigationController;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class MoistureSensorCallback_CallbackSkeleton implements MoistureSensorCallback {
-
-       private MoistureSensorCallback mainObj;
-       private int objectId = 0;
-       private String callbackAddress;
-       
-
-       public MoistureSensorCallback_CallbackSkeleton(MoistureSensorCallback _mainObj, String _callbackAddress, int _objectId) throws Exception {
-               callbackAddress = _callbackAddress;
-               mainObj = _mainObj;
-               objectId = _objectId;
-       }
-
-       public void newReadingAvailable(int sensorId, float moisture, long timeStampOfLastReading) {
-               mainObj.newReadingAvailable(sensorId, moisture, timeStampOfLastReading);
-       }
-
-       public void ___newReadingAvailable(IoTRMIObject rmiObj) {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class, float.class, long.class }, 
-               new Class<?>[] { null, null, null });
-               newReadingAvailable((int) paramObj[0], (float) paramObj[1], (long) paramObj[2]);
-       }
-
-       public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
-               int methodId = rmiObj.getMethodId();
-               switch (methodId) {
-                       case 0: ___newReadingAvailable(rmiObj); break;
-                       default: 
-                       throw new Error("Method Id " + methodId + " not recognized!");
-               }
-       }
-
-}
diff --git a/benchmarks/Java/IrrigationController/MoistureSensorCallback_Skeleton.java b/benchmarks/Java/IrrigationController/MoistureSensorCallback_Skeleton.java
new file mode 100644 (file)
index 0000000..c8e29d6
--- /dev/null
@@ -0,0 +1,116 @@
+package IrrigationController;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class MoistureSensorCallback_Skeleton implements MoistureSensorCallback {
+
+       private MoistureSensorCallback mainObj;
+       private int objectId = 6;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object6Permission = { 0 };
+       private static List<Integer> set6Allowed;
+       
+
+       public MoistureSensorCallback_Skeleton(MoistureSensorCallback _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set6Allowed = new ArrayList<Integer>(Arrays.asList(object6Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public MoistureSensorCallback_Skeleton(MoistureSensorCallback _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set6Allowed = new ArrayList<Integer>(Arrays.asList(object6Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
+       }
+
+       public void newReadingAvailable(int sensorId, float moisture, long timeStampOfLastReading) {
+               mainObj.newReadingAvailable(sensorId, moisture, timeStampOfLastReading);
+       }
+
+       public void ___newReadingAvailable() {
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int.class, float.class, long.class }, new Class<?>[] { null, null, null }, localMethodBytes);
+               newReadingAvailable((int) paramObj[0], (float) paramObj[1], (long) paramObj[2]);
+       }
+
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
+               while (true) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set6Allowed.contains(methodId)) {
+                                       throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
+                               }
+                       }
+                       else {
+                               continue;
+                       }
+                       switch (methodId) {
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___newReadingAvailable();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               default: 
+                               throw new Error("Method Id " + methodId + " not recognized!");
+                       }
+               }
+       }
+
+}
index 438563b..dd80718 100644 (file)
@@ -4,35 +4,45 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class MoistureSensorSmart_Stub implements MoistureSensorSmart {
 
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private final static int objectId = 0;
-       // Callback properties
-       private IoTRMIObject rmiObj;
-       List<MoistureSensorCallback> listCallbackObj;
-       private int objIdCnt = 0;
-       private final static int object0Id = 0; //MoistureSensorSmartCallback
-       private static Integer[] object0Permission = { 0 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 5;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       private AtomicBoolean retValueReceived2 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived4 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived1 = new AtomicBoolean(false);
        
 
-       public MoistureSensorSmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               ports = _ports;
-               rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               listCallbackObj = new ArrayList<MoistureSensorCallback>();
-               set0Allowed.add(-9999);
-               ___initCallBack();
+       public MoistureSensorSmart_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               rmiComm.registerStub(objectId, 2, retValueReceived2);
+               rmiComm.registerStub(objectId, 4, retValueReceived4);
+               rmiComm.registerStub(objectId, 1, retValueReceived1);
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public MoistureSensorSmart_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               rmiComm.registerStub(objectId, 2, retValueReceived2);
+               rmiComm.registerStub(objectId, 4, retValueReceived4);
+               rmiComm.registerStub(objectId, 1, retValueReceived1);
        }
 
        public long getTimestampOfLastReading() {
@@ -40,7 +50,13 @@ public class MoistureSensorSmart_Stub implements MoistureSensorSmart {
                Class<?> retType = long.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived2.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived2.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (long)retObj;
        }
 
@@ -49,14 +65,44 @@ public class MoistureSensorSmart_Stub implements MoistureSensorSmart {
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived4.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived4.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (int)retObj;
        }
 
        public void registerCallback(MoistureSensorCallback _callbackTo) {
+               int[] objIdSent0 = new int[1];
                try {
-                       MoistureSensorCallback_CallbackSkeleton skel0 = new MoistureSensorCallback_CallbackSkeleton(_callbackTo, callbackAddress, objIdCnt++);
-                       listCallbackObj.add(skel0);
+                       if (!IoTRMIUtil.mapSkel.containsKey(_callbackTo)) {
+                               int newObjIdSent = rmiComm.getObjectIdCounter();
+                               objIdSent0[0] = newObjIdSent;
+                               rmiComm.decrementObjectIdCounter();
+                               MoistureSensorCallback_Skeleton skel0 = new MoistureSensorCallback_Skeleton(_callbackTo, rmiComm, newObjIdSent);
+                               IoTRMIUtil.mapSkel.put(_callbackTo, skel0);
+                               IoTRMIUtil.mapSkelId.put(_callbackTo, newObjIdSent);
+                               Thread thread = new Thread() {
+                                       public void run() {
+                                               try {
+                                                       skel0.___waitRequestInvokeMethod();
+                                                       } catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                                       throw new Error("Exception when trying to run ___waitRequestInvokeMethod() for MoistureSensorCallback_Skeleton!");
+                                               }
+                                       }
+                               };
+                               thread.start();
+                               while(!skel0.didAlreadyInitWaitInvoke());
+                       }
+                       else
+                       {
+                               int newObjIdSent = IoTRMIUtil.mapSkelId.get(_callbackTo);
+                               objIdSent0[0] = newObjIdSent;
+                       }
                } catch (Exception ex) {
                        ex.printStackTrace();
                        throw new Error("Exception when generating skeleton objects!");
@@ -64,43 +110,9 @@ public class MoistureSensorSmart_Stub implements MoistureSensorSmart {
 
                int methodId = 5;
                Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int.class };
-               Object[] paramObj = new Object[] { new Integer(1) };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-       public void ___initCallBack() {
-               Thread thread = new Thread() {
-                       public void run() {
-                               try {
-                                       rmiObj = new IoTRMIObject(ports[0]);
-                                       while (true) {
-                                               byte[] method = rmiObj.getMethodBytes();
-                                               int objId = IoTRMIObject.getObjectId(method);
-                                               MoistureSensorCallback_CallbackSkeleton skel = (MoistureSensorCallback_CallbackSkeleton) listCallbackObj.get(objId);
-                                               if (skel != null) {
-                                                       int methodId = IoTRMIObject.getMethodId(method);
-                                                       if (!set0Allowed.contains(methodId)) {
-                                                               throw new Error("Callback object for MoistureSensorCallback is not allowed to access method: " + methodId);
-                                                       }
-                                                       skel.invokeMethod(rmiObj);
-                                               } else {
-                                                       throw new Error("MoistureSensorCallback: Object with Id " + objId + " not found!");
-                                               }
-                                       }
-                               } catch (Exception ex) {
-                                       ex.printStackTrace();
-                                       throw new Error("Error instantiating class MoistureSensorCallback_CallbackSkeleton!");
-                               }
-                       }
-               };
-               thread.start();
-
-               int methodId = -9998;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int[].class, String.class, int.class };
-               Object[] paramObj = new Object[] { ports, callbackAddress, 0 };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               Class<?>[] paramCls = new Class<?>[] { int[].class };
+               Object[] paramObj = new Object[] { objIdSent0 };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public float getMoisture() {
@@ -108,7 +120,13 @@ public class MoistureSensorSmart_Stub implements MoistureSensorSmart {
                Class<?> retType = float.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived1.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived1.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (float)retObj;
        }
 
@@ -117,7 +135,7 @@ public class MoistureSensorSmart_Stub implements MoistureSensorSmart {
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] { int.class };
                Object[] paramObj = new Object[] { id };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public void init() {
@@ -125,7 +143,7 @@ public class MoistureSensorSmart_Stub implements MoistureSensorSmart {
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
 }
index 6e06e56..6209290 100644 (file)
@@ -4,24 +4,45 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class SprinklerSmart_Stub implements SprinklerSmart {
 
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private final static int objectId = 0;
+       private int objectId = 6;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       private AtomicBoolean retValueReceived4 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived2 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived3 = new AtomicBoolean(false);
        
 
-       public SprinklerSmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               ports = _ports;
-               rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
+       public SprinklerSmart_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               rmiComm.registerStub(objectId, 4, retValueReceived4);
+               rmiComm.registerStub(objectId, 2, retValueReceived2);
+               rmiComm.registerStub(objectId, 3, retValueReceived3);
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public SprinklerSmart_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               rmiComm.registerStub(objectId, 4, retValueReceived4);
+               rmiComm.registerStub(objectId, 2, retValueReceived2);
+               rmiComm.registerStub(objectId, 3, retValueReceived3);
        }
 
        public boolean doesHaveZoneTimers() {
@@ -29,7 +50,13 @@ public class SprinklerSmart_Stub implements SprinklerSmart {
                Class<?> retType = boolean.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived4.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived4.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (boolean)retObj;
        }
 
@@ -38,8 +65,14 @@ public class SprinklerSmart_Stub implements SprinklerSmart {
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retLenObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-               int retLen = (int) retLenObj;
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived2.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived2.set(false);
+               rmiComm.setGetReturnBytes();
+
+               int retLen = (int) retObj;
                Class<?>[] retCls = new Class<?>[3*retLen];
                Class<?>[] retClsVal = new Class<?>[3*retLen];
                int retPos = 0;
@@ -51,14 +84,19 @@ public class SprinklerSmart_Stub implements SprinklerSmart {
                        retCls[retPos] = int.class;
                        retClsVal[retPos++] = null;
                }
-               Object[] retObj = rmiCall.getStructObjects(retCls, retClsVal);
+               // Waiting for return value
+               while (!retValueReceived2.get());
+               Object[] retActualObj = rmiComm.getStructObjects(retCls, retClsVal);
+               retValueReceived2.set(false);
+               rmiComm.setGetReturnBytes();
+
                List<ZoneState> structRet = new ArrayList<ZoneState>();
                int retObjPos = 0;
                for(int i = 0; i < retLen; i++) {
                        ZoneState structRetMem = new ZoneState();
-                       structRetMem.zoneNumber = (int) retObj[retObjPos++];
-                       structRetMem.onOffState = (boolean) retObj[retObjPos++];
-                       structRetMem.duration = (int) retObj[retObjPos++];
+                       structRetMem.zoneNumber = (int) retActualObj[retObjPos++];
+                       structRetMem.onOffState = (boolean) retActualObj[retObjPos++];
+                       structRetMem.duration = (int) retActualObj[retObjPos++];
                        structRet.add(structRetMem);
                }
                return structRet;
@@ -69,7 +107,7 @@ public class SprinklerSmart_Stub implements SprinklerSmart {
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public void setZone(int _zone, boolean _onOff, int _onDurationSeconds) {
@@ -77,7 +115,7 @@ public class SprinklerSmart_Stub implements SprinklerSmart {
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] { int.class, boolean.class, int.class };
                Object[] paramObj = new Object[] { _zone, _onOff, _onDurationSeconds };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public int getNumberOfZones() {
@@ -85,7 +123,13 @@ public class SprinklerSmart_Stub implements SprinklerSmart {
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived3.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived3.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (int)retObj;
        }
 
diff --git a/benchmarks/Java/IrrigationController/WeatherGatewayCallback_CallbackSkeleton.java b/benchmarks/Java/IrrigationController/WeatherGatewayCallback_CallbackSkeleton.java
deleted file mode 100644 (file)
index f3696e4..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package IrrigationController;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class WeatherGatewayCallback_CallbackSkeleton implements WeatherGatewayCallback {
-
-       private WeatherGatewayCallback mainObj;
-       private int objectId = 0;
-       private String callbackAddress;
-       
-
-       public WeatherGatewayCallback_CallbackSkeleton(WeatherGatewayCallback _mainObj, String _callbackAddress, int _objectId) throws Exception {
-               callbackAddress = _callbackAddress;
-               mainObj = _mainObj;
-               objectId = _objectId;
-       }
-
-       public void informationRetrieved(double _inchesPerWeek, int _weatherZipCode, int _daysToWaterOn, double _inchesPerMinute) {
-               mainObj.informationRetrieved(_inchesPerWeek, _weatherZipCode, _daysToWaterOn, _inchesPerMinute);
-       }
-
-       public void ___informationRetrieved(IoTRMIObject rmiObj) {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { double.class, int.class, int.class, double.class }, 
-               new Class<?>[] { null, null, null, null });
-               informationRetrieved((double) paramObj[0], (int) paramObj[1], (int) paramObj[2], (double) paramObj[3]);
-       }
-
-       public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
-               int methodId = rmiObj.getMethodId();
-               switch (methodId) {
-                       case 0: ___informationRetrieved(rmiObj); break;
-                       default: 
-                       throw new Error("Method Id " + methodId + " not recognized!");
-               }
-       }
-
-}
diff --git a/benchmarks/Java/IrrigationController/WeatherGatewayCallback_Skeleton.java b/benchmarks/Java/IrrigationController/WeatherGatewayCallback_Skeleton.java
new file mode 100644 (file)
index 0000000..4040ed4
--- /dev/null
@@ -0,0 +1,116 @@
+package IrrigationController;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class WeatherGatewayCallback_Skeleton implements WeatherGatewayCallback {
+
+       private WeatherGatewayCallback mainObj;
+       private int objectId = 4;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object4Permission = { 0 };
+       private static List<Integer> set4Allowed;
+       
+
+       public WeatherGatewayCallback_Skeleton(WeatherGatewayCallback _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set4Allowed = new ArrayList<Integer>(Arrays.asList(object4Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public WeatherGatewayCallback_Skeleton(WeatherGatewayCallback _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set4Allowed = new ArrayList<Integer>(Arrays.asList(object4Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
+       }
+
+       public void informationRetrieved(double _inchesPerWeek, int _weatherZipCode, int _daysToWaterOn, double _inchesPerMinute) {
+               mainObj.informationRetrieved(_inchesPerWeek, _weatherZipCode, _daysToWaterOn, _inchesPerMinute);
+       }
+
+       public void ___informationRetrieved() {
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { double.class, int.class, int.class, double.class }, new Class<?>[] { null, null, null, null }, localMethodBytes);
+               informationRetrieved((double) paramObj[0], (int) paramObj[1], (int) paramObj[2], (double) paramObj[3]);
+       }
+
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
+               while (true) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set4Allowed.contains(methodId)) {
+                                       throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
+                               }
+                       }
+                       else {
+                               continue;
+                       }
+                       switch (methodId) {
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___informationRetrieved();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               default: 
+                               throw new Error("Method Id " + methodId + " not recognized!");
+                       }
+               }
+       }
+
+}
index e8922c5..9c10528 100644 (file)
@@ -4,35 +4,48 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class WeatherGatewaySmart_Stub implements WeatherGatewaySmart {
 
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private final static int objectId = 0;
-       // Callback properties
-       private IoTRMIObject rmiObj;
-       List<WeatherGatewayCallback> listCallbackObj;
-       private int objIdCnt = 0;
-       private final static int object0Id = 0; //WeatherGatewaySmartCallback
-       private static Integer[] object0Permission = { 0 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 3;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       private AtomicBoolean retValueReceived3 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived6 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived5 = new AtomicBoolean(false);
+       private AtomicBoolean retValueReceived4 = new AtomicBoolean(false);
        
 
-       public WeatherGatewaySmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               ports = _ports;
-               rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               listCallbackObj = new ArrayList<WeatherGatewayCallback>();
-               set0Allowed.add(-9999);
-               ___initCallBack();
+       public WeatherGatewaySmart_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               rmiComm.registerStub(objectId, 3, retValueReceived3);
+               rmiComm.registerStub(objectId, 6, retValueReceived6);
+               rmiComm.registerStub(objectId, 5, retValueReceived5);
+               rmiComm.registerStub(objectId, 4, retValueReceived4);
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public WeatherGatewaySmart_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               rmiComm.registerStub(objectId, 3, retValueReceived3);
+               rmiComm.registerStub(objectId, 6, retValueReceived6);
+               rmiComm.registerStub(objectId, 5, retValueReceived5);
+               rmiComm.registerStub(objectId, 4, retValueReceived4);
        }
 
        public double getInchesPerWeek() {
@@ -40,7 +53,13 @@ public class WeatherGatewaySmart_Stub implements WeatherGatewaySmart {
                Class<?> retType = double.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived3.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived3.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (double)retObj;
        }
 
@@ -49,7 +68,13 @@ public class WeatherGatewaySmart_Stub implements WeatherGatewaySmart {
                Class<?> retType = double.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived6.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived6.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (double)retObj;
        }
 
@@ -58,14 +83,44 @@ public class WeatherGatewaySmart_Stub implements WeatherGatewaySmart {
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived5.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived5.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (int)retObj;
        }
 
        public void registerCallback(WeatherGatewayCallback _callbackTo) {
+               int[] objIdSent0 = new int[1];
                try {
-                       WeatherGatewayCallback_CallbackSkeleton skel0 = new WeatherGatewayCallback_CallbackSkeleton(_callbackTo, callbackAddress, objIdCnt++);
-                       listCallbackObj.add(skel0);
+                       if (!IoTRMIUtil.mapSkel.containsKey(_callbackTo)) {
+                               int newObjIdSent = rmiComm.getObjectIdCounter();
+                               objIdSent0[0] = newObjIdSent;
+                               rmiComm.decrementObjectIdCounter();
+                               WeatherGatewayCallback_Skeleton skel0 = new WeatherGatewayCallback_Skeleton(_callbackTo, rmiComm, newObjIdSent);
+                               IoTRMIUtil.mapSkel.put(_callbackTo, skel0);
+                               IoTRMIUtil.mapSkelId.put(_callbackTo, newObjIdSent);
+                               Thread thread = new Thread() {
+                                       public void run() {
+                                               try {
+                                                       skel0.___waitRequestInvokeMethod();
+                                                       } catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                                       throw new Error("Exception when trying to run ___waitRequestInvokeMethod() for WeatherGatewayCallback_Skeleton!");
+                                               }
+                                       }
+                               };
+                               thread.start();
+                               while(!skel0.didAlreadyInitWaitInvoke());
+                       }
+                       else
+                       {
+                               int newObjIdSent = IoTRMIUtil.mapSkelId.get(_callbackTo);
+                               objIdSent0[0] = newObjIdSent;
+                       }
                } catch (Exception ex) {
                        ex.printStackTrace();
                        throw new Error("Exception when generating skeleton objects!");
@@ -73,43 +128,9 @@ public class WeatherGatewaySmart_Stub implements WeatherGatewaySmart {
 
                int methodId = 7;
                Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int.class };
-               Object[] paramObj = new Object[] { new Integer(1) };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-       public void ___initCallBack() {
-               Thread thread = new Thread() {
-                       public void run() {
-                               try {
-                                       rmiObj = new IoTRMIObject(ports[0]);
-                                       while (true) {
-                                               byte[] method = rmiObj.getMethodBytes();
-                                               int objId = IoTRMIObject.getObjectId(method);
-                                               WeatherGatewayCallback_CallbackSkeleton skel = (WeatherGatewayCallback_CallbackSkeleton) listCallbackObj.get(objId);
-                                               if (skel != null) {
-                                                       int methodId = IoTRMIObject.getMethodId(method);
-                                                       if (!set0Allowed.contains(methodId)) {
-                                                               throw new Error("Callback object for WeatherGatewayCallback is not allowed to access method: " + methodId);
-                                                       }
-                                                       skel.invokeMethod(rmiObj);
-                                               } else {
-                                                       throw new Error("WeatherGatewayCallback: Object with Id " + objId + " not found!");
-                                               }
-                                       }
-                               } catch (Exception ex) {
-                                       ex.printStackTrace();
-                                       throw new Error("Error instantiating class WeatherGatewayCallback_CallbackSkeleton!");
-                               }
-                       }
-               };
-               thread.start();
-
-               int methodId = -9998;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int[].class, String.class, int.class };
-               Object[] paramObj = new Object[] { ports, callbackAddress, 0 };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               Class<?>[] paramCls = new Class<?>[] { int[].class };
+               Object[] paramObj = new Object[] { objIdSent0 };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public void stop() {
@@ -117,7 +138,7 @@ public class WeatherGatewaySmart_Stub implements WeatherGatewaySmart {
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public void start() {
@@ -125,7 +146,7 @@ public class WeatherGatewaySmart_Stub implements WeatherGatewaySmart {
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public void init() {
@@ -133,7 +154,7 @@ public class WeatherGatewaySmart_Stub implements WeatherGatewaySmart {
                Class<?> retType = void.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
        }
 
        public int getWeatherZipCode() {
@@ -141,7 +162,13 @@ public class WeatherGatewaySmart_Stub implements WeatherGatewaySmart {
                Class<?> retType = int.class;
                Class<?>[] paramCls = new Class<?>[] {  };
                Object[] paramObj = new Object[] {  };
-               Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+               // Waiting for return value
+               while (!retValueReceived4.get());
+               Object retObj = rmiComm.getReturnValue(retType, null);
+               retValueReceived4.set(false);
+               rmiComm.setGetReturnBytes();
+
                return (int)retObj;
        }
 
diff --git a/benchmarks/Java/SpeakerController/GPSGatewayCallback_CallbackSkeleton.java b/benchmarks/Java/SpeakerController/GPSGatewayCallback_CallbackSkeleton.java
deleted file mode 100644 (file)
index 91c2d15..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-package SpeakerController;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class GPSGatewayCallback_CallbackSkeleton implements GPSGatewayCallback {
-
-       private GPSGatewayCallback mainObj;
-       private int objectId = 0;
-       private String callbackAddress;
-       
-
-       public GPSGatewayCallback_CallbackSkeleton(GPSGatewayCallback _mainObj, String _callbackAddress, int _objectId) throws Exception {
-               callbackAddress = _callbackAddress;
-               mainObj = _mainObj;
-               objectId = _objectId;
-       }
-
-       public void newRoomIDRetrieved(int _roomIdentifier) {
-               mainObj.newRoomIDRetrieved(_roomIdentifier);
-       }
-
-       public void newRingStatusRetrieved(boolean _ringStatus) {
-               mainObj.newRingStatusRetrieved(_ringStatus);
-       }
-
-       public void ___newRoomIDRetrieved(IoTRMIObject rmiObj) {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
-               newRoomIDRetrieved((int) paramObj[0]);
-       }
-
-       public void ___newRingStatusRetrieved(IoTRMIObject rmiObj) {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { boolean.class }, 
-               new Class<?>[] { null });
-               newRingStatusRetrieved((boolean) paramObj[0]);
-       }
-
-       public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
-               int methodId = rmiObj.getMethodId();
-               switch (methodId) {
-                       case 0: ___newRoomIDRetrieved(rmiObj); break;
-                       case 1: ___newRingStatusRetrieved(rmiObj); break;
-                       default: 
-                       throw new Error("Method Id " + methodId + " not recognized!");
-               }
-       }
-
-}
diff --git a/benchmarks/Java/SpeakerController/SpeakerCallback_CallbackSkeleton.java b/benchmarks/Java/SpeakerController/SpeakerCallback_CallbackSkeleton.java
deleted file mode 100644 (file)
index 808ae44..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package SpeakerController;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class SpeakerCallback_CallbackSkeleton implements SpeakerCallback {
-
-       private SpeakerCallback mainObj;
-       private int objectId = 0;
-       private String callbackAddress;
-       
-
-       public SpeakerCallback_CallbackSkeleton(SpeakerCallback _mainObj, String _callbackAddress, int _objectId) throws Exception {
-               callbackAddress = _callbackAddress;
-               mainObj = _mainObj;
-               objectId = _objectId;
-       }
-
-       public void speakerDone() {
-               mainObj.speakerDone();
-       }
-
-       public void ___speakerDone(IoTRMIObject rmiObj) {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
-               speakerDone();
-       }
-
-       public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
-               int methodId = rmiObj.getMethodId();
-               switch (methodId) {
-                       case 0: ___speakerDone(rmiObj); break;
-                       default: 
-                       throw new Error("Method Id " + methodId + " not recognized!");
-               }
-       }
-
-}
index b9b9b3b..47e78ce 100644 (file)
@@ -4,28 +4,65 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.Room;
 
 public class Room_Skeleton implements Room {
 
        private Room mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private final static int object0Id = 0; //RoomSmart
-       private static Integer[] object0Permission = { 0 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 4;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object4Permission = { 0 };
+       private static List<Integer> set4Allowed;
        
 
-       public Room_Skeleton(Room _mainObj, String _callbackAddress, int _port) throws Exception {
+       public Room_Skeleton(Room _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set4Allowed = new ArrayList<Integer>(Arrays.asList(object4Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public Room_Skeleton(Room _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set4Allowed = new ArrayList<Integer>(Arrays.asList(object4Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
        }
 
        public int getRoomID() {
@@ -33,27 +70,44 @@ public class Room_Skeleton implements Room {
        }
 
        public void ___getRoomID() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getRoomID();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set4Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
-                               case 0: ___getRoomID(); break;
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getRoomID();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
                                default: 
                                throw new Error("Method Id " + methodId + " not recognized!");
                        }
index a2830a8..25740f2 100644 (file)
@@ -4,28 +4,65 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class Sprinkler_Skeleton implements Sprinkler {
 
        private Sprinkler mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private final static int object0Id = 0; //SprinklerSmart
-       private static Integer[] object0Permission = { 4, 2, 0, 1, 3 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 6;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object2Permission = { 4, 2, 0, 1, 3 };
+       private static List<Integer> set2Allowed;
        
 
-       public Sprinkler_Skeleton(Sprinkler _mainObj, String _callbackAddress, int _port) throws Exception {
+       public Sprinkler_Skeleton(Sprinkler _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set2Allowed = new ArrayList<Integer>(Arrays.asList(object2Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public Sprinkler_Skeleton(Sprinkler _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set2Allowed = new ArrayList<Integer>(Arrays.asList(object2Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
        }
 
        public void init() {
@@ -49,24 +86,27 @@ public class Sprinkler_Skeleton implements Sprinkler {
        }
 
        public void ___init() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                init();
        }
 
        public void ___setZone() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class, boolean.class, int.class }, 
-               new Class<?>[] { null, null, null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int.class, boolean.class, int.class }, new Class<?>[] { null, null, null }, localMethodBytes);
                setZone((int) paramObj[0], (boolean) paramObj[1], (int) paramObj[2]);
        }
 
        public void ___getZoneStates() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                List<ZoneState> retStruct = getZoneStates();
                int retLen = retStruct.size();
                Object retLenObj = retLen;
-               rmiObj.sendReturnObj(retLenObj);
+               rmiComm.sendReturnObj(retLenObj, localMethodBytes);
                Class<?>[] retCls = new Class<?>[3*retLen];
                Object[] retObj = new Object[3*retLen];
                int retPos = 0;
@@ -78,42 +118,104 @@ public class Sprinkler_Skeleton implements Sprinkler {
                        retCls[retPos] = int.class;
                        retObj[retPos++] = retStruct.get(i).duration;
                }
-               rmiObj.sendReturnObj(retCls, retObj);
+               rmiComm.sendReturnObj(retCls, retObj, localMethodBytes);
        }
 
        public void ___getNumberOfZones() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getNumberOfZones();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___doesHaveZoneTimers() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = doesHaveZoneTimers();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set2Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
-                               case 0: ___init(); break;
-                               case 1: ___setZone(); break;
-                               case 2: ___getZoneStates(); break;
-                               case 3: ___getNumberOfZones(); break;
-                               case 4: ___doesHaveZoneTimers(); break;
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___init();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 1:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___setZone();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 2:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getZoneStates();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 3:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getNumberOfZones();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 4:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___doesHaveZoneTimers();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
                                default: 
                                throw new Error("Method Id " + methodId + " not recognized!");
                        }
diff --git a/benchmarks/drivers/Java/GPSPhoneGateway/GPSGatewaySmartCallback_CallbackStub.java b/benchmarks/drivers/Java/GPSPhoneGateway/GPSGatewaySmartCallback_CallbackStub.java
deleted file mode 100644 (file)
index c728a8f..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package iotcode.GPSPhoneGateway;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class GPSGatewaySmartCallback_CallbackStub implements GPSGatewaySmartCallback {
-
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private int objectId = 0;
-       
-
-       public GPSGatewaySmartCallback_CallbackStub(IoTRMICall _rmiCall, String _callbackAddress, int _objectId, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               objectId = _objectId;
-               rmiCall = _rmiCall;
-               ports = _ports;
-       }
-
-       public void newRoomIDRetrieved(int _roomIdentifier) {
-               int methodId = 0;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int.class };
-               Object[] paramObj = new Object[] { _roomIdentifier };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-       public void newRingStatusRetrieved(boolean _ringStatus) {
-               int methodId = 1;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { boolean.class };
-               Object[] paramObj = new Object[] { _ringStatus };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-}
diff --git a/benchmarks/drivers/Java/GPSPhoneGateway/GPSGatewaySmartCallback_Stub.java b/benchmarks/drivers/Java/GPSPhoneGateway/GPSGatewaySmartCallback_Stub.java
new file mode 100644 (file)
index 0000000..da3ab21
--- /dev/null
@@ -0,0 +1,55 @@
+package iotcode.GPSPhoneGateway;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class GPSGatewaySmartCallback_Stub implements GPSGatewaySmartCallback {
+
+       private int objectId = 4;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       
+
+       public GPSGatewaySmartCallback_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public GPSGatewaySmartCallback_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+       }
+
+       public void newRoomIDRetrieved(int _roomIdentifier) {
+               int methodId = 0;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] { int.class };
+               Object[] paramObj = new Object[] { _roomIdentifier };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+       }
+
+       public void newRingStatusRetrieved(boolean _ringStatus) {
+               int methodId = 1;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] { boolean.class };
+               Object[] paramObj = new Object[] { _ringStatus };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+       }
+
+}
index 382785f..c54c4d7 100644 (file)
@@ -4,33 +4,65 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class GPSGateway_Skeleton implements GPSGateway {
 
        private GPSGateway mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private int objIdCnt = 0;
-       private IoTRMICall rmiCall;
-       private int[] ports;
-
-       private final static int object0Id = 0; //GPSGatewaySmart
-       private static Integer[] object0Permission = { 5, 6, 2, 1, 0, 3, 7, 4 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 3;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object3Permission = { 5, 6, 2, 1, 0, 3, 7, 4 };
+       private static List<Integer> set3Allowed;
        
 
-       public GPSGateway_Skeleton(GPSGateway _mainObj, String _callbackAddress, int _port) throws Exception {
+       public GPSGateway_Skeleton(GPSGateway _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set3Allowed = new ArrayList<Integer>(Arrays.asList(object3Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public GPSGateway_Skeleton(GPSGateway _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               set0Allowed.add(-9998);
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set3Allowed = new ArrayList<Integer>(Arrays.asList(object3Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
        }
 
        public void init() {
@@ -65,62 +97,75 @@ public class GPSGateway_Skeleton implements GPSGateway {
                mainObj.registerCallback(_callbackTo);
        }
 
-       public void ___regCB() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
-               ports = (int[]) paramObj[0];
-               rmiCall = new IoTRMICall(ports[0], (String) paramObj[1], (int) paramObj[2]);
-       }
-
        public void ___init() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                init();
        }
 
        public void ___start() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                start();
        }
 
        public void ___stop() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                stop();
        }
 
        public void ___getRoomID() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getRoomID();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getRingStatus() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getRingStatus();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___setNewRoomIDAvailable() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { boolean.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { boolean.class }, new Class<?>[] { null }, localMethodBytes);
                setNewRoomIDAvailable((boolean) paramObj[0]);
        }
 
        public void ___setNewRingStatusAvailable() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { boolean.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { boolean.class }, new Class<?>[] { null }, localMethodBytes);
                setNewRingStatusAvailable((boolean) paramObj[0]);
        }
 
        public void ___registerCallback() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int[].class }, new Class<?>[] { null }, localMethodBytes);
                try {
-                       GPSGatewaySmartCallback stub0 = new GPSGatewaySmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
-                       objIdCnt++;
+                       int[] stubIdArray0 = (int[]) paramObj[0];
+                       int objIdRecv0 = stubIdArray0[0];
+                       GPSGatewaySmartCallback newStub0 = null;
+                       if(!IoTRMIUtil.mapStub.containsKey(objIdRecv0)) {
+                               newStub0 = new GPSGatewaySmartCallback_Stub(rmiComm, objIdRecv0);
+                               IoTRMIUtil.mapStub.put(objIdRecv0, newStub0);
+                               rmiComm.setObjectIdCounter(objIdRecv0);
+                               rmiComm.decrementObjectIdCounter();
+                       }
+                       else {
+                               newStub0 = (GPSGatewaySmartCallback_Stub) IoTRMIUtil.mapStub.get(objIdRecv0);
+                       }
+                       GPSGatewaySmartCallback stub0 = newStub0;
                        registerCallback(stub0);
                } catch(Exception ex) {
                        ex.printStackTrace();
@@ -128,29 +173,121 @@ public class GPSGateway_Skeleton implements GPSGateway {
                }
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set3Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
-                               case 0: ___init(); break;
-                               case 1: ___start(); break;
-                               case 2: ___stop(); break;
-                               case 3: ___getRoomID(); break;
-                               case 4: ___getRingStatus(); break;
-                               case 5: ___setNewRoomIDAvailable(); break;
-                               case 6: ___setNewRingStatusAvailable(); break;
-                               case 7: ___registerCallback(); break;
-                               case -9998: ___regCB(); break;
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___init();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 1:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___start();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 2:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___stop();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 3:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getRoomID();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 4:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getRingStatus();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 5:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___setNewRoomIDAvailable();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 6:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___setNewRingStatusAvailable();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 7:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___registerCallback();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
                                default: 
                                throw new Error("Method Id " + methodId + " not recognized!");
                        }
index bc72a64..e7ef58b 100644 (file)
@@ -4,42 +4,84 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class Lawn_Skeleton implements Lawn {
 
        private Lawn mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private final static int object0Id = 0; //LawnSmart
-       private static Integer[] object0Permission = {  };
-       private static List<Integer> set0Allowed;
+       private int objectId = 1;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object1Permission = {  };
+       private static List<Integer> set1Allowed;
        
 
-       public Lawn_Skeleton(Lawn _mainObj, String _callbackAddress, int _port) throws Exception {
+       public Lawn_Skeleton(Lawn _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set1Allowed = new ArrayList<Integer>(Arrays.asList(object1Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public Lawn_Skeleton(Lawn _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set1Allowed = new ArrayList<Integer>(Arrays.asList(object1Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
+       }
+
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set1Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
                                default: 
index 7a02025..7b1650c 100644 (file)
@@ -4,28 +4,65 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.Room;
 
 public class Room_Skeleton implements Room {
 
        private Room mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private final static int object0Id = 0; //RoomSmart
-       private static Integer[] object0Permission = { 0 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 4;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object4Permission = { 0 };
+       private static List<Integer> set4Allowed;
        
 
-       public Room_Skeleton(Room _mainObj, String _callbackAddress, int _port) throws Exception {
+       public Room_Skeleton(Room _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set4Allowed = new ArrayList<Integer>(Arrays.asList(object4Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public Room_Skeleton(Room _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set4Allowed = new ArrayList<Integer>(Arrays.asList(object4Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
        }
 
        public int getRoomID() {
@@ -33,27 +70,44 @@ public class Room_Skeleton implements Room {
        }
 
        public void ___getRoomID() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getRoomID();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set4Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
-                               case 0: ___getRoomID(); break;
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getRoomID();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
                                default: 
                                throw new Error("Method Id " + methodId + " not recognized!");
                        }
diff --git a/benchmarks/drivers/Java/IHome/SpeakerSmartCallback_CallbackStub.java b/benchmarks/drivers/Java/IHome/SpeakerSmartCallback_CallbackStub.java
deleted file mode 100644 (file)
index 2dfc481..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package iotcode.IHome;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class SpeakerSmartCallback_CallbackStub implements SpeakerSmartCallback {
-
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private int objectId = 0;
-       
-
-       public SpeakerSmartCallback_CallbackStub(IoTRMICall _rmiCall, String _callbackAddress, int _objectId, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               objectId = _objectId;
-               rmiCall = _rmiCall;
-               ports = _ports;
-       }
-
-       public void speakerDone() {
-               int methodId = 0;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] {  };
-               Object[] paramObj = new Object[] {  };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-}
diff --git a/benchmarks/drivers/Java/IHome/SpeakerSmartCallback_Stub.java b/benchmarks/drivers/Java/IHome/SpeakerSmartCallback_Stub.java
new file mode 100644 (file)
index 0000000..3a4a01d
--- /dev/null
@@ -0,0 +1,47 @@
+package iotcode.IHome;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class SpeakerSmartCallback_Stub implements SpeakerSmartCallback {
+
+       private int objectId = 2;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       
+
+       public SpeakerSmartCallback_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public SpeakerSmartCallback_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+       }
+
+       public void speakerDone() {
+               int methodId = 0;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] {  };
+               Object[] paramObj = new Object[] {  };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+       }
+
+}
index 75f2f6d..f2b994d 100644 (file)
@@ -4,33 +4,65 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class Speaker_Skeleton implements Speaker {
 
        private Speaker mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private int objIdCnt = 0;
-       private IoTRMICall rmiCall;
-       private int[] ports;
-
-       private final static int object0Id = 0; //SpeakerSmart
-       private static Integer[] object0Permission = { 6, 2, 9, 1, 3, 4, 5, 7, 8, 0, 10 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 1;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object1Permission = { 6, 2, 9, 1, 3, 4, 5, 7, 8, 0, 10 };
+       private static List<Integer> set1Allowed;
        
 
-       public Speaker_Skeleton(Speaker _mainObj, String _callbackAddress, int _port) throws Exception {
+       public Speaker_Skeleton(Speaker _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set1Allowed = new ArrayList<Integer>(Arrays.asList(object1Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public Speaker_Skeleton(Speaker _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               set0Allowed.add(-9998);
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set1Allowed = new ArrayList<Integer>(Arrays.asList(object1Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
        }
 
        public void init() {
@@ -77,84 +109,100 @@ public class Speaker_Skeleton implements Speaker {
                mainObj.registerCallback(_cb);
        }
 
-       public void ___regCB() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
-               ports = (int[]) paramObj[0];
-               rmiCall = new IoTRMICall(ports[0], (String) paramObj[1], (int) paramObj[2]);
-       }
-
        public void ___init() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                init();
        }
 
        public void ___startPlayback() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = startPlayback();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___stopPlayback() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = stopPlayback();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getPlaybackState() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getPlaybackState();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___setVolume() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { float.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { float.class }, new Class<?>[] { null }, localMethodBytes);
                Object retObj = setVolume((float) paramObj[0]);
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getVolume() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getVolume();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getPosition() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getPosition();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___setPosition() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int.class }, new Class<?>[] { null }, localMethodBytes);
                setPosition((int) paramObj[0]);
        }
 
        public void ___loadData() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { short[].class, int.class, int.class }, 
-               new Class<?>[] { null, null, null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { short[].class, int.class, int.class }, new Class<?>[] { null, null, null }, localMethodBytes);
                loadData((short[]) paramObj[0], (int) paramObj[1], (int) paramObj[2]);
        }
 
        public void ___clearData() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                clearData();
        }
 
        public void ___registerCallback() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int[].class }, new Class<?>[] { null }, localMethodBytes);
                try {
-                       SpeakerSmartCallback stub0 = new SpeakerSmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
-                       objIdCnt++;
+                       int[] stubIdArray0 = (int[]) paramObj[0];
+                       int objIdRecv0 = stubIdArray0[0];
+                       SpeakerSmartCallback newStub0 = null;
+                       if(!IoTRMIUtil.mapStub.containsKey(objIdRecv0)) {
+                               newStub0 = new SpeakerSmartCallback_Stub(rmiComm, objIdRecv0);
+                               IoTRMIUtil.mapStub.put(objIdRecv0, newStub0);
+                               rmiComm.setObjectIdCounter(objIdRecv0);
+                               rmiComm.decrementObjectIdCounter();
+                       }
+                       else {
+                               newStub0 = (SpeakerSmartCallback_Stub) IoTRMIUtil.mapStub.get(objIdRecv0);
+                       }
+                       SpeakerSmartCallback stub0 = newStub0;
                        registerCallback(stub0);
                } catch(Exception ex) {
                        ex.printStackTrace();
@@ -162,32 +210,157 @@ public class Speaker_Skeleton implements Speaker {
                }
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set1Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
-                               case 0: ___init(); break;
-                               case 1: ___startPlayback(); break;
-                               case 2: ___stopPlayback(); break;
-                               case 3: ___getPlaybackState(); break;
-                               case 4: ___setVolume(); break;
-                               case 5: ___getVolume(); break;
-                               case 6: ___getPosition(); break;
-                               case 7: ___setPosition(); break;
-                               case 8: ___loadData(); break;
-                               case 9: ___clearData(); break;
-                               case 10: ___registerCallback(); break;
-                               case -9998: ___regCB(); break;
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___init();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 1:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___startPlayback();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 2:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___stopPlayback();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 3:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getPlaybackState();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 4:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___setVolume();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 5:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getVolume();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 6:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getPosition();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 7:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___setPosition();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 8:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___loadData();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 9:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___clearData();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 10:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___registerCallback();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
                                default: 
                                throw new Error("Method Id " + methodId + " not recognized!");
                        }
diff --git a/benchmarks/drivers/Java/MotionSensor/SmartthingsSensorSmartCallback_CallbackStub.java b/benchmarks/drivers/Java/MotionSensor/SmartthingsSensorSmartCallback_CallbackStub.java
deleted file mode 100644 (file)
index 037968d..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package iotcode.MotionSensor;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class SmartthingsSensorSmartCallback_CallbackStub implements SmartthingsSensorSmartCallback {
-
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private int objectId = 0;
-       
-
-       public SmartthingsSensorSmartCallback_CallbackStub(IoTRMICall _rmiCall, String _callbackAddress, int _objectId, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               objectId = _objectId;
-               rmiCall = _rmiCall;
-               ports = _ports;
-       }
-
-       public void newReadingAvailable(int _sensorId, int _value, boolean _activeValue) {
-               int methodId = 0;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int.class, int.class, boolean.class };
-               Object[] paramObj = new Object[] { _sensorId, _value, _activeValue };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-}
diff --git a/benchmarks/drivers/Java/MotionSensor/SmartthingsSensorSmartCallback_Stub.java b/benchmarks/drivers/Java/MotionSensor/SmartthingsSensorSmartCallback_Stub.java
new file mode 100644 (file)
index 0000000..e64093a
--- /dev/null
@@ -0,0 +1,47 @@
+package iotcode.MotionSensor;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class SmartthingsSensorSmartCallback_Stub implements SmartthingsSensorSmartCallback {
+
+       private int objectId = 3;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       
+
+       public SmartthingsSensorSmartCallback_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public SmartthingsSensorSmartCallback_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+       }
+
+       public void newReadingAvailable(int _sensorId, int _value, boolean _activeValue) {
+               int methodId = 0;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] { int.class, int.class, boolean.class };
+               Object[] paramObj = new Object[] { _sensorId, _value, _activeValue };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+       }
+
+}
index 4dc20e1..d6924b4 100644 (file)
@@ -4,33 +4,65 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
 
        private SmartthingsSensor mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private int objIdCnt = 0;
-       private IoTRMICall rmiCall;
-       private int[] ports;
-
-       private final static int object0Id = 0; //SmartthingsSensorSmart
-       private static Integer[] object0Permission = { 3, 2, 5, 6, 1, 4, 0 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 2;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object2Permission = { 3, 2, 5, 6, 1, 4, 0 };
+       private static List<Integer> set2Allowed;
        
 
-       public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, String _callbackAddress, int _port) throws Exception {
+       public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set2Allowed = new ArrayList<Integer>(Arrays.asList(object2Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               set0Allowed.add(-9998);
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set2Allowed = new ArrayList<Integer>(Arrays.asList(object2Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
        }
 
        public void init() {
@@ -61,58 +93,70 @@ public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
                mainObj.registerCallback(_callbackTo);
        }
 
-       public void ___regCB() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
-               ports = (int[]) paramObj[0];
-               rmiCall = new IoTRMICall(ports[0], (String) paramObj[1], (int) paramObj[2]);
-       }
-
        public void ___init() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                init();
        }
 
        public void ___getValue() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getValue();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___isActiveValue() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = isActiveValue();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getTimestampOfLastReading() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getTimestampOfLastReading();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___setId() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int.class }, new Class<?>[] { null }, localMethodBytes);
                setId((int) paramObj[0]);
        }
 
        public void ___getId() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getId();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___registerCallback() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int[].class }, new Class<?>[] { null }, localMethodBytes);
                try {
-                       SmartthingsSensorSmartCallback stub0 = new SmartthingsSensorSmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
-                       objIdCnt++;
+                       int[] stubIdArray0 = (int[]) paramObj[0];
+                       int objIdRecv0 = stubIdArray0[0];
+                       SmartthingsSensorSmartCallback newStub0 = null;
+                       if(!IoTRMIUtil.mapStub.containsKey(objIdRecv0)) {
+                               newStub0 = new SmartthingsSensorSmartCallback_Stub(rmiComm, objIdRecv0);
+                               IoTRMIUtil.mapStub.put(objIdRecv0, newStub0);
+                               rmiComm.setObjectIdCounter(objIdRecv0);
+                               rmiComm.decrementObjectIdCounter();
+                       }
+                       else {
+                               newStub0 = (SmartthingsSensorSmartCallback_Stub) IoTRMIUtil.mapStub.get(objIdRecv0);
+                       }
+                       SmartthingsSensorSmartCallback stub0 = newStub0;
                        registerCallback(stub0);
                } catch(Exception ex) {
                        ex.printStackTrace();
@@ -120,28 +164,109 @@ public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
                }
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set2Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
-                               case 0: ___init(); break;
-                               case 1: ___getValue(); break;
-                               case 2: ___isActiveValue(); break;
-                               case 3: ___getTimestampOfLastReading(); break;
-                               case 4: ___setId(); break;
-                               case 5: ___getId(); break;
-                               case 6: ___registerCallback(); break;
-                               case -9998: ___regCB(); break;
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___init();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 1:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getValue();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 2:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___isActiveValue();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 3:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getTimestampOfLastReading();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 4:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___setId();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 5:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getId();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 6:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___registerCallback();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
                                default: 
                                throw new Error("Method Id " + methodId + " not recognized!");
                        }
diff --git a/benchmarks/drivers/Java/MultipurposeSensor/SmartthingsSensorSmartCallback_CallbackStub.java b/benchmarks/drivers/Java/MultipurposeSensor/SmartthingsSensorSmartCallback_CallbackStub.java
deleted file mode 100644 (file)
index 6ed7f31..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package iotcode.MultipurposeSensor;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class SmartthingsSensorSmartCallback_CallbackStub implements SmartthingsSensorSmartCallback {
-
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private int objectId = 0;
-       
-
-       public SmartthingsSensorSmartCallback_CallbackStub(IoTRMICall _rmiCall, String _callbackAddress, int _objectId, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               objectId = _objectId;
-               rmiCall = _rmiCall;
-               ports = _ports;
-       }
-
-       public void newReadingAvailable(int _sensorId, int _value, boolean _activeValue) {
-               int methodId = 0;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int.class, int.class, boolean.class };
-               Object[] paramObj = new Object[] { _sensorId, _value, _activeValue };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-}
diff --git a/benchmarks/drivers/Java/MultipurposeSensor/SmartthingsSensorSmartCallback_Stub.java b/benchmarks/drivers/Java/MultipurposeSensor/SmartthingsSensorSmartCallback_Stub.java
new file mode 100644 (file)
index 0000000..bada1de
--- /dev/null
@@ -0,0 +1,47 @@
+package iotcode.MultipurposeSensor;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class SmartthingsSensorSmartCallback_Stub implements SmartthingsSensorSmartCallback {
+
+       private int objectId = 3;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       
+
+       public SmartthingsSensorSmartCallback_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public SmartthingsSensorSmartCallback_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+       }
+
+       public void newReadingAvailable(int _sensorId, int _value, boolean _activeValue) {
+               int methodId = 0;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] { int.class, int.class, boolean.class };
+               Object[] paramObj = new Object[] { _sensorId, _value, _activeValue };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+       }
+
+}
index db2f2d6..6ddc6cf 100644 (file)
@@ -4,33 +4,65 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
 
        private SmartthingsSensor mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private int objIdCnt = 0;
-       private IoTRMICall rmiCall;
-       private int[] ports;
-
-       private final static int object0Id = 0; //SmartthingsSensorSmart
-       private static Integer[] object0Permission = { 3, 2, 5, 6, 1, 4, 0 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 2;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object2Permission = { 3, 2, 5, 6, 1, 4, 0 };
+       private static List<Integer> set2Allowed;
        
 
-       public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, String _callbackAddress, int _port) throws Exception {
+       public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set2Allowed = new ArrayList<Integer>(Arrays.asList(object2Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               set0Allowed.add(-9998);
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set2Allowed = new ArrayList<Integer>(Arrays.asList(object2Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
        }
 
        public void init() {
@@ -61,58 +93,70 @@ public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
                mainObj.registerCallback(_callbackTo);
        }
 
-       public void ___regCB() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
-               ports = (int[]) paramObj[0];
-               rmiCall = new IoTRMICall(ports[0], (String) paramObj[1], (int) paramObj[2]);
-       }
-
        public void ___init() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                init();
        }
 
        public void ___getValue() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getValue();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___isActiveValue() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = isActiveValue();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getTimestampOfLastReading() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getTimestampOfLastReading();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___setId() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int.class }, new Class<?>[] { null }, localMethodBytes);
                setId((int) paramObj[0]);
        }
 
        public void ___getId() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getId();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___registerCallback() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int[].class }, new Class<?>[] { null }, localMethodBytes);
                try {
-                       SmartthingsSensorSmartCallback stub0 = new SmartthingsSensorSmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
-                       objIdCnt++;
+                       int[] stubIdArray0 = (int[]) paramObj[0];
+                       int objIdRecv0 = stubIdArray0[0];
+                       SmartthingsSensorSmartCallback newStub0 = null;
+                       if(!IoTRMIUtil.mapStub.containsKey(objIdRecv0)) {
+                               newStub0 = new SmartthingsSensorSmartCallback_Stub(rmiComm, objIdRecv0);
+                               IoTRMIUtil.mapStub.put(objIdRecv0, newStub0);
+                               rmiComm.setObjectIdCounter(objIdRecv0);
+                               rmiComm.decrementObjectIdCounter();
+                       }
+                       else {
+                               newStub0 = (SmartthingsSensorSmartCallback_Stub) IoTRMIUtil.mapStub.get(objIdRecv0);
+                       }
+                       SmartthingsSensorSmartCallback stub0 = newStub0;
                        registerCallback(stub0);
                } catch(Exception ex) {
                        ex.printStackTrace();
@@ -120,28 +164,109 @@ public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
                }
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set2Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
-                               case 0: ___init(); break;
-                               case 1: ___getValue(); break;
-                               case 2: ___isActiveValue(); break;
-                               case 3: ___getTimestampOfLastReading(); break;
-                               case 4: ___setId(); break;
-                               case 5: ___getId(); break;
-                               case 6: ___registerCallback(); break;
-                               case -9998: ___regCB(); break;
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___init();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 1:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getValue();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 2:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___isActiveValue();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 3:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getTimestampOfLastReading();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 4:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___setId();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 5:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getId();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 6:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___registerCallback();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
                                default: 
                                throw new Error("Method Id " + methodId + " not recognized!");
                        }
diff --git a/benchmarks/drivers/Java/SpruceSensor/MoistureSensorSmartCallback_CallbackStub.java b/benchmarks/drivers/Java/SpruceSensor/MoistureSensorSmartCallback_CallbackStub.java
deleted file mode 100644 (file)
index a2a318f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package iotcode.SpruceSensor;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class MoistureSensorSmartCallback_CallbackStub implements MoistureSensorSmartCallback {
-
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private int objectId = 0;
-       
-
-       public MoistureSensorSmartCallback_CallbackStub(IoTRMICall _rmiCall, String _callbackAddress, int _objectId, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               objectId = _objectId;
-               rmiCall = _rmiCall;
-               ports = _ports;
-       }
-
-       public void newReadingAvailable(int sensorId, float moisture, long timeStampOfLastReading) {
-               int methodId = 0;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int.class, float.class, long.class };
-               Object[] paramObj = new Object[] { sensorId, moisture, timeStampOfLastReading };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-}
diff --git a/benchmarks/drivers/Java/SpruceSensor/MoistureSensorSmartCallback_Stub.java b/benchmarks/drivers/Java/SpruceSensor/MoistureSensorSmartCallback_Stub.java
new file mode 100644 (file)
index 0000000..ee4aa08
--- /dev/null
@@ -0,0 +1,47 @@
+package iotcode.SpruceSensor;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class MoistureSensorSmartCallback_Stub implements MoistureSensorSmartCallback {
+
+       private int objectId = 6;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       
+
+       public MoistureSensorSmartCallback_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public MoistureSensorSmartCallback_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+       }
+
+       public void newReadingAvailable(int sensorId, float moisture, long timeStampOfLastReading) {
+               int methodId = 0;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] { int.class, float.class, long.class };
+               Object[] paramObj = new Object[] { sensorId, moisture, timeStampOfLastReading };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+       }
+
+}
index 47e2bc0..2906135 100644 (file)
@@ -4,33 +4,65 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class MoistureSensor_Skeleton implements MoistureSensor {
 
        private MoistureSensor mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private int objIdCnt = 0;
-       private IoTRMICall rmiCall;
-       private int[] ports;
-
-       private final static int object0Id = 0; //MoistureSensorSmart
-       private static Integer[] object0Permission = { 2, 4, 5, 1, 3, 0 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 5;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object5Permission = { 2, 4, 5, 1, 3, 0 };
+       private static List<Integer> set5Allowed;
        
 
-       public MoistureSensor_Skeleton(MoistureSensor _mainObj, String _callbackAddress, int _port) throws Exception {
+       public MoistureSensor_Skeleton(MoistureSensor _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set5Allowed = new ArrayList<Integer>(Arrays.asList(object5Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public MoistureSensor_Skeleton(MoistureSensor _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               set0Allowed.add(-9998);
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set5Allowed = new ArrayList<Integer>(Arrays.asList(object5Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
        }
 
        public void init() {
@@ -57,51 +89,62 @@ public class MoistureSensor_Skeleton implements MoistureSensor {
                mainObj.registerCallback(_callbackTo);
        }
 
-       public void ___regCB() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
-               ports = (int[]) paramObj[0];
-               rmiCall = new IoTRMICall(ports[0], (String) paramObj[1], (int) paramObj[2]);
-       }
-
        public void ___init() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                init();
        }
 
        public void ___getMoisture() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getMoisture();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getTimestampOfLastReading() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getTimestampOfLastReading();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___setId() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int.class }, new Class<?>[] { null }, localMethodBytes);
                setId((int) paramObj[0]);
        }
 
        public void ___getId() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getId();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___registerCallback() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int[].class }, new Class<?>[] { null }, localMethodBytes);
                try {
-                       MoistureSensorSmartCallback stub0 = new MoistureSensorSmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
-                       objIdCnt++;
+                       int[] stubIdArray0 = (int[]) paramObj[0];
+                       int objIdRecv0 = stubIdArray0[0];
+                       MoistureSensorSmartCallback newStub0 = null;
+                       if(!IoTRMIUtil.mapStub.containsKey(objIdRecv0)) {
+                               newStub0 = new MoistureSensorSmartCallback_Stub(rmiComm, objIdRecv0);
+                               IoTRMIUtil.mapStub.put(objIdRecv0, newStub0);
+                               rmiComm.setObjectIdCounter(objIdRecv0);
+                               rmiComm.decrementObjectIdCounter();
+                       }
+                       else {
+                               newStub0 = (MoistureSensorSmartCallback_Stub) IoTRMIUtil.mapStub.get(objIdRecv0);
+                       }
+                       MoistureSensorSmartCallback stub0 = newStub0;
                        registerCallback(stub0);
                } catch(Exception ex) {
                        ex.printStackTrace();
@@ -109,27 +152,97 @@ public class MoistureSensor_Skeleton implements MoistureSensor {
                }
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set5Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
-                               case 0: ___init(); break;
-                               case 1: ___getMoisture(); break;
-                               case 2: ___getTimestampOfLastReading(); break;
-                               case 3: ___setId(); break;
-                               case 4: ___getId(); break;
-                               case 5: ___registerCallback(); break;
-                               case -9998: ___regCB(); break;
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___init();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 1:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getMoisture();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 2:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getTimestampOfLastReading();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 3:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___setId();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 4:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getId();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 5:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___registerCallback();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
                                default: 
                                throw new Error("Method Id " + methodId + " not recognized!");
                        }
diff --git a/benchmarks/drivers/Java/WaterLeakSensor/SmartthingsSensorSmartCallback_CallbackStub.java b/benchmarks/drivers/Java/WaterLeakSensor/SmartthingsSensorSmartCallback_CallbackStub.java
deleted file mode 100644 (file)
index ac06a99..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package iotcode.WaterLeakSensor;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class SmartthingsSensorSmartCallback_CallbackStub implements SmartthingsSensorSmartCallback {
-
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private int objectId = 0;
-       
-
-       public SmartthingsSensorSmartCallback_CallbackStub(IoTRMICall _rmiCall, String _callbackAddress, int _objectId, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               objectId = _objectId;
-               rmiCall = _rmiCall;
-               ports = _ports;
-       }
-
-       public void newReadingAvailable(int _sensorId, int _value, boolean _activeValue) {
-               int methodId = 0;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { int.class, int.class, boolean.class };
-               Object[] paramObj = new Object[] { _sensorId, _value, _activeValue };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-}
diff --git a/benchmarks/drivers/Java/WaterLeakSensor/SmartthingsSensorSmartCallback_Stub.java b/benchmarks/drivers/Java/WaterLeakSensor/SmartthingsSensorSmartCallback_Stub.java
new file mode 100644 (file)
index 0000000..73ebd60
--- /dev/null
@@ -0,0 +1,47 @@
+package iotcode.WaterLeakSensor;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class SmartthingsSensorSmartCallback_Stub implements SmartthingsSensorSmartCallback {
+
+       private int objectId = 3;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       
+
+       public SmartthingsSensorSmartCallback_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public SmartthingsSensorSmartCallback_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+       }
+
+       public void newReadingAvailable(int _sensorId, int _value, boolean _activeValue) {
+               int methodId = 0;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] { int.class, int.class, boolean.class };
+               Object[] paramObj = new Object[] { _sensorId, _value, _activeValue };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+       }
+
+}
index e52f126..62cf61c 100644 (file)
@@ -4,33 +4,65 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
 
        private SmartthingsSensor mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private int objIdCnt = 0;
-       private IoTRMICall rmiCall;
-       private int[] ports;
-
-       private final static int object0Id = 0; //SmartthingsSensorSmart
-       private static Integer[] object0Permission = { 3, 2, 5, 6, 1, 4, 0 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 2;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object2Permission = { 3, 2, 5, 6, 1, 4, 0 };
+       private static List<Integer> set2Allowed;
        
 
-       public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, String _callbackAddress, int _port) throws Exception {
+       public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set2Allowed = new ArrayList<Integer>(Arrays.asList(object2Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               set0Allowed.add(-9998);
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set2Allowed = new ArrayList<Integer>(Arrays.asList(object2Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
        }
 
        public void init() {
@@ -61,58 +93,70 @@ public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
                mainObj.registerCallback(_callbackTo);
        }
 
-       public void ___regCB() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
-               ports = (int[]) paramObj[0];
-               rmiCall = new IoTRMICall(ports[0], (String) paramObj[1], (int) paramObj[2]);
-       }
-
        public void ___init() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                init();
        }
 
        public void ___getValue() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getValue();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___isActiveValue() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = isActiveValue();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getTimestampOfLastReading() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getTimestampOfLastReading();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___setId() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int.class }, new Class<?>[] { null }, localMethodBytes);
                setId((int) paramObj[0]);
        }
 
        public void ___getId() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getId();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___registerCallback() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int[].class }, new Class<?>[] { null }, localMethodBytes);
                try {
-                       SmartthingsSensorSmartCallback stub0 = new SmartthingsSensorSmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
-                       objIdCnt++;
+                       int[] stubIdArray0 = (int[]) paramObj[0];
+                       int objIdRecv0 = stubIdArray0[0];
+                       SmartthingsSensorSmartCallback newStub0 = null;
+                       if(!IoTRMIUtil.mapStub.containsKey(objIdRecv0)) {
+                               newStub0 = new SmartthingsSensorSmartCallback_Stub(rmiComm, objIdRecv0);
+                               IoTRMIUtil.mapStub.put(objIdRecv0, newStub0);
+                               rmiComm.setObjectIdCounter(objIdRecv0);
+                               rmiComm.decrementObjectIdCounter();
+                       }
+                       else {
+                               newStub0 = (SmartthingsSensorSmartCallback_Stub) IoTRMIUtil.mapStub.get(objIdRecv0);
+                       }
+                       SmartthingsSensorSmartCallback stub0 = newStub0;
                        registerCallback(stub0);
                } catch(Exception ex) {
                        ex.printStackTrace();
@@ -120,28 +164,109 @@ public class SmartthingsSensor_Skeleton implements SmartthingsSensor {
                }
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set2Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
-                               case 0: ___init(); break;
-                               case 1: ___getValue(); break;
-                               case 2: ___isActiveValue(); break;
-                               case 3: ___getTimestampOfLastReading(); break;
-                               case 4: ___setId(); break;
-                               case 5: ___getId(); break;
-                               case 6: ___registerCallback(); break;
-                               case -9998: ___regCB(); break;
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___init();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 1:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getValue();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 2:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___isActiveValue();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 3:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getTimestampOfLastReading();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 4:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___setId();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 5:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getId();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 6:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___registerCallback();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
                                default: 
                                throw new Error("Method Id " + methodId + " not recognized!");
                        }
diff --git a/benchmarks/drivers/Java/WeatherPhoneGateway/WeatherGatewaySmartCallback_CallbackStub.java b/benchmarks/drivers/Java/WeatherPhoneGateway/WeatherGatewaySmartCallback_CallbackStub.java
deleted file mode 100644 (file)
index 213d287..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package iotcode.WeatherPhoneGateway;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
-
-import iotcode.interfaces.*;
-
-public class WeatherGatewaySmartCallback_CallbackStub implements WeatherGatewaySmartCallback {
-
-       private IoTRMICall rmiCall;
-       private String callbackAddress;
-       private int[] ports;
-
-       private int objectId = 0;
-       
-
-       public WeatherGatewaySmartCallback_CallbackStub(IoTRMICall _rmiCall, String _callbackAddress, int _objectId, int[] _ports) throws Exception {
-               callbackAddress = _callbackAddress;
-               objectId = _objectId;
-               rmiCall = _rmiCall;
-               ports = _ports;
-       }
-
-       public void informationRetrieved(double _inchesPerWeek, int _weatherZipCode, int _daysToWaterOn, double _inchesPerMinute) {
-               int methodId = 0;
-               Class<?> retType = void.class;
-               Class<?>[] paramCls = new Class<?>[] { double.class, int.class, int.class, double.class };
-               Object[] paramObj = new Object[] { _inchesPerWeek, _weatherZipCode, _daysToWaterOn, _inchesPerMinute };
-               rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
-       }
-
-}
diff --git a/benchmarks/drivers/Java/WeatherPhoneGateway/WeatherGatewaySmartCallback_Stub.java b/benchmarks/drivers/Java/WeatherPhoneGateway/WeatherGatewaySmartCallback_Stub.java
new file mode 100644 (file)
index 0000000..77b5b4b
--- /dev/null
@@ -0,0 +1,47 @@
+package iotcode.WeatherPhoneGateway;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
+
+import iotcode.interfaces.*;
+
+public class WeatherGatewaySmartCallback_Stub implements WeatherGatewaySmartCallback {
+
+       private int objectId = 4;
+       private IoTRMIComm rmiComm;
+       // Synchronization variables
+       
+
+       public WeatherGatewaySmartCallback_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
+               if (_localPortSend != 0 && _localPortRecv != 0) {
+                       rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
+               } else
+               {
+                       rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
+               }
+               IoTRMIUtil.mapStub.put(objectId, this);
+       }
+
+       public WeatherGatewaySmartCallback_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+       }
+
+       public void informationRetrieved(double _inchesPerWeek, int _weatherZipCode, int _daysToWaterOn, double _inchesPerMinute) {
+               int methodId = 0;
+               Class<?> retType = void.class;
+               Class<?>[] paramCls = new Class<?>[] { double.class, int.class, int.class, double.class };
+               Object[] paramObj = new Object[] { _inchesPerWeek, _weatherZipCode, _daysToWaterOn, _inchesPerMinute };
+               rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
+       }
+
+}
index afb488a..3a472bf 100644 (file)
@@ -4,33 +4,65 @@ import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import iotrmi.Java.IoTRMICall;
-import iotrmi.Java.IoTRMIObject;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import iotrmi.Java.IoTRMIComm;
+import iotrmi.Java.IoTRMICommClient;
+import iotrmi.Java.IoTRMICommServer;
+import iotrmi.Java.IoTRMIUtil;
 
 import iotcode.interfaces.*;
 
 public class WeatherGateway_Skeleton implements WeatherGateway {
 
        private WeatherGateway mainObj;
-       private IoTRMIObject rmiObj;
-
-       private String callbackAddress;
-       private int objIdCnt = 0;
-       private IoTRMICall rmiCall;
-       private int[] ports;
-
-       private final static int object0Id = 0; //WeatherGatewaySmart
-       private static Integer[] object0Permission = { 3, 6, 5, 7, 2, 1, 0, 4 };
-       private static List<Integer> set0Allowed;
+       private int objectId = 3;
+       // Communications and synchronizations
+       private IoTRMIComm rmiComm;
+       private AtomicBoolean didAlreadyInitWaitInvoke;
+       private AtomicBoolean methodReceived;
+       private byte[] methodBytes = null;
+       // Permissions
+       private static Integer[] object3Permission = { 3, 6, 5, 7, 2, 1, 0, 4 };
+       private static List<Integer> set3Allowed;
        
 
-       public WeatherGateway_Skeleton(WeatherGateway _mainObj, String _callbackAddress, int _port) throws Exception {
+       public WeatherGateway_Skeleton(WeatherGateway _mainObj, int _portSend, int _portRecv) throws Exception {
+               mainObj = _mainObj;
+               rmiComm = new IoTRMICommServer(_portSend, _portRecv);
+               set3Allowed = new ArrayList<Integer>(Arrays.asList(object3Permission));
+               IoTRMIUtil.mapSkel.put(_mainObj, this);
+               IoTRMIUtil.mapSkelId.put(_mainObj, objectId);
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+               Thread thread1 = new Thread() {
+                       public void run() {
+                               try {
+                                       ___waitRequestInvokeMethod();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ex.printStackTrace();
+                               }
+                       }
+               };
+               thread1.start();
+       }
+
+       public WeatherGateway_Skeleton(WeatherGateway _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception {
                mainObj = _mainObj;
-               callbackAddress = _callbackAddress;
-               rmiObj = new IoTRMIObject(_port);
-               set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
-               set0Allowed.add(-9998);
-               ___waitRequestInvokeMethod();
+               rmiComm = _rmiComm;
+               objectId = _objectId;
+               set3Allowed = new ArrayList<Integer>(Arrays.asList(object3Permission));
+               didAlreadyInitWaitInvoke = new AtomicBoolean(false);
+               methodReceived = new AtomicBoolean(false);
+               rmiComm.registerSkeleton(objectId, methodReceived);
+       }
+
+       public boolean didAlreadyInitWaitInvoke() {
+               return didAlreadyInitWaitInvoke.get();
        }
 
        public void init() {
@@ -65,64 +97,77 @@ public class WeatherGateway_Skeleton implements WeatherGateway {
                mainObj.registerCallback(_callbackTo);
        }
 
-       public void ___regCB() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
-               ports = (int[]) paramObj[0];
-               rmiCall = new IoTRMICall(ports[0], (String) paramObj[1], (int) paramObj[2]);
-       }
-
        public void ___init() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                init();
        }
 
        public void ___start() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                start();
        }
 
        public void ___stop() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                stop();
        }
 
        public void ___getInchesPerWeek() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getInchesPerWeek();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getWeatherZipCode() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getWeatherZipCode();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getDaysToWaterOn() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getDaysToWaterOn();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___getInchesPerMinute() throws IOException {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] {  }, 
-               new Class<?>[] {  });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] {  }, new Class<?>[] {  }, localMethodBytes);
                Object retObj = getInchesPerMinute();
-               rmiObj.sendReturnObj(retObj);
+               rmiComm.sendReturnObj(retObj, localMethodBytes);
        }
 
        public void ___registerCallback() {
-               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-               new Class<?>[] { null });
+               byte[] localMethodBytes = methodBytes;
+               rmiComm.setGetMethodBytes();
+               Object[] paramObj = rmiComm.getMethodParams(new Class<?>[] { int[].class }, new Class<?>[] { null }, localMethodBytes);
                try {
-                       WeatherGatewaySmartCallback stub0 = new WeatherGatewaySmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
-                       objIdCnt++;
+                       int[] stubIdArray0 = (int[]) paramObj[0];
+                       int objIdRecv0 = stubIdArray0[0];
+                       WeatherGatewaySmartCallback newStub0 = null;
+                       if(!IoTRMIUtil.mapStub.containsKey(objIdRecv0)) {
+                               newStub0 = new WeatherGatewaySmartCallback_Stub(rmiComm, objIdRecv0);
+                               IoTRMIUtil.mapStub.put(objIdRecv0, newStub0);
+                               rmiComm.setObjectIdCounter(objIdRecv0);
+                               rmiComm.decrementObjectIdCounter();
+                       }
+                       else {
+                               newStub0 = (WeatherGatewaySmartCallback_Stub) IoTRMIUtil.mapStub.get(objIdRecv0);
+                       }
+                       WeatherGatewaySmartCallback stub0 = newStub0;
                        registerCallback(stub0);
                } catch(Exception ex) {
                        ex.printStackTrace();
@@ -130,29 +175,121 @@ public class WeatherGateway_Skeleton implements WeatherGateway {
                }
        }
 
-       private void ___waitRequestInvokeMethod() throws IOException {
+       public void ___waitRequestInvokeMethod() throws IOException {
+               didAlreadyInitWaitInvoke.compareAndSet(false, true);
                while (true) {
-                       rmiObj.getMethodBytes();
-                       int _objectId = rmiObj.getObjectId();
-                       int methodId = rmiObj.getMethodId();
-                       if (_objectId == object0Id) {
-                               if (!set0Allowed.contains(methodId)) {
+                       if (!methodReceived.get()) {
+                               continue;
+                       }
+                       methodBytes = rmiComm.getMethodBytes();
+                       methodReceived.set(false);
+                       int _objectId = IoTRMIComm.getObjectId(methodBytes);
+                       int methodId = IoTRMIComm.getMethodId(methodBytes);
+                       if (_objectId == objectId) {
+                               if (!set3Allowed.contains(methodId)) {
                                        throw new Error("Object with object Id: " + _objectId + "  is not allowed to access method: " + methodId);
                                }
                        }
                        else {
-                               throw new Error("Object Id: " + _objectId + " not recognized!");
+                               continue;
                        }
                        switch (methodId) {
-                               case 0: ___init(); break;
-                               case 1: ___start(); break;
-                               case 2: ___stop(); break;
-                               case 3: ___getInchesPerWeek(); break;
-                               case 4: ___getWeatherZipCode(); break;
-                               case 5: ___getDaysToWaterOn(); break;
-                               case 6: ___getInchesPerMinute(); break;
-                               case 7: ___registerCallback(); break;
-                               case -9998: ___regCB(); break;
+                               case 0:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___init();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 1:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___start();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 2:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___stop();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 3:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getInchesPerWeek();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 4:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getWeatherZipCode();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 5:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getDaysToWaterOn();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 6:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___getInchesPerMinute();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
+                               case 7:
+                               new Thread() {
+                                       public void run() {
+                                               try {
+                                                       ___registerCallback();
+                                               }
+                                               catch (Exception ex) {
+                                                       ex.printStackTrace();
+                                               }
+                                       }
+                               }.start();
+                               break;
                                default: 
                                throw new Error("Method Id " + methodId + " not recognized!");
                        }
index 93ba52c..0fda646 100644 (file)
@@ -28,12 +28,7 @@ run-compiler-dev:
        cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler testclasspolicy_callbacks.pol testclassrequires_callbacks.pol callbackpolicy.pol callbackrequires.pol -cplus Cplus -java Java
        #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler testclasspolicy_callbacks_three.pol testclassrequires_callbacks_three.pol callbackpolicy.pol callbackrequires.pol callbackpolicy_two.pol callbackrequires_two.pol -cplus Cplus -java Java
 
-PHONY += run-compiler-smartlight
-run-compiler-smartlight:
-       cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/
-       cp ../localconfig/iotpolicy/LifxLightBulb/*.req $(BIN_DIR)/iotpolicy/
-       cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol smartlightsbulb.req amcrestcamera.pol smartlightscam.req motiondetection.pol motiondetection.req room.pol roomsmart.req -java Java
-       
+
 PHONY += run-compiler-lbtest
 run-compiler-lbtest:
        cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/
@@ -42,6 +37,12 @@ run-compiler-lbtest:
        cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol lifxtest.req -cplus Cplus
 
 # SmartLightsController
+PHONY += run-compiler-smartlight
+run-compiler-smartlight:
+       cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/
+       cp ../localconfig/iotpolicy/LifxLightBulb/*.req $(BIN_DIR)/iotpolicy/
+       cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol smartlightsbulb.req amcrestcamera.pol smartlightscam.req motiondetection.pol motiondetection.req room.pol roomsmart.req -java Java
+
 PHONY += run-compiler-lifx
 run-compiler-lifx:
        cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/
@@ -63,6 +64,12 @@ run-compiler-cam:
        cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler amcrestcamera.pol smartlightscam.req motiondetection.pol motiondetection.req -java Java
 
 # IrrigationController
+PHONY += run-compiler-irrigation
+run-compiler-irrigation:
+       cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/
+       cp ../localconfig/iotpolicy/LifxLightBulb/*.req $(BIN_DIR)/iotpolicy/
+       cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler greenlawn.pol smartlawn.req espsprinkler.pol smartsprinkler.req  weatherphonegateway.pol smartweathergateway.req weathergatewaycallback.pol smartweathergatewaycallback.req sprucesensor.pol smartsensor.req moisturesensorcallback.pol moisturesensorcallback.req -java Java
+
 PHONY += run-compiler-lawn
 run-compiler-lawn:
        cp ../localconfig/iotpolicy/GreenLawn/*.pol $(BIN_DIR)/iotpolicy/
@@ -88,6 +95,12 @@ run-compiler-moist:
        cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler sprucesensor.pol smartsensor.req moisturesensorcallback.pol moisturesensorcallback.req -java Java
 
 # SpeakerController
+PHONY += run-compiler-speaker
+run-compiler-speaker:
+       cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/
+       cp ../localconfig/iotpolicy/LifxLightBulb/*.req $(BIN_DIR)/iotpolicy/
+       cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler ihome.pol smartspeaker.req speakercallback.pol smartspeakercallback.req gpsphonegateway.pol smartgpsgateway.req gpsgatewaycallback.pol smartgpsgatewaycallback.req -java Java
+
 PHONY += run-compiler-spkr
 run-compiler-spkr:
        cp ../localconfig/iotpolicy/IHome/*.pol $(BIN_DIR)/iotpolicy/
@@ -101,6 +114,12 @@ run-compiler-ggw:
        cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler gpsphonegateway.pol smartgpsgateway.req gpsgatewaycallback.pol smartgpsgatewaycallback.req -java Java
 
 # HomeSecurityController
+PHONY += run-compiler-homesec
+run-compiler-homesec:
+       cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/
+       cp ../localconfig/iotpolicy/LifxLightBulb/*.req $(BIN_DIR)/iotpolicy/
+       cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler espalarm.pol smartalarm.req smartthingssensor.pol smartthingssensor.req smartthingssensorcallback.pol smartthingssensorcallback.req -java Java
+
 PHONY += run-compiler-alarm
 run-compiler-alarm:
        cp ../localconfig/iotpolicy/EspAlarm/*.pol $(BIN_DIR)/iotpolicy/
index 70b25d3..b899280 100644 (file)
@@ -21,7 +21,8 @@ ROUTER_ADD=192.168.2.1
 MONITORING_HOST=74:da:38:68:72:8a
 
 #Zigbee gateway information
-ZIGBEE_GATEWAY_ADDRESS=c0:4a:00:10:9c:b3
+#ZIGBEE_GATEWAY_ADDRESS=c0:4a:00:10:9c:b3
+ZIGBEE_GATEWAY_ADDRESS=74:da:38:0d:05:56
 ZIGBEE_GATEWAY_PORT=5005
 ZIGBEE_IOTMASTER_PORT=12345