本文整理汇总了Java中org.eclipse.jetty.server.ServerConnector.getHost方法的典型用法代码示例。如果您正苦于以下问题:Java ServerConnector.getHost方法的具体用法?Java ServerConnector.getHost怎么用?Java ServerConnector.getHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.server.ServerConnector
的用法示例。
在下文中一共展示了ServerConnector.getHost方法的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: createRpcServerMetadata
import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
private RpcMetadataResponse createRpcServerMetadata(ServerConnector connector) throws
UnknownHostException {
String host = connector.getHost();
if (null == host) {
// "null" means binding to all interfaces, we need to pick one so the client gets a real
// address and not "0.0.0.0" or similar.
host = InetAddress.getLocalHost().getHostName();
}
final int port = connector.getLocalPort();
return new RpcMetadataResponse(
String.format(Locale.ROOT, "%s:%d", host, port));
}