+ private void initializeSetsAndRelationsJava(ObjectInputStream inStream, ObjectOutputStream outStream)
+ throws IOException, ClassNotFoundException {
+ // Get list of fields
+ List<String> strFields = objInitHand.getListOfFields();
+ // Iterate on HostAddress
+ for(String str : strFields) {
+ IoTCommCode iotcommMsg = objInitHand.getFieldMessage(str);
+ if (iotcommMsg == IoTCommCode.CREATE_NEW_IOTSET) {
+ // == COMMUNICATION WITH IOTSLAVE CONTROLLER TO CREATE IOTSET
+ Message msgCrtIoTSet = new MessageCreateSetRelation(IoTCommCode.CREATE_NEW_IOTSET, str);
+ commMasterToSlave(msgCrtIoTSet, "Create new IoTSet!", inStream, outStream);
+ List<ObjectInitInfo> listObject = objInitHand.getListObjectInitInfo(str);
+ for (ObjectInitInfo objInitInfo : listObject) {
+ // == COMMUNICATION WITH IOTSLAVE CONTROLLER TO FILL IN IOTSET
+ commMasterToSlave(new MessageGetObject(IoTCommCode.GET_IOTSET_OBJECT, objInitInfo.getIoTSlaveObjectHostAdd(),
+ objInitInfo.getObjectName(), objInitInfo.getObjectClassName(), objInitInfo.getObjectClassInterfaceName(),
+ objInitInfo.getObjectStubClassInterfaceName(), objInitInfo.getRMIRegistryPort(), objInitInfo.getRMIStubPort(),
+ objInitInfo.getRMICallbackPorts()), "Get IoTSet object!", inStream, outStream);
+
+ }
+ // == COMMUNICATION WITH IOTSLAVE CONTROLLER TO REINITIALIZE IOTSET FIELD
+ commMasterToSlave(new MessageSimple(IoTCommCode.REINITIALIZE_IOTSET_FIELD),
+ "Renitialize IoTSet field!", inStream, outStream);
+ } else if (iotcommMsg == IoTCommCode.CREATE_NEW_IOTRELATION) {
+ // == COMMUNICATION WITH IOTSLAVE CONTROLLER TO CREATE IOTRELATION
+ Message msgCrtIoTRel = new MessageCreateSetRelation(IoTCommCode.CREATE_NEW_IOTRELATION, str);
+ commMasterToSlave(msgCrtIoTRel, "Create new IoTRelation!", inStream, outStream);
+ List<ObjectInitInfo> listObject = objInitHand.getListObjectInitInfo(str);
+ List<ObjectInitInfo> listSecondObject = objInitHand.getSecondObjectInitInfo(str);
+ Iterator it = listSecondObject.iterator();
+ for (ObjectInitInfo objInitInfo : listObject) {
+ // == COMMUNICATION WITH IOTSLAVE CONTROLLER TO FILL IN IOTRELATION (FIRST OBJECT)
+ commMasterToSlave(new MessageGetObject(IoTCommCode.GET_IOTRELATION_FIRST_OBJECT,
+ objInitInfo.getIoTSlaveObjectHostAdd(), objInitInfo.getObjectName(), objInitInfo.getObjectClassName(),
+ objInitInfo.getObjectClassInterfaceName(), objInitInfo.getObjectStubClassInterfaceName(),
+ objInitInfo.getRMIRegistryPort(), objInitInfo.getRMIStubPort(), objInitInfo.getRMICallbackPorts()),
+ "Get IoTRelation first object!", inStream, outStream);
+ ObjectInitInfo objSecObj = (ObjectInitInfo) it.next();
+ // == COMMUNICATION WITH IOTSLAVE CONTROLLER TO FILL IN IOTRELATION (SECOND OBJECT)
+ commMasterToSlave(new MessageGetObject(IoTCommCode.GET_IOTRELATION_SECOND_OBJECT,
+ objSecObj.getIoTSlaveObjectHostAdd(), objSecObj.getObjectName(), objSecObj.getObjectClassName(),
+ objSecObj.getObjectClassInterfaceName(), objSecObj.getObjectStubClassInterfaceName(),
+ objSecObj.getRMIRegistryPort(), objSecObj.getRMIStubPort(), objSecObj.getRMICallbackPorts()),
+ "Get IoTRelation second object!", inStream, outStream);
+ }
+ // == COMMUNICATION WITH IOTSLAVE CONTROLLER TO REINITIALIZE IOTRELATION FIELD
+ commMasterToSlave(new MessageSimple(IoTCommCode.REINITIALIZE_IOTRELATION_FIELD),
+ "Renitialize IoTRelation field!", inStream, outStream);
+ }
+ }
+ }
+
+ /**
+ * A method to reinitialize IoTSet and IoTRelation in the code based on ObjectInitHandler information
+ *
+ * @params inStream ObjectInputStream communication
+ * @params outStream ObjectOutputStream communication
+ * @return void
+ */
+ private void initializeSetsAndRelationsCpp(ObjectInputStream inStream, ObjectOutputStream outStream)