當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。