本文整理匯總了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);
}
示例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));
}
}
}