org.jgroups.util.Util.getAddressByPatternMatch()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中org.jgroups.util.Util.getAddressByPatternMatch()方法的一些代码示例,展示了Util.getAddressByPatternMatch()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.getAddressByPatternMatch()方法的具体详情如下:
包路径:org.jgroups.util.Util
类名称:Util
方法名:getAddressByPatternMatch

Util.getAddressByPatternMatch介绍

[英]Returns a valid interface address based on a pattern. Iterates over all interfaces that are up and returns the first match, based on the address or interface name
[中]根据模式返回有效的接口地址。迭代所有启动的接口,并根据地址或接口名称返回第一个匹配项

代码示例

代码示例来源:origin: wildfly/wildfly

protected static InetAddress convertBindAddress(String value) throws Exception {
  InetAddress retval=null;
  Util.AddressScope addr_scope=null;
  try {
    addr_scope=Util.AddressScope.valueOf(value.toUpperCase());
  }
  catch(Throwable ignored) {
  }
  if(addr_scope != null)
    retval=Util.getAddress(addr_scope);
  else {
    if(value.startsWith("match"))
      retval=Util.getAddressByPatternMatch(value);
    else if(value.startsWith("custom:"))
      retval=getAddressByCustomCode(value.substring("custom:".length()));
    else
      retval=InetAddress.getByName(value);
  }
  if(retval instanceof Inet4Address && retval.isMulticastAddress() && Util.getIpStackType() == StackType.IPv6) {
    String tmp=prefix + value;
    retval=InetAddress.getByName(tmp);
    return retval;
  }
  return retval;
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

protected static InetAddress convertBindAddress(String value) throws Exception {
  InetAddress retval=null;
  Util.AddressScope addr_scope=null;
  try {
    addr_scope=Util.AddressScope.valueOf(value.toUpperCase());
  }
  catch(Throwable ex) {
  }
  if(addr_scope != null)
    retval=Util.getAddress(addr_scope);
  else {
    if(value.startsWith("match"))
      retval=Util.getAddressByPatternMatch(value);
    else if(value.startsWith("custom:"))
      retval=getAddressByCustomCode(value.substring("custom:".length()));
    else
      retval=InetAddress.getByName(value);
  }
  if(retval instanceof Inet4Address && retval.isMulticastAddress() && Util.getIpStackType() == StackType.IPv6) {
    String tmp=prefix + value;
    retval=InetAddress.getByName(tmp);
    return retval;
  }
  return retval;
}

相关文章

Util类方法