当前位置: 首页>>代码示例>>Java>>正文


Java HttpServerOptions.getPort方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:27,代码来源:ZeroRxAgent.java

示例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);
    }
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:14,代码来源:ZeroApiAgent.java

示例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);
    }
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:35,代码来源:ZeroHttpAgent.java

示例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());
    }
}
 
开发者ID:jTelegram,项目名称:jTelegramBotAPI,代码行数:48,代码来源:WebhookUpdateProvider.java


注:本文中的io.vertx.core.http.HttpServerOptions.getPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。