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

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

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

Server.start介绍

[英]Starts this Server to listen to the ServerPorts specified in the ServerConfig. Note that the startup procedure is asynchronous and thus this method returns immediately. To wait until this Server is fully started up, wait for the returned CompletableFuture:

ServerBuilder builder = new ServerBuilder();

[中]启动此服务器以侦听ServerConfig中指定的ServerPorts。请注意,启动过程是异步的,因此该方法会立即返回。要等待此服务器完全启动,请等待返回的CompletableFuture:

ServerBuilder builder = new ServerBuilder();

代码示例

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

@Override
public synchronized void start() {
  try {
    if (!isRunning) {
      server.start().get();
      if (port == 0) {
        // Replace the specified port number with the primary port number.
        // Server#activePort doesn't return the first added port, so we need to find that.
        final Optional<ServerPort> port =
            server.activePorts().values().stream()
               .filter(p -> p.protocols().contains(protocol))
               .filter(p -> address == null ||
                      Arrays.equals(address.getAddress(),
                             p.localAddress().getAddress().getAddress()))
               .findFirst();
        assert port.isPresent() : "the primary port doest not exist.";
        this.port = port.get().localAddress().getPort();
      }
      isRunning = true;
    }
  } catch (Exception cause) {
    throw new WebServerException("Failed to start " + ArmeriaWebServer.class.getSimpleName(),
                   Exceptions.peel(cause));
  }
}

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

/**
 * Starts the {@link Server} configured by {@link #configure(ServerBuilder)}.
 * If the {@link Server} has been started up already, the existing {@link Server} is returned.
 * Note that this operation blocks until the {@link Server} finished the start-up.
 *
 * @return the started {@link Server}
 */
public Server start() {
  final Server oldServer = server.get();
  if (!isStopped(oldServer)) {
    return oldServer;
  }
  final ServerBuilder sb = new ServerBuilder();
  try {
    configure(sb);
  } catch (Exception e) {
    throw new IllegalStateException("failed to configure a Server", e);
  }
  final Server server = sb.build();
  server.start().join();
  this.server.set(server);
  return server;
}

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

public static void main(String[] args) throws Exception {
    final SamlServiceProvider ssp = samlServiceProvider();
    final Server server = new ServerBuilder()
        .https(8443)
        // You can add this certificate to your trust store in order to make your web browser happy.
        .tls(new File(ClassLoader.getSystemResource("localhost.crt").toURI()),
           new File(ClassLoader.getSystemResource("localhost.key").toURI()))
        // Decorate you service with SAML decorator.
        .annotatedService("/", new MyService(), ssp.newSamlDecorator())
        // Add SAML service to your server which handles a SAML response and a metadata request.
        .service(ssp.newSamlService())
        .build();

    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
      server.stop().join();
      logger.info("Server has been stopped.");
    }));

    server.start().join();
    logger.info("Server has been started.");
  }
}

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

@BeforeClass
public static void init() throws Exception {
  server.start().get();
  httpPort = server.activePorts().values().stream()
           .filter(ServerPort::hasHttp).findAny().get()
           .localAddress().getPort();
  httpsPort = server.activePorts().values().stream()
           .filter(ServerPort::hasHttps).findAny().get()
           .localAddress().getPort();
}

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

s.start().handle((result, t) -> {
  if (t != null) {
    throw new IllegalStateException("Armeria server failed to start", t);

代码示例来源: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/armeria

@BeforeClass
public static void init() throws Exception {
  server.start().get();

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

@Before
public void startServers() {
  servers = new ArrayList<>();
  for (Endpoint endpoint : sampleEndpoints) {
    final Server server = new ServerBuilder().http(endpoint.port())
                         .service("/", new EchoService())
                         .build();
    final ServerListener listener = new ZooKeeperUpdatingListenerBuilder(
        instance().connectString().get(), zNode)
        .sessionTimeoutMillis(sessionTimeoutMillis)
        .endpoint(endpoint)
        .build();
    server.addListener(listener);
    server.start().join();
    servers.add(server);
  }
}

代码示例来源:origin: com.linecorp.armeria/armeria-spring-boot2-autoconfigure

s.start().join();
logger.info("Armeria server started at ports: {}", s.activePorts());
return s;

代码示例来源:origin: com.linecorp.armeria/armeria-spring-boot2-autoconfigure-shaded

s.start().join();
logger.info("Armeria server started at ports: {}", s.activePorts());
return s;

代码示例来源:origin: com.linecorp.armeria/armeria-spring-boot-autoconfigure-shaded

s.start().handle((result, t) -> {
  if (t != null) {
    throw new IllegalStateException("Armeria server failed to start", t);

代码示例来源:origin: com.linecorp.armeria/armeria-spring-boot1-autoconfigure-shaded

s.start().handle((result, t) -> {
  if (t != null) {
    throw new IllegalStateException("Armeria server failed to start", t);

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

s.start().join();
return s;

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

s.start().join();
return s;

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

s.start().join();
return s;

相关文章