Package org.kiwiproject.registry.util
Class Ports
java.lang.Object
org.kiwiproject.registry.util.Ports
Utility methods for finding a desired port out of a list of port definitions,
or finding application or admin ports.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringdetermineScheme(List<Port> ports, Port.PortType type) Determines the HTTP scheme to use for a given typefindAdminPorts(List<Port> ports) Find only the admin ports in the list of ports.findApplicationPorts(List<Port> ports) Find only the application ports in the list of ports.static PortfindFirstPortPreferSecure(List<Port> ports, Port.PortType type) Finds the first port of a given type (Application or Admin) from the list.static PortfindOnlyAdminPort(List<Port> ports) Find the single admin port.static PortfindOnlyApplicationPort(List<Port> ports) Find the single application port.static PortfindPort(List<Port> ports, Port.PortType type, Port.Security security) Finds a desired port given a security and type criteria.findPorts(List<Port> ports, Port.PortType portType) Find all ports having the specifiedPort.PortType.
-
Method Details
-
findOnlyApplicationPort
Find the single application port. If there is not exactly one, throw an exception.- Parameters:
ports- the ports to filter- Returns:
- the application port
- Throws:
IllegalStateException- if there is not exactly one port
-
findApplicationPorts
Find only the application ports in the list of ports.- Parameters:
ports- the ports to filter- Returns:
- a list of application ports
-
findOnlyAdminPort
Find the single admin port. If there is not exactly one, throw an exception.- Parameters:
ports- the ports to filter- Returns:
- the admin port
- Throws:
IllegalStateException- if there is not exactly one port
-
findAdminPorts
Find only the admin ports in the list of ports.- Parameters:
ports- the ports to filter- Returns:
- a list of application ports
-
findPorts
Find all ports having the specifiedPort.PortType.- Parameters:
ports- the ports to filterportType- the type of port to find- Returns:
- a list of ports having the specified type
-
findFirstPortPreferSecure
Finds the first port of a given type (Application or Admin) from the list. If multiple ports are found and at least one is marked secure, that port will be given priority. If multiple ports are found with the same security level, then the first one is returned.If not found, returns a new Port with number 0 and the given value for
Port.PortType.- Parameters:
ports- The list of ports to traversetype- The type of port that is being requested- Returns:
- The port definition that was found based on the given criteria
-
findPort
Finds a desired port given a security and type criteria.If not found, returns a new Port with number 0 and the given values for
Port.SecurityandPort.PortType.- Parameters:
ports- The list of ports to traversetype- The type of port that is desired (Application or Admin)security- The security of the port that is desired (Secure or Non-Secure)- Returns:
- The port definition that was found based on the given criteria
-
determineScheme
Determines the HTTP scheme to use for a given type- Parameters:
ports- The list of ports to traverse to determine the schemetype- The type of port that is desired (Application or Admin)- Returns:
- The scheme (https or http) based on the port definitions
- See Also:
-