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

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

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

Util.validateBindAddressFromInterface介绍

[英]Method used by PropertyConverters.BindInterface to check that a bind_address is consistent with a specified interface

Idea: 1. We are passed a bind_addr, which may be null 2. If non-null, check that bind_addr is on bind_interface - if not, throw exception, otherwise, return the original bind_addr 3. If null, get first non-loopback address on bind_interface, using stack preference to get the IP version. If no non-loopback address, then just return null (i.e. the bind_interface did not influence the decision).
[中]属性转换器使用的方法。BindInterface,检查bind_地址是否与指定接口一致
想法:1。我们被传递了一个bind_addr,它可能是null 2。如果非空,检查bind_addr是否在bind_接口上——如果不是,则抛出异常,否则,返回原始的bind_addr 3。如果为null,则在bind_接口上获取第一个非环回地址,使用堆栈首选项获取IP版本。如果没有非环回地址,则只返回null(即bind_接口不影响决策)。

代码示例

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

public Object convert(Object obj, Class<?> propertyFieldType, String propertyName, String propertyValue, boolean check_scope) throws Exception {
  // get the existing bind address - possibly null
  InetAddress    old_bind_addr = (InetAddress)Configurator.getValueFromProtocol((Protocol)obj, "bind_addr");
  // apply a bind interface constraint
  InetAddress new_bind_addr = Util.validateBindAddressFromInterface(old_bind_addr, propertyValue);
  if (new_bind_addr != null)
    setBindAddress((Protocol)obj, new_bind_addr) ;
  // if no bind_interface specified, set it to the empty string to avoid exception
  // from @Property processing
  if (propertyValue != null)
    return propertyValue ;
  else
    return "" ;
}

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

public Object convert(Object obj, Class<?> propertyFieldType, String propertyName, String propertyValue, boolean check_scope) throws Exception {
  // get the existing bind address - possibly null
  InetAddress    old_bind_addr = (InetAddress)Configurator.getValueFromProtocol((Protocol)obj, "bind_addr");
  // apply a bind interface constraint
  InetAddress new_bind_addr = Util.validateBindAddressFromInterface(old_bind_addr, propertyValue);
  if (new_bind_addr != null)
    setBindAddress((Protocol)obj, new_bind_addr) ;
  // if no bind_interface specified, set it to the empty string to avoid exception
  // from @Property processing
  if (propertyValue != null)
    return propertyValue ;
  else
    return "" ;
}

相关文章

Util类方法