Package io.fabric8.maven.docker.access
Class PortMapping
- java.lang.Object
-
- io.fabric8.maven.docker.access.PortMapping
-
public class PortMapping extends Object
Entity holding port mappings which can be set through the configuration.- Since:
- 04.04.14
- Author:
- roland
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPortMapping.PropertyWriteHelper
-
Constructor Summary
Constructors Constructor Description PortMapping(List<String> portMappings, Properties projProperties)Create the mapping from a configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>getContainerPorts()booleanneedsPropertiesUpdate()Check whether property needs updates for dynamically obtained host ports and ip adresses.com.google.gson.JsonArraytoJson()Return the content of the mapping as an array with all specifications as givenvoidupdateProperties(Map<String,Container.PortBinding> dockerObtainedDynamicBindings)Update variable-to-port mappings with dynamically obtained ports and host ips.
-
-
-
Constructor Detail
-
PortMapping
public PortMapping(List<String> portMappings, Properties projProperties)
Create the mapping from a configuration. The configuration is list of port mapping specifications which has the format used by docker for port mapping (i.e. host_ip:host_port:container_port)- The "host_ip" part is optional. If not given, the all interfaces are used
- If "host_port" is non numeric it is taken as a variable name. If this variable is given as value in
variables, this number is used as host port. If no numeric value is given, it is considered to be filled with the
real, dynamically created port value when
updateProperties(Map)is called
- Parameters:
portMappings- a list of configuration strings where each string hast the formathost_ip:host_port:container_port. If thehost-portis non-numeric it is assumed to be a variable (which later might be filled in with the dynamically created port).projProperties- project properties- Throws:
IllegalArgumentException- if the format doesn't fit
-
-
Method Detail
-
needsPropertiesUpdate
public boolean needsPropertiesUpdate()
Check whether property needs updates for dynamically obtained host ports and ip adresses.- Returns:
- true if any property are used which need to be filled in, false otherwise
-
updateProperties
public void updateProperties(Map<String,Container.PortBinding> dockerObtainedDynamicBindings)
Update variable-to-port mappings with dynamically obtained ports and host ips. This should only be called once after this dynamically allocated parts has been be obtained.- Parameters:
dockerObtainedDynamicBindings- keys are the container ports, values are the dynamically mapped host ports and host ips.
-
toJson
public com.google.gson.JsonArray toJson()
Return the content of the mapping as an array with all specifications as given- Returns:
- port mappings as JSON array or null if no mappings exist
-
-