From 9c534bc3fd8974e2e814f17701ba05b172604acd Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:18:01 +0800 Subject: [PATCH] Fixed Web thread pool adaptation --- .../WebThreadPoolHandlerConfiguration.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/src/main/java/cn/hippo4j/springboot/starter/adapter/web/WebThreadPoolHandlerConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/src/main/java/cn/hippo4j/springboot/starter/adapter/web/WebThreadPoolHandlerConfiguration.java index 4934b887..3d245e4a 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/src/main/java/cn/hippo4j/springboot/starter/adapter/web/WebThreadPoolHandlerConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/src/main/java/cn/hippo4j/springboot/starter/adapter/web/WebThreadPoolHandlerConfiguration.java @@ -2,6 +2,7 @@ package cn.hippo4j.springboot.starter.adapter.web; import cn.hippo4j.adapter.web.JettyWebThreadPoolHandler; import cn.hippo4j.adapter.web.TomcatWebThreadPoolHandler; +import cn.hippo4j.adapter.web.UndertowWebThreadPoolHandler; import cn.hippo4j.adapter.web.WebThreadPoolRunStateHandler; import org.apache.catalina.startup.Tomcat; import org.apache.coyote.UpgradeProtocol; @@ -15,6 +16,8 @@ import org.springframework.context.annotation.Configuration; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.webapp.WebAppContext; +import io.undertow.Undertow; +import org.xnio.SslClientAuthMode; import javax.servlet.Servlet; @@ -55,4 +58,20 @@ public class WebThreadPoolHandlerConfiguration { return new JettyWebThreadPoolHandler(); } } + + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass({ Servlet.class, Undertow.class, SslClientAuthMode.class }) + @ConditionalOnBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT) + static class EmbeddedUndertow { + + /** + * Refer to the Undertow loading source code . + * This load is performed if the {@link Undertow} class exists and + * the Web embedded server loads the {@link ServletWebServerFactory} top-level interface type at the same time + */ + @Bean + public UndertowWebThreadPoolHandler undertowWebThreadPoolHandler() { + return new UndertowWebThreadPoolHandler(); + } + } }