com.linecorp.armeria.server.Server.activePort()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(234)

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

Server.activePort介绍

[英]Returns the primary ServerPort that this Server is listening to. This method is useful when a Server listens to only one ServerPort.
[中]返回此服务器正在侦听的主服务器端口。当服务器只侦听一个服务器端口时,此方法非常有用。

代码示例

代码示例来源:origin: line/armeria

@Override
public void serverStarted(Server server) throws Exception {
  if (endpoint == null) {
    assert server.activePort().isPresent();
    endpoint = Endpoint.of(server.defaultHostname(),
                server.activePort().get()
                   .localAddress().getPort());
  }
  client.start();
  final String key = endpoint.host() + '_' + endpoint.port();
  final byte[] value = nodeValueCodec.encode(endpoint);
  client.create()
     .creatingParentsIfNeeded()
     .withMode(CreateMode.EPHEMERAL)
     .forPath(zNodePath + '/' + key, value);
}

代码示例来源:origin: line/armeria

@Override
  public void serverStarted(Server server) throws Exception {
    // Ensure that the following work will be done once.
    if (completed.compareAndSet(false, true)) {
      builder.setSchemeAndPortIfAbsent(server.activePort().get());
      assert builder.scheme() != null;
      config = new SamlPortConfig(builder.scheme(), builder.port());
      future.complete(config);
    }
  }
}

代码示例来源:origin: line/armeria

private String newUrl(String scheme) {
  final int port = server.activePort().get().localAddress().getPort();
  return scheme + "://127.0.0.1:" + port;
}

代码示例来源:origin: line/armeria

private String newUrl(String scheme) {
  final int port = server.activePort().get().localAddress().getPort();
  return scheme + "://127.0.0.1:" + port;
}

代码示例来源:origin: line/armeria

@Before
public void initClient() {
  if (client == null) {
    client = HttpClient.of("http://127.0.0.1:" + server.activePort().get().localAddress().getPort());
  }
}

代码示例来源:origin: line/armeria

@BeforeClass
public static void beforeClass() {
  server = ServerFactory.of(0);
  server.start().join();
  client = HttpClient.of("http://127.0.0.1:" + server.activePort().get().localAddress().getPort());
}

代码示例来源:origin: line/centraldogma

/**
 * Returns the primary port of the server.
 *
 * @return the primary {@link ServerPort} if the server is started. {@link Optional#empty()} otherwise.
 */
public Optional<ServerPort> activePort() {
  final Server server = this.server;
  return server != null ? server.activePort() : Optional.empty();
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server

/**
 * Returns the primary port of the server.
 *
 * @return the primary {@link ServerPort} if the server is started. {@link Optional#empty()} otherwise.
 */
public Optional<ServerPort> activePort() {
  final Server server = this.server;
  return server != null ? server.activePort() : Optional.empty();
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded

/**
 * Returns the primary port of the server.
 *
 * @return the primary {@link ServerPort} if the server is started. {@link Optional#empty()} otherwise.
 */
public Optional<ServerPort> activePort() {
  final Server server = this.server;
  return server != null ? server.activePort() : Optional.empty();
}

代码示例来源:origin: com.linecorp.armeria/armeria-saml

@Override
  public void serverStarted(Server server) throws Exception {
    // Ensure that the following work will be done once.
    if (completed.compareAndSet(false, true)) {
      builder.setSchemeAndPortIfAbsent(server.activePort().get());
      assert builder.scheme() != null;
      config = new SamlPortConfig(builder.scheme(), builder.port());
      future.complete(config);
    }
  }
}

相关文章