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


Java Handlers.gracefulShutdown方法代码示例

本文整理汇总了Java中io.undertow.Handlers.gracefulShutdown方法的典型用法代码示例。如果您正苦于以下问题:Java Handlers.gracefulShutdown方法的具体用法?Java Handlers.gracefulShutdown怎么用?Java Handlers.gracefulShutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.undertow.Handlers的用法示例。


在下文中一共展示了Handlers.gracefulShutdown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rootHandler

import io.undertow.Handlers; //导入方法依赖的package包/类
private static GracefulShutdownHandler rootHandler(HttpHandler headersHandler, Config cfg) {
    return Handlers.gracefulShutdown(
            new RequestLimitingHandler(Integer.getInteger(SYS_PROP_MAX_CONCUR_REQ, cfg.getInt(KEY_MAX_CONCURRENT_REQS)),
                    new AllowedMethodsHandler(predicateHandler(headersHandler), allowedMethods(cfg))));
}
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:6,代码来源:Server.java

示例2: getHandlers

import io.undertow.Handlers; //导入方法依赖的package包/类
private HttpHandler getHandlers(SpurOptions options) {
    // Path handler
    PathTemplateHandler pathTemplateHandler = Handlers.pathTemplate();
    endpointsMap.forEach((path, methodEndpointMap) -> pathTemplateHandler.add(path, new HttpHandler() {
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            // non-blocking
            if (options.blockableHandlersEnabled && exchange.isInIoThread()) {
                // LOGGER.info("Is in IO thread, dispatching for blockableHandlersEnabled...");
                exchange.dispatch(this);
                return;
            }
            // handler code
            // LOGGER.info("STARTING Async");
            invokePathTemplateHandler(options, methodEndpointMap, exchange);
        }
    }));

    // Websocket
    if (!webSocketHandlerMap.isEmpty()) {
        webSocketHandlerMap.forEach((pathPrefix, webSocketHandler) -> {
            LOGGER.info("Adding WS for path: " + webSocketHandler.getPath());
            addWebSocketHandler(pathTemplateHandler, webSocketHandler);
        });
    }

    // SSE
    if (!sseHandlerMap.isEmpty()) {
        sseHandlerMap.forEach(pathTemplateHandler::add);
    }

    // CORS
    HttpHandler httpHandler = Handlers.predicate(exchange -> isValidCorsOrigin(options, getRequestHeader(exchange, Headers.ORIGIN)),
            new CorsHandler(pathTemplateHandler), pathTemplateHandler);

    // Gzip
    if (options.gzipEnabled) {
        httpHandler = new EncodingHandler(new ContentEncodingRepository().addEncodingHandler("gzip", new GzipEncodingProvider(), 50,
                Predicates.maxContentSize(options.gzipMaxSize))).setNext(httpHandler);
    }

    // Custom handlers
    for (RequestFilter requestFilter : requestFilters) {
        httpHandler = Handlers.predicate(requestFilter.getAssertionPredicate(), httpHandler, requestFilter.getFailureHandler());
    }

    // Graceful shutdown
    httpHandler = Handlers.gracefulShutdown(httpHandler);

    // Basic auth
    if (!options.basicAuthUser.isEmpty() && !options.basicAuthPassword.isEmpty()) {
        httpHandler = new BasicAuthHandler(httpHandler, options.basicAuthUser, options.basicAuthPassword);
    }

    // Force HTTPS
    if (options.forceHttps) {
        httpHandler = Handlers.predicate(Predicates.secure(), httpHandler, new RedirectHttpsHandler());
    }

    return httpHandler;
}
 
开发者ID:icha024,项目名称:spur,代码行数:61,代码来源:SpurServer.java


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