Code formatting optimization

pull/664/merge
chen.ma 2 years ago
parent 60a1352596
commit 8ee0e4edee

@ -21,17 +21,22 @@ import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
/** /**
* web ip and port info * Web ip and port info
*/ */
@Data @Data
@Slf4j @Slf4j
public class WebIpAndPortInfo { public class WebIpAndPortInfo {
protected static final String ALL = "*"; protected static final String ALL = "*";
protected static final String SPOT = "\\."; protected static final String SPOT = "\\.";
protected static final String COLON = ":"; protected static final String COLON = ":";
private String ip; private String ip;
private String port; private String port;
private String[] ipSegment; private String[] ipSegment;
public WebIpAndPortInfo(String ip, String port) { public WebIpAndPortInfo(String ip, String port) {
@ -53,7 +58,7 @@ public class WebIpAndPortInfo {
} }
/** /**
* check * Check.
* *
* @param appIpSegment application ip segment * @param appIpSegment application ip segment
* @param port application port * @param port application port
@ -63,7 +68,7 @@ public class WebIpAndPortInfo {
} }
/** /**
* check ip * Check ip.
* *
* @param appIpSegment application ip segment * @param appIpSegment application ip segment
*/ */
@ -81,7 +86,7 @@ public class WebIpAndPortInfo {
} }
/** /**
* check port * Check port.
* *
* @param port application port * @param port application port
*/ */
@ -90,7 +95,7 @@ public class WebIpAndPortInfo {
} }
/** /**
* Check whether the strings are the same * Check whether the strings are the same.
* *
* @param appIp appIp * @param appIp appIp
* @param propIp propIp * @param propIp propIp

@ -36,10 +36,11 @@ import java.util.Objects;
public abstract class AbstractRefreshListener<M> implements RefreshListener<Hippo4jConfigDynamicRefreshEvent, M> { public abstract class AbstractRefreshListener<M> implements RefreshListener<Hippo4jConfigDynamicRefreshEvent, M> {
protected static final String ALL = "*"; protected static final String ALL = "*";
protected static final String SEPARATOR = ","; protected static final String SEPARATOR = ",";
/** /**
* application ip and application post * Application ip and application post
*/ */
protected static volatile WebIpAndPortInfo webIpAndPort; protected static volatile WebIpAndPortInfo webIpAndPort;
@ -60,7 +61,7 @@ public abstract class AbstractRefreshListener<M> implements RefreshListener<Hipp
String ip = loopBackHostInfo.getIpAddress(); String ip = loopBackHostInfo.getIpAddress();
WebThreadPoolHandlerChoose webThreadPoolHandlerChoose = ApplicationContextHolder.getBean(WebThreadPoolHandlerChoose.class); WebThreadPoolHandlerChoose webThreadPoolHandlerChoose = ApplicationContextHolder.getBean(WebThreadPoolHandlerChoose.class);
WebThreadPoolService webThreadPoolService = webThreadPoolHandlerChoose.choose(); WebThreadPoolService webThreadPoolService = webThreadPoolHandlerChoose.choose();
// when get the port at startup, can get the message: "port xxx was already in use" or use two ports // When get the port at startup, can get the message: "port xxx was already in use" or use two ports
String port = String.valueOf(webThreadPoolService.getWebServer().getPort()); String port = String.valueOf(webThreadPoolService.getWebServer().getPort());
return new WebIpAndPortInfo(ip, port); return new WebIpAndPortInfo(ip, port);
} }
@ -93,11 +94,11 @@ public abstract class AbstractRefreshListener<M> implements RefreshListener<Hipp
.distinct() .distinct()
.map(WebIpAndPortInfo::build) .map(WebIpAndPortInfo::build)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.anyMatch(i -> i.check(webIpAndPort.getIpSegment(), webIpAndPort.getPort())); .anyMatch(each -> each.check(webIpAndPort.getIpSegment(), webIpAndPort.getPort()));
} }
/** /**
* get nodes in new properties * Get nodes in new properties.
* *
* @param properties new properties * @param properties new properties
* @return nodes in properties * @return nodes in properties
@ -105,5 +106,4 @@ public abstract class AbstractRefreshListener<M> implements RefreshListener<Hipp
protected String getNodes(M properties) { protected String getNodes(M properties) {
return ALL; return ALL;
} }
} }
Loading…
Cancel
Save