String locationSpec = String.format(DockerResolver.DOCKER_HOST_MACHINE_SPEC, infrastructure.getId(), getId()) + String.format(":(name=\"%s\")", locationName);
setAttribute(LOCATION_SPEC, locationSpec);
final LocationDefinition definition = new BasicLocationDefinition(locationName, locationSpec, flags);
Location location = getManagementContext().getLocationRegistry().resolve(definition);
setAttribute(DYNAMIC_LOCATION, location);
setAttribute(LOCATION_NAME, location.getId());
if (getConfig(DockerInfrastructure.REGISTER_DOCKER_HOST_LOCATIONS)) {
getManagementContext().getLocationRegistry().updateDefinedLocation(definition);
}
getManagementContext().getLocationManager().manage(location);
getManagementContext().addPropertiesReloadListener(new ManagementContext.PropertiesReloadListener() {
@Override
public void reloaded() {
if (getInfrastructure().isLocationAvailable()) {
Location resolved = getManagementContext().getLocationRegistry().resolve(definition);
if (getConfig(DockerInfrastructure.REGISTER_DOCKER_HOST_LOCATIONS)) {
getManagementContext().getLocationRegistry().updateDefinedLocation(definition);
}
getManagementContext().getLocationManager().manage(resolved);
}