private Map<Integer, Integer> hmRMIStubPort;
private Set<Integer> hsDevicePort;
private Set<Integer> hsCallbackPort;
+ private Map<Integer, Integer[]> hmCallbackPort;
private int iNumOfObjects;
private int iNumOfHosts;
private boolean bVerbose;
hmRMIStubPort = new HashMap<Integer, Integer>();
hsDevicePort = new HashSet<Integer>();
hsCallbackPort = new HashSet<Integer>();
+ hmCallbackPort = new HashMap<Integer, Integer[]>();
iNumOfObjects = 0;
iNumOfHosts = 0;
bVerbose = _bVerbose;
}
+ /**
+ * Method getCallbackPorts()
+ * <p>
+ * Get a set of new ports for new connections for callback objects in the program.
+ * This newly generated port number will be recorded.
+ *
+ * @return int[] A set of callback ports
+ */
+ public Integer[] getCallbackPorts(String sAObject, int numOfPorts) {
+
+ Integer[] ports = new Integer[numOfPorts];
+ int iNumOfObject = hmActiveObj.get(sAObject);
+
+ if (!hmCallbackPort.containsKey(iNumOfObject)) {
+ for(int i = 0; i < numOfPorts; i++) {
+ do {
+ ports[i] = random.nextInt(INT_MAX_PORT - INT_MIN_PORT + 1) + INT_MIN_PORT;
+ // Check port existence in HashMap
+ } while (portIsAvailable(ports[i]) == false);
+ hsCallbackPort.add(ports[i]);
+ }
+ hmCallbackPort.put(iNumOfObject, ports);
+ } else {
+ ports = hmCallbackPort.get(iNumOfObject);
+ }
+
+ return ports;
+ }
+
+
/**
* Method addDevicePort()
* <p>