private String getAddress(String predefinedAddress, AbstractConfigurableEmbeddedServletContainer container) { String proto = (container.getSsl() == null)? "http://" : "https://"; if(StringUtils.hasText(predefinedAddress)) { String hostPort = AddressUtils.getHostPort(predefinedAddress); return proto + hostPort; } else { int port = container.getPort(); // server must have way to fix invalid host if it need String host = "localhost"; return proto + host + ":" + port; } }
@Autowired public DataProvider(NotifierProps config, AbstractConfigurableEmbeddedServletContainer container) { this.collector = new InfoCollector(config.getRootPath()); this.address = getAddress(config.getAddress(), container); this.hostName = OSUtils.getHostName(); }