com.alibaba.dubbo.common.URL.getAuthority()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(82)

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

URL.getAuthority介绍

暂无

代码示例

代码示例来源:origin: com.alibaba/dubbo

public CuratorZookeeperClient(URL url) {
  super(url);
  try {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
        .connectString(url.getBackupAddress())
        .retryPolicy(new RetryNTimes(1, 1000))
        .connectionTimeoutMs(5000);
    String authority = url.getAuthority();
    if (authority != null && authority.length() > 0) {
      builder = builder.authorization("digest", authority.getBytes());
    }
    client = builder.build();
    client.getConnectionStateListenable().addListener(new ConnectionStateListener() {
      @Override
      public void stateChanged(CuratorFramework client, ConnectionState state) {
        if (state == ConnectionState.LOST) {
          CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED);
        } else if (state == ConnectionState.CONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.CONNECTED);
        } else if (state == ConnectionState.RECONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.RECONNECTED);
        }
      }
    });
    client.start();
  } catch (Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}

代码示例来源:origin: com.alibaba/dubbo-remoting-zookeeper

public CuratorZookeeperClient(URL url) {
  super(url);
  try {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
        .connectString(url.getBackupAddress())
        .retryPolicy(new RetryNTimes(1, 1000))
        .connectionTimeoutMs(5000);
    String authority = url.getAuthority();
    if (authority != null && authority.length() > 0) {
      builder = builder.authorization("digest", authority.getBytes());
    }
    client = builder.build();
    client.getConnectionStateListenable().addListener(new ConnectionStateListener() {
      @Override
      public void stateChanged(CuratorFramework client, ConnectionState state) {
        if (state == ConnectionState.LOST) {
          CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED);
        } else if (state == ConnectionState.CONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.CONNECTED);
        } else if (state == ConnectionState.RECONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.RECONNECTED);
        }
      }
    });
    client.start();
  } catch (Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}

代码示例来源:origin: net.jahhan/dubbo-remoting-zookeeper

public CuratorZookeeperClient(URL url) {
  super(url);
  try {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
        .connectString(url.getBackupAddress())
        .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000))
        .connectionTimeoutMs(5000);
    String authority = url.getAuthority();
    if (authority != null && authority.length() > 0) {
      builder = builder.authorization("digest", authority.getBytes());
    }
    client = builder.build();
    client.getConnectionStateListenable().addListener(new ConnectionStateListener() {
      public void stateChanged(CuratorFramework client, ConnectionState state) {
        if (state == ConnectionState.LOST) {
          CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED);
        } else if (state == ConnectionState.CONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.CONNECTED);
        } else if (state == ConnectionState.RECONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.RECONNECTED);
        }
      }
    });
    client.start();
  } catch (Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}

代码示例来源:origin: remoting/dubbox

public CuratorZookeeperClient(URL url) {
  super(url);
  Builder builder = CuratorFrameworkFactory.builder()
      .connectString(url.getBackupAddress())
      .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000))
      .connectionTimeoutMs(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_REGISTRY_CONNECT_TIMEOUT))
      .sessionTimeoutMs(url.getParameter(Constants.SESSION_TIMEOUT_KEY, Constants.DEFAULT_SESSION_TIMEOUT));
  String authority = url.getAuthority();
  if (authority != null && authority.length() > 0) {
    builder = builder.authorization("digest", authority.getBytes());
  }
  client = builder.build();
  client.getConnectionStateListenable().addListener(
      new ConnectionStateListener() {
        public void stateChanged(CuratorFramework client,
            ConnectionState state) {
          if (state == ConnectionState.LOST) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.DISCONNECTED);
          } else if (state == ConnectionState.CONNECTED) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.CONNECTED);
          } else if (state == ConnectionState.RECONNECTED) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.RECONNECTED);
          }
        }
      });
  client.start();
}

代码示例来源:origin: remoting/dubbox

public CuratorZookeeperClient(URL url) {
  super(url);
  Builder builder = CuratorFrameworkFactory.builder()
      .connectString(url.getBackupAddress())
      .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000))
      .connectionTimeoutMs(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_REGISTRY_CONNECT_TIMEOUT))
      .sessionTimeoutMs(url.getParameter(Constants.SESSION_TIMEOUT_KEY, Constants.DEFAULT_SESSION_TIMEOUT));
  String authority = url.getAuthority();
  if (authority != null && authority.length() > 0) {
    builder = builder.authorization("digest", authority.getBytes());
  }
  client = builder.build();
  client.getConnectionStateListenable().addListener(
      new ConnectionStateListener() {
        public void stateChanged(CuratorFramework client,
            ConnectionState state) {
          if (state == ConnectionState.LOST) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.DISCONNECTED);
          } else if (state == ConnectionState.CONNECTED) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.CONNECTED);
          } else if (state == ConnectionState.RECONNECTED) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.RECONNECTED);
          }
        }
      });
  client.start();
}

相关文章

微信公众号

最新文章

更多