* @version 1.0
* @since 2016-06-16
*/
-public class IoTSlave {
+public final class IoTSlave {
/**
* IoTSlave class properties
FileInputStream fis = new FileInputStream(file);
prop.load(fis);
} catch (IOException ex) {
- System.out.println("IoTMaster: Error reading config file: " + strCfgFileName);
+ RuntimeOutput.print("IoTMaster: Error reading config file: " + strCfgFileName, BOOL_VERBOSE);
ex.printStackTrace();
}
- System.out.println("IoTMaster: Extracting information from config file: " + strCfgFileName);
+ RuntimeOutput.print("IoTMaster: Extracting information from config file: " + strCfgFileName, BOOL_VERBOSE);
// Initialize constants from config file
STR_JAR_FILE_PATH = prop.getProperty("JAR_FILE_PATH");
STR_OBJ_CLS_PFX = prop.getProperty("OBJECT_CLASS_PREFIX");
CAPAB_BASED_RMI = true;
}
- System.out.println("JAR_FILE_PATH=" + STR_JAR_FILE_PATH);
- System.out.println("OBJECT_CLASS_PREFIX=" + STR_OBJ_CLS_PFX);
- System.out.println("INTERFACE_PREFIX=" + STR_INTERFACE_PFX);
- System.out.println("SKEL_CLASS_SUFFIX=" + SKEL_CLASS_SUFFIX);
- System.out.println("STUB_CLASS_SUFFIX=" + STUB_CLASS_SUFFIX);
- System.out.println("CAPAB_BASED_RMI=" + CAPAB_BASED_RMI);
- System.out.println("IoTMaster: Information extracted successfully!");
+ RuntimeOutput.print("JAR_FILE_PATH=" + STR_JAR_FILE_PATH, BOOL_VERBOSE);
+ RuntimeOutput.print("OBJECT_CLASS_PREFIX=" + STR_OBJ_CLS_PFX, BOOL_VERBOSE);
+ RuntimeOutput.print("INTERFACE_PREFIX=" + STR_INTERFACE_PFX, BOOL_VERBOSE);
+ RuntimeOutput.print("SKEL_CLASS_SUFFIX=" + SKEL_CLASS_SUFFIX, BOOL_VERBOSE);
+ RuntimeOutput.print("STUB_CLASS_SUFFIX=" + STUB_CLASS_SUFFIX, BOOL_VERBOSE);
+ RuntimeOutput.print("CAPAB_BASED_RMI=" + CAPAB_BASED_RMI, BOOL_VERBOSE);
+ RuntimeOutput.print("IoTMaster: Information extracted successfully!", BOOL_VERBOSE);
}
/**
private void createCapabBasedRMIJava(MessageCreateObject sMessage) throws
ClassNotFoundException, NoSuchMethodException, UnknownHostException {
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: Create capab based RMI here!");
- System.out.println("DEBUG: sMessage host address: " + sMessage.getHostAddress());
- System.out.println("DEBUG: sMessage object class: " + sMessage.getObjectClass());
- System.out.println("DEBUG: sMessage object name: " + sMessage.getObjectName());
- System.out.println("DEBUG: sMessage interface name: " + sMessage.getObjectInterfaceName());
- System.out.println("DEBUG: sMessage reg port: " + sMessage.getRMIRegPort());
- System.out.println("DEBUG: sMessage stub port: " + sMessage.getRMIStubPort());
- System.out.println("DEBUG: sMessage object fields: " + Arrays.toString(sMessage.getObjectFields()));
- System.out.println("DEBUG: sMessage object fields: " + Arrays.toString(sMessage.getObjectFldCls()));
- System.out.println("\n\n");
-
// Instantiate the skeleton and put in the object
String strObjSkelName = STR_OBJ_CLS_PFX + "." + sMessage.getObjectClass() +
"." + sMessage.getObjectInterfaceName() + SKEL_CLASS_SUFFIX;
RemoteException, AlreadyBoundException, IllegalAccessException,
InvocationTargetException {
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: CREATE DRIVER OBJECT!!!\n\n");
-
// Translating into the actual Message class
MessageCreateObject sMessage = (MessageCreateObject) sIoTMasterMsg;
// Instantiate object using reflection
// Translating into the actual Message class
MessageCreateMainObject sMessage = (MessageCreateMainObject) sIoTMasterMsg;
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: CREATE MAIN OBJECT!!!");
- System.out.println("DEBUG: sMessage object name: " + sMessage.getObjectName());
-
// Getting controller class
File file = new File(STR_JAR_FILE_PATH + sMessage.getObjectName() + STR_JAR_FILE_EXT);
RuntimeOutput.print("IoTSlave: DEBUG print path: " + STR_JAR_FILE_PATH +
// Translating into the actual Message class
MessageCreateSetRelation sMessage = (MessageCreateSetRelation) sIoTMasterMsg;
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: CREATE NEW IOT SET!!!");
- System.out.println("DEBUG: sMessage object field name: " + sMessage.getObjectFieldName());
-
// Initialize field name
strFieldName = sMessage.getObjectFieldName();
RuntimeOutput.print("IoTSlave: Setting up field " + strFieldName, BOOL_VERBOSE);
// Translating into the actual Message class
MessageCreateSetRelation sMessage = (MessageCreateSetRelation) sIoTMasterMsg;
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: CREATE NEW IOT RELATION!!!");
- System.out.println("DEBUG: sMessage object field name: " + sMessage.getObjectFieldName());
-
// Initialize field name
strFieldName = sMessage.getObjectFieldName();
RuntimeOutput.print("IoTSlave: Setting up field " + strFieldName, BOOL_VERBOSE);
// Translating into the actual Message class
MessageGetObject sMessage = (MessageGetObject) sIoTMasterMsg;
-
- System.out.println("DEBUG: sMessage host address: " + sMessage.getHostAddress());
- System.out.println("DEBUG: sMessage object class: " + sMessage.getObjectClass());
- System.out.println("DEBUG: sMessage object name: " + sMessage.getObjectName());
- System.out.println("DEBUG: sMessage interface name: " + sMessage.getObjectInterfaceName());
- System.out.println("DEBUG: sMessage reg port: " + sMessage.getRMIRegPort());
- System.out.println("DEBUG: sMessage stub port: " + sMessage.getRMIStubPort());
- System.out.println("DEBUG: sMessage callback ports: " + Arrays.toString(sMessage.getRMICallbackPorts()));
- System.out.println("\n\n");
-
Object stubObjConv = null;
String strObjectName = sMessage.getObjectName();
String strObjClassInterfaceName = STR_OBJ_CLS_PFX + "." + STR_INTERFACE_PFX + "." +
private void getIoTSetObject() throws IOException,
ClassNotFoundException, RemoteException, NotBoundException, NoSuchMethodException,
InstantiationException, IllegalAccessException, InvocationTargetException {
-
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: GET IOT SET OBJECT!!!");
-
Object objRegistry = null;
if (CAPAB_BASED_RMI)
objRegistry = getObjectFromStub();
private void getIoTRelationFirstObject() throws IOException,
ClassNotFoundException, RemoteException, NotBoundException, NoSuchMethodException,
InstantiationException, IllegalAccessException, InvocationTargetException {
-
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: GET IOT RELATION FIRST OBJECT!!!");
-
Object objRegistry = null;
if (CAPAB_BASED_RMI)
objRegistry = getObjectFromStub();
private void getIoTRelationSecondObject() throws IOException,
ClassNotFoundException, RemoteException, NotBoundException, NoSuchMethodException,
InstantiationException, IllegalAccessException, InvocationTargetException {
-
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: GET IOT RELATION SECOND OBJECT!!!");
-
Object objRegistry = null;
if (CAPAB_BASED_RMI)
objRegistry = getObjectFromStub();
// Reinitialize IoTSet field after getting all the objects
iotsetObject = new IoTSet<Object>(isetObject.values());
-
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: REINITIALIZE IOT SET FIELD!!!");
- System.out.println("DEBUG: Field name: " + strFieldName + "\n\n");
-
// Private fields need getDeclaredField(), while public fields use getField()
Field fld = clsMain.getDeclaredField(strFieldName);
boolean bAccess = fld.isAccessible();
// Reinitialize IoTSet field after getting all the objects
iotrelObject = new IoTRelation<Object,Object>(irelObject.relationMap(), irelObject.size());
-
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: REINITIALIZE IOT RELATION FIELD!!!");
- System.out.println("DEBUG: Field name: " + strFieldName + "\n\n");
-
// Private fields need getDeclaredField(), while public fields use getField()
Field fld = clsMain.getDeclaredField(strFieldName);
boolean bAccess = fld.isAccessible();
// Translating into the actual Message class
MessageGetDeviceObject sMessage = (MessageGetDeviceObject) sIoTMasterMsg;
-
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: GET DEVICE IOT SET OBJECT!!!");
- System.out.println("DEBUG: sMessage host address: " + sMessage.getHostAddress());
- System.out.println("DEBUG: sMessage source port: " + sMessage.getSourceDeviceDriverPort());
- System.out.println("DEBUG: sMessage destination port: " + sMessage.getDestinationDeviceDriverPort());
- System.out.println("DEBUG: sMessage source wild card: " + sMessage.isSourcePortWildCard());
- System.out.println("DEBUG: sMessage desination wild card: " + sMessage.isDestinationPortWildCard() + "\n\n");
-
// Get IoTSet objects for IP address set on device driver/controller
IoTDeviceAddress objDeviceAddress = new IoTDeviceAddress(sMessage.getHostAddress(),
sMessage.getSourceDeviceDriverPort(),
// Translating into the actual Message class
MessageGetSimpleDeviceObject sMessage = (MessageGetSimpleDeviceObject) sIoTMasterMsg;
-
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: GET ZIGBEE DEVICE IOT SET OBJECT!!!");
- System.out.println("DEBUG: sMessage host address: " + sMessage.getHostAddress() + "\n\n");
-
// Get IoTSet objects for IP address set on device driver/controller
IoTZigbeeAddress objZBDevAddress = new IoTZigbeeAddress(sMessage.getHostAddress());
RuntimeOutput.print("IoTSlave: Device address transferred: " + sMessage.getHostAddress(), BOOL_VERBOSE);
// Translating into the actual Message class
MessageGetSimpleDeviceObject sMessage = (MessageGetSimpleDeviceObject) sIoTMasterMsg;
-
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: GET ADD IOT SET OBJECT!!!");
- System.out.println("DEBUG: sMessage host address: " + sMessage.getHostAddress() + "\n\n");
-
// Get IoTSet objects for IP address set on device driver/controller
IoTAddress objAddress = new IoTAddress(sMessage.getHostAddress());
RuntimeOutput.print("IoTSlave: Address transferred: " + sMessage.getHostAddress(), BOOL_VERBOSE);
*/
private void invokeInitMethod() throws IOException {
- // TODO: DEBUG
- System.out.println("\n\nDEBUG: INVOKE INIT METHOD!!!\n\n");
-
new Thread() {
public void run() {
try {
inStream.close();
socket.close();
RuntimeOutput.print("IoTSlave: Closing!", BOOL_VERBOSE);
- // We have to continuously loop because we are preserving our stubs and skeletons
- //while(true) { }
} catch (IOException |
ClassNotFoundException |