本文整理汇总了Java中io.vertx.core.http.HttpServerOptions.getPort方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerOptions.getPort方法的具体用法?Java HttpServerOptions.getPort怎么用?Java HttpServerOptions.getPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.http.HttpServerOptions
的用法示例。
在下文中一共展示了HttpServerOptions.getPort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recordServer
import io.vertx.core.http.HttpServerOptions; //导入方法依赖的package包/类
private void recordServer(final HttpServerOptions options,
final Router router) {
final Integer port = options.getPort();
final AtomicInteger out = ZeroAtomic.RX_START_LOGS.get(port);
if (Values.ZERO == out.getAndIncrement()) {
// 1. Build logs for current server;
final String portLiteral = String.valueOf(port);
LOGGER.info(Info.RX_SERVERS, this.NAME, deploymentID(),
portLiteral);
final List<Route> routes = router.getRoutes();
final Map<String, Route> routeMap = new TreeMap<>();
for (final Route route : routes) {
// 2.Route
final String path = null == route.getPath() ? "/*" : route.getPath();
routeMap.put(path, route);
}
routeMap.forEach((path, route) ->
LOGGER.info(Info.MAPPED_ROUTE, this.NAME, path,
route.toString()));
// 3. Endpoint Publish
final String address =
MessageFormat.format("http://{0}:{1}/",
options.getHost(), portLiteral);
LOGGER.info(Info.RX_LISTEN, this.NAME, address);
}
}
示例2: registryServer
import io.vertx.core.http.HttpServerOptions; //导入方法依赖的package包/类
private void registryServer(final HttpServerOptions options) {
final Integer port = options.getPort();
final AtomicInteger out = API_START_LOGS.get(port);
if (Values.ZERO == out.getAndIncrement()) {
final String portLiteral = String.valueOf(port);
LOGGER.info(Info.API_GATEWAY, getClass().getSimpleName(), deploymentID(),
portLiteral);
final String address =
MessageFormat.format("http://{0}:{1}/",
options.getHost(), portLiteral);
LOGGER.info(Info.API_LISTEN, getClass().getSimpleName(), address);
}
}
示例3: registryServer
import io.vertx.core.http.HttpServerOptions; //导入方法依赖的package包/类
private void registryServer(final HttpServerOptions options,
final Router router) {
final Integer port = options.getPort();
final AtomicInteger out = ZeroAtomic.HTTP_START_LOGS.get(port);
if (Values.ZERO == out.getAndIncrement()) {
// 1. Build logs for current server;
final String portLiteral = String.valueOf(port);
LOGGER.info(Info.HTTP_SERVERS, getClass().getSimpleName(), deploymentID(),
portLiteral);
final List<Route> routes = router.getRoutes();
final Map<String, Route> routeMap = new TreeMap<>();
final Set<String> tree = new TreeSet<>();
for (final Route route : routes) {
// 2.Route
final String path = null == route.getPath() ? "/*" : route.getPath();
routeMap.put(path, route);
if (!"/*".equals(path)) {
tree.add(path);
}
}
routeMap.forEach((path, route) ->
LOGGER.info(Info.MAPPED_ROUTE, getClass().getSimpleName(), path,
route.toString()));
// 3. Endpoint Publish
final String address =
MessageFormat.format("http://{0}:{1}/",
Net.getIPv4(), portLiteral);
LOGGER.info(Info.HTTP_LISTEN, getClass().getSimpleName(), address);
// 4. Send configuration to Event bus
final String name = SERVICES.get(port);
startRegistry(name, options, tree);
}
}
示例4: WebhookUpdateProvider
import io.vertx.core.http.HttpServerOptions; //导入方法依赖的package包/类
@Builder
public WebhookUpdateProvider(HttpServerOptions serverOptions, File selfSignedCertificate,
List<UpdateType> updateTypes, Integer maxConnections) throws InterruptedException, FailBindingException {
if (!serverOptions.isSsl()) {
throw new IllegalArgumentException("Http Server must be SSL!");
}
if (selfSignedCertificate != null) {
this.selfSignedCertificate = new LocalInputFile(selfSignedCertificate);
}
this.updateTypes = updateTypes;
this.maxConnections = maxConnections;
baseUrl = "https://" + serverOptions.getHost() + ":" + serverOptions.getPort() + "/";
server = vertx.createHttpServer(serverOptions.setHost("0.0.0.0"));
server.requestHandler((request) -> {
String path = request.path().substring(1);
if (requestPaths.containsKey(path)) {
TelegramBot bot = requestPaths.get(path);
request.bodyHandler((buffer) -> {
Update update = TelegramBotRegistry.GSON.fromJson(buffer.toString(), Update.class);
PollingUpdateRunnable.handleUpdate(bot, UpdateType.from(update.getClass()), update);
});
request.response().setStatusCode(200).end("OK");
return;
}
request.response().setStatusCode(404).end("No bot found on this endpoint");
});
CountDownLatch latch = new CountDownLatch(1);
server.listen((res) -> {
bindingResult = res;
latch.countDown();
});
latch.await();
if (bindingResult.failed()) {
throw new FailBindingException(bindingResult.cause());
}
}