Class PortFinder
java.lang.Object
org.codice.ddf.test.common.configurators.PortFinder
- All Implemented Interfaces:
Closeable,AutoCloseable
Class used to find and reserve a range of ports, and assign ports within that range by name. For
instance, creating a new instance of
PortFinder will reserve a block of ports, calling
getPort(String) or getPortAsString(String) the first time will assign a
specific port in that range with the name provided, and calling one of those two methods with
that name will return the same port number afterwards.-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
PortFinder
public PortFinder()Default constructor. Finds and reserves a range of ports.
-
-
Method Details
-
getPort
Gets the port number associated with the key provided. Assigns a new port number if the key couldn't be found.- Parameters:
portKey- key of the port to look up- Returns:
- port number associated with the key provided
-
getPortAsString
Gets the port number associated with the key provided as a string. Assigns a new port number if the key couldn't be found.- Parameters:
portKey- key of the port to look up- Returns:
- port number associated with the key provided
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-