當前位置: 首頁>>代碼示例>>Java>>正文


Java Server.getPort方法代碼示例

本文整理匯總了Java中io.grpc.Server.getPort方法的典型用法代碼示例。如果您正苦於以下問題:Java Server.getPort方法的具體用法?Java Server.getPort怎麽用?Java Server.getPort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.grpc.Server的用法示例。


在下文中一共展示了Server.getPort方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPort

import io.grpc.Server; //導入方法依賴的package包/類
/**
 * Returns the actual port of the running gRPC server. The port is only available once the server is up and running.
 *
 * @throws IllegalStateException if called either before the server has started or after it has stopped
 */
public final int getPort() {
    final Server server = server();

    if (server == null) {
        throw new IllegalStateException("Cannot fetch port until server has started.");
    }

    return server.getPort();
}
 
開發者ID:salesforce,項目名稱:grpc-java-contrib,代碼行數:15,代碼來源:GrpcServerHost.java

示例2: registerServices

import io.grpc.Server; //導入方法依賴的package包/類
/**
 * Pull all the specified services from the provided server and register
 * them into consul. Services will be registered using the provided
 * {@code advertiseAddress}. The {@code port} will be obtained from the
 * provided {@code server}. Service names are filtered through the
 * {@link #excludedServices} set before being registered into consul.
 *
 * @param advertiseAddress The address that the service is advertising on.
 * @param server The server to pull the services and port from.
 */
public void registerServices(final String advertiseAddress, final Server server) {
    final int port = server.getPort();

    final Stream<String> services = server.getImmutableServices().stream()
            .map((ssd) -> ssd.getServiceDescriptor().getName());

    registerServices(advertiseAddress, port, services);
}
 
開發者ID:indeedeng-alpha,項目名稱:indeed-grpc-java,代碼行數:19,代碼來源:ConsulServiceRegistrar.java


注:本文中的io.grpc.Server.getPort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。