diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/toolkit/CloudCommonIdUtil.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/toolkit/CloudCommonIdUtil.java index 90de193d..53c79ff4 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/toolkit/CloudCommonIdUtil.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/toolkit/CloudCommonIdUtil.java @@ -26,14 +26,31 @@ import org.springframework.core.env.PropertyResolver; */ public class CloudCommonIdUtil { + /** + * Splice target information separator + */ private static final String SEPARATOR = ":"; + /** + * Get client ip port. + * + * @param resolver resolver + * @param inetUtils inet utils + * @return ip and port + */ public static String getClientIpPort(PropertyResolver resolver, InetUtils inetUtils) { String hostname = inetUtils.findFirstNonLoopBackHostInfo().getIpAddress(); String port = resolver.getProperty("server.port", "8080"); return combineParts(hostname, SEPARATOR, port); } + /** + * Get default instance id. + * + * @param resolver resolver + * @param inetUtils inet utils + * @return default instance id + */ @SneakyThrows public static String getDefaultInstanceId(PropertyResolver resolver, InetUtils inetUtils) { String namePart = getIpApplicationName(resolver, inetUtils); @@ -41,6 +58,13 @@ public class CloudCommonIdUtil { return combineParts(namePart, SEPARATOR, indexPart); } + /** + * Get ip application name. + * + * @param resolver resolver + * @param inetUtils inet utils + * @return ip application name + */ @SneakyThrows public static String getIpApplicationName(PropertyResolver resolver, InetUtils inetUtils) { String hostname = inetUtils.findFirstNonLoopBackHostInfo().getIpAddress(); @@ -48,6 +72,14 @@ public class CloudCommonIdUtil { return combineParts(hostname, SEPARATOR, appName); } + /** + * Combine parts. + * + * @param firstPart first part + * @param separator separator + * @param secondPart second part + * @return combined + */ public static String combineParts(String firstPart, String separator, String secondPart) { String combined = null; if (firstPart != null && secondPart != null) {