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


Java ServerConnector.getPort方法代碼示例

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


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

示例1: getConnectorPath

import org.eclipse.jetty.server.ServerConnector; //導入方法依賴的package包/類
private String getConnectorPath(ServerConnector sc) {
    String prefix = "http";
    String host = sc.getHost();
    int port = sc.getPort();

    ConnectionFactory cf = sc.getDefaultConnectionFactory();
    if (cf instanceof SslConnectionFactory) {
        prefix = "https";
    }

    if (host == null || host.equals("0.0.0.0")) {
        try {
            host = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            // Well, we failed to read from system, fall back to main.properties.
            // Better than nothing
            host = CONFIG.getJetty().getServerHost();
        }
    }

    String layout = "%s://%s:%d" + CONFIG.getContextPath();

    return String.format(layout, prefix, host, port);
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:25,代碼來源:JettyServer.java

示例2: dumpUrls

import org.eclipse.jetty.server.ServerConnector; //導入方法依賴的package包/類
private void dumpUrls() throws SocketException {
    final List<String> urls = new ArrayList<>();

    for (Connector connector : server.getConnectors()) {
        if (connector instanceof ServerConnector) {
            final ServerConnector serverConnector = (ServerConnector) connector;

            Set<String> hosts = new HashSet<>();

            // determine the hosts
            if (StringUtils.isNotBlank(serverConnector.getHost())) {
                hosts.add(serverConnector.getHost());
            } else {
                Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
                if (networkInterfaces != null) {
                    for (NetworkInterface networkInterface : Collections.list(networkInterfaces)) {
                        for (InetAddress inetAddress : Collections.list(networkInterface.getInetAddresses())) {
                            hosts.add(inetAddress.getHostAddress());
                        }
                    }
                }
            }

            // ensure some hosts were found
            if (!hosts.isEmpty()) {
                String scheme = "http";
                if (properties.getSslPort() != null && serverConnector.getPort() == properties.getSslPort()) {
                    scheme = "https";
                }

                // dump each url
                for (String host : hosts) {
                    urls.add(String.format("%s://%s:%s", scheme, host, serverConnector.getPort()));
                }
            }
        }
    }

    if (urls.isEmpty()) {
        logger.warn("NiFi Registry has started, but the UI is not available on any hosts. Please verify the host properties.");
    } else {
        // log the ui location
        logger.info("NiFi Registry has started. The UI is available at the following URLs:");
        for (final String url : urls) {
            logger.info(String.format("%s/nifi-registry", url));
        }
    }
}
 
開發者ID:apache,項目名稱:nifi-registry,代碼行數:49,代碼來源:JettyServer.java


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