本文整理汇总了Java中io.undertow.server.handlers.BlockingHandler类的典型用法代码示例。如果您正苦于以下问题:Java BlockingHandler类的具体用法?Java BlockingHandler怎么用?Java BlockingHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockingHandler类属于io.undertow.server.handlers包,在下文中一共展示了BlockingHandler类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: wrapWithMiddleware
import io.undertow.server.handlers.BlockingHandler; //导入依赖的package包/类
private static HttpHandler wrapWithMiddleware(HttpHandler handler) {
/*
* Undertow has I/O threads for handling inbound connections and non blocking IO.
* If you are doing any blocking you should use the BlockingHandler. This
* will push work into a separate Executor with customized thread pool
* which is made for blocking work. I am blocking immediately here because I am lazy.
* Don't block if you don't need to. Remember you can configure only certain routes block.
* When looking at logs you can tell if you are blocking or not by the thread name.
* I/O non blocking thread - [XNIO-1 I/O-{threadnum}] - You should NOT be blocking here.
* Blocking task threads - [XNIO-1 task-{threadnum}] This pool is made for blocking.
*/
return MiddlewareBuilder.begin(BlockingHandler::new)
.next(CustomHandlers::gzip)
.next(CustomHandlers::accessLog)
.next(CustomHandlers::statusCodeMetrics)
.next(MiddlewareServer::exceptionHandler)
.complete(handler);
}
示例2: HttpProtocolReceiver
import io.undertow.server.handlers.BlockingHandler; //导入依赖的package包/类
public HttpProtocolReceiver(final UPID localAddress,
final Class<?> messageBaseClass,
final ManagedEventBus eventBus)
{
this.localAddress = localAddress;
this.messageBaseClass = messageBaseClass;
this.eventBus = eventBus;
final PathHandler pathHandler = new PathHandler();
pathHandler.addPrefixPath(localAddress.getId(), new CanonicalPathHandler(new BlockingHandler(this)));
this.shutdownHandler = new GracefulShutdownHandler(pathHandler);
this.httpServer = Undertow.builder()
.setIoThreads(2)
.setWorkerThreads(16)
.addHttpListener(localAddress.getPort(), localAddress.getHost())
.setHandler(shutdownHandler)
.build();
}
示例3: buildGracefulShutdownHandler
import io.undertow.server.handlers.BlockingHandler; //导入依赖的package包/类
/**
* buildGracefulShutdownHandler
*
* @param paths
* @return
*/
private static GracefulShutdownHandler buildGracefulShutdownHandler(PathHandler paths) {
return new GracefulShutdownHandler(
new RequestLimitingHandler(new RequestLimit(configuration.getRequestLimit()),
new AllowedMethodsHandler(
new BlockingHandler(
new GzipEncodingHandler(
new ErrorHandler(
new HttpContinueAcceptingHandler(paths)
), configuration.isForceGzipEncoding()
)
), // allowed methods
HttpString.tryFromString(RequestContext.METHOD.GET.name()),
HttpString.tryFromString(RequestContext.METHOD.POST.name()),
HttpString.tryFromString(RequestContext.METHOD.PUT.name()),
HttpString.tryFromString(RequestContext.METHOD.DELETE.name()),
HttpString.tryFromString(RequestContext.METHOD.PATCH.name()),
HttpString.tryFromString(RequestContext.METHOD.OPTIONS.name())
)
)
);
}
示例4: wrapWithMiddleware
import io.undertow.server.handlers.BlockingHandler; //导入依赖的package包/类
private static HttpHandler wrapWithMiddleware(HttpHandler handler) {
return MiddlewareBuilder.begin(BlockingHandler::new)
.next(CustomHandlers::gzip)
.next(ex -> CustomHandlers.accessLog(ex, log))
.next(CustomHandlers::statusCodeMetrics)
.next(WebpackServer::exceptionHandler)
.complete(handler);
}
示例5: common
import io.undertow.server.handlers.BlockingHandler; //导入依赖的package包/类
public static HttpHandler common(HttpHandler root) {
return MiddlewareBuilder.begin(handler -> CustomHandlers.securityHeaders(handler, ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN))
.next(CustomHandlers::gzip)
.next(BlockingHandler::new)
.next(CustomHandlers::accessLog)
.next(CustomHandlers::statusCodeMetrics)
.complete(root);
}
示例6: wrapWithMiddleware
import io.undertow.server.handlers.BlockingHandler; //导入依赖的package包/类
private static HttpHandler wrapWithMiddleware(HttpHandler next) {
return MiddlewareBuilder.begin(PageRoutes::redirector)
.next(handler -> CustomHandlers.securityHeaders(handler, ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN))
.next(StubbornJavaWebApp::contentSecurityPolicy)
.next(CustomHandlers::gzip)
.next(BlockingHandler::new)
.next(ex -> CustomHandlers.accessLog(ex, logger))
.next(CustomHandlers::statusCodeMetrics)
.next(StubbornJavaWebApp::exceptionHandler)
.complete(next);
}
示例7: start
import io.undertow.server.handlers.BlockingHandler; //导入依赖的package包/类
public void start()
{
undertow = builder.setHandler(new BlockingHandler(pathHandler)).build();
undertow.start();
}
示例8: associateIdentity
import io.undertow.server.handlers.BlockingHandler; //导入依赖的package包/类
private static HttpHandler associateIdentity(HttpHandler domainHandler, final Builder builder) {
domainHandler = new ElytronIdentityHandler(domainHandler);
return new BlockingHandler(domainHandler);
}
示例9: start
import io.undertow.server.handlers.BlockingHandler; //导入依赖的package包/类
private void start() {
Undertow server = Undertow.builder()
.addHttpListener(this.port, this.host, new BlockingHandler(new MyHttpHandler())).build();
server.start();
}