当前位置: 首页>>代码示例>>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;未经允许,请勿转载。