-
- /**
- * Method getCallbackPort()
- * <p>
- * Get a new port 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 int[] getCallbackPorts(int numOfPorts) {
-
- int[] ports = new int[numOfPorts];
-
- 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]);
- }
-
- return ports;
- }
-
-
- /**
- * 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;
- }
-
-