From 21930ac7f0e92622c9ecbb97524edf7a2ea422e7 Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 11:04:18 +0800 Subject: [PATCH 01/15] add WebThreadPoolHandlerConfiguration --- .../adapter/web/WebThreadPoolHandlerConfiguration.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 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 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 new file mode 100644 index 00000000..c5743e55 --- /dev/null +++ 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 @@ -0,0 +1,7 @@ +package cn.hippo4j.springboot.starter.adapter.web; + +/** + * Web Thread Pool Handler Configuration + **/ +public class WebThreadPoolHandlerConfiguration { +} From 6ed3c1c68db8321634144a160cdba9380079ab84 Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 15:54:08 +0800 Subject: [PATCH 02/15] Modifying Tomcat Adaptation --- .../WebThreadPoolHandlerConfiguration.java | 30 +++++++++++++++++++ 1 file changed, 30 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 c5743e55..24ec8a0e 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 @@ -1,7 +1,37 @@ package cn.hippo4j.springboot.starter.adapter.web; +import cn.hippo4j.adapter.web.TomcatWebThreadPoolHandler; +import cn.hippo4j.adapter.web.WebThreadPoolRunStateHandler; +import org.apache.catalina.startup.Tomcat; +import org.apache.coyote.UpgradeProtocol; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.SearchStrategy; +import org.springframework.boot.web.servlet.server.ServletWebServerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.Servlet; + /** * Web Thread Pool Handler Configuration **/ +@Configuration(proxyBeanMethods = false) public class WebThreadPoolHandlerConfiguration { + + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass({Servlet.class, Tomcat.class, UpgradeProtocol.class}) + @ConditionalOnBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT) + static class EmbeddedTomcat { + + /** + * Refer to the Tomcat loading source code . + * This load is performed if the {@link Tomcat} class exists and + * the Web embedded server loads the {@link ServletWebServerFactory} top-level interface type at the same time + */ + @Bean + public TomcatWebThreadPoolHandler tomcatWebThreadPoolHandler(WebThreadPoolRunStateHandler webThreadPoolRunStateHandler) { + return new TomcatWebThreadPoolHandler(webThreadPoolRunStateHandler); + } + } } From 81b026a0606beb9674e376bf905472e7644fb85a Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 15:54:51 +0800 Subject: [PATCH 03/15] Modifying Web Adaptation --- .../web/WebAdapterAutoConfiguration.java | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java index 80d1010d..9891ef10 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java @@ -23,23 +23,17 @@ import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; import cn.hippo4j.core.toolkit.inet.InetUtils; import lombok.RequiredArgsConstructor; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SearchStrategy; -import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; -import javax.servlet.Servlet; - -import org.apache.catalina.startup.Tomcat; -import org.apache.coyote.UpgradeProtocol; - /** * Web adapter auto configuration. */ @Configuration +@Import({WebThreadPoolHandlerConfiguration.class}) @RequiredArgsConstructor public class WebAdapterAutoConfiguration { @@ -66,18 +60,6 @@ public class WebAdapterAutoConfiguration { return new ThreadPoolRunStateHandler(hippo4JInetUtils, environment); } - /** - * Refer to the Tomcat loading source code . - * This load is performed if the {@link Tomcat} class exists and - * the Web embedded server loads the {@link ServletWebServerFactory} top-level interface type at the same time - */ - @Bean - @ConditionalOnClass({Servlet.class, Tomcat.class, UpgradeProtocol.class}) - @ConditionalOnBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT) - public TomcatWebThreadPoolHandler tomcatWebThreadPoolHandler(WebThreadPoolRunStateHandler webThreadPoolRunStateHandler) { - return new TomcatWebThreadPoolHandler(webThreadPoolRunStateHandler); - } - @Bean @ConditionalOnBean(name = JETTY_SERVLET_WEB_SERVER_FACTORY) public JettyWebThreadPoolHandler jettyWebThreadPoolHandler() { From 6d65d29b8168b9e95fee759fea4c929364b5f338 Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:06:26 +0800 Subject: [PATCH 04/15] Modifying WebAdapterAutoConfiguration --- .../starter/adapter/web/WebAdapterAutoConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java index 9891ef10..18a49bea 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java @@ -33,7 +33,7 @@ import org.springframework.core.env.ConfigurableEnvironment; * Web adapter auto configuration. */ @Configuration -@Import({WebThreadPoolHandlerConfiguration.class}) +@Import({WebThreadPoolHandlerConfiguration.EmbeddedTomcat.class}) @RequiredArgsConstructor public class WebAdapterAutoConfiguration { From 2c316d6dfff480dd1b896086364ffcde260b82b5 Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:07:18 +0800 Subject: [PATCH 05/15] Modify web adaptation dependency --- .../hippo4j-spring-boot-starter-adapter-web/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/pom.xml index 4c4c9238..b24f5b81 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/pom.xml +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/pom.xml @@ -14,11 +14,6 @@ cn.hippo4j hippo4j-adapter-web - - org.springframework.boot - spring-boot-starter-web - true - From 4361d96f31d4c9684e02539b2daff11ee1123156 Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:09:33 +0800 Subject: [PATCH 06/15] Fix web adaptation dependency issues --- .../pom.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/pom.xml index b24f5b81..c3c754aa 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/pom.xml +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-web/pom.xml @@ -14,6 +14,24 @@ cn.hippo4j hippo4j-adapter-web + + + org.springframework.boot + spring-boot-starter-tomcat + true + + + + org.springframework.boot + spring-boot-starter-jetty + true + + + + org.springframework.boot + spring-boot-starter-undertow + true + From 6643ced991e2ac90b09cebca99c67bf9d58e157c Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:13:12 +0800 Subject: [PATCH 07/15] Modifying WebAdapterAutoConfiguration --- .../starter/adapter/web/WebAdapterAutoConfiguration.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java index 18a49bea..480bc432 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java @@ -37,8 +37,6 @@ import org.springframework.core.env.ConfigurableEnvironment; @RequiredArgsConstructor public class WebAdapterAutoConfiguration { - private static final String JETTY_SERVLET_WEB_SERVER_FACTORY = "JettyServletWebServerFactory"; - private static final String UNDERTOW_SERVLET_WEB_SERVER_FACTORY = "undertowServletWebServerFactory"; private final ConfigurableEnvironment environment; @@ -60,11 +58,7 @@ public class WebAdapterAutoConfiguration { return new ThreadPoolRunStateHandler(hippo4JInetUtils, environment); } - @Bean - @ConditionalOnBean(name = JETTY_SERVLET_WEB_SERVER_FACTORY) - public JettyWebThreadPoolHandler jettyWebThreadPoolHandler() { - return new JettyWebThreadPoolHandler(); - } + @Bean @ConditionalOnBean(name = UNDERTOW_SERVLET_WEB_SERVER_FACTORY) From 75b7487ff2670deddc94f475c0f41c2d6b47d880 Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:13:42 +0800 Subject: [PATCH 08/15] Modifying WebThreadPoolHandlerConfiguration --- .../WebThreadPoolHandlerConfiguration.java | 21 +++++++++++++++++++ 1 file changed, 21 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 24ec8a0e..4934b887 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 @@ -1,15 +1,20 @@ package cn.hippo4j.springboot.starter.adapter.web; +import cn.hippo4j.adapter.web.JettyWebThreadPoolHandler; import cn.hippo4j.adapter.web.TomcatWebThreadPoolHandler; import cn.hippo4j.adapter.web.WebThreadPoolRunStateHandler; import org.apache.catalina.startup.Tomcat; import org.apache.coyote.UpgradeProtocol; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.SearchStrategy; import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.context.annotation.Bean; 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 javax.servlet.Servlet; @@ -34,4 +39,20 @@ public class WebThreadPoolHandlerConfiguration { return new TomcatWebThreadPoolHandler(webThreadPoolRunStateHandler); } } + + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass({ Servlet.class, Server.class, Loader.class, WebAppContext.class }) + @ConditionalOnBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT) + static class EmbeddedJetty { + + /** + * Refer to the Server loading source code . + * This load is performed if the {@link Server} class exists and + * the Web embedded server loads the {@link ServletWebServerFactory} top-level interface type at the same time + */ + @Bean + public JettyWebThreadPoolHandler jettyWebThreadPoolHandler() { + return new JettyWebThreadPoolHandler(); + } + } } From 6c19ea8596ecf84521d4ecad0ef2c5cd5395edab Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:14:37 +0800 Subject: [PATCH 09/15] Modifying WebAdapterAutoConfiguration --- .../starter/adapter/web/WebAdapterAutoConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java index 480bc432..87ea6a9b 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java @@ -33,7 +33,8 @@ import org.springframework.core.env.ConfigurableEnvironment; * Web adapter auto configuration. */ @Configuration -@Import({WebThreadPoolHandlerConfiguration.EmbeddedTomcat.class}) +@Import({WebThreadPoolHandlerConfiguration.EmbeddedTomcat.class, + WebThreadPoolHandlerConfiguration.EmbeddedJetty.class}) @RequiredArgsConstructor public class WebAdapterAutoConfiguration { From 31c8b14c256a1f04e57b1b043255b6bbf9ae46da Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:17:19 +0800 Subject: [PATCH 10/15] Fix the Web adaptation configuration --- .../adapter/web/WebAdapterAutoConfiguration.java | 10 ---------- 1 file changed, 10 deletions(-) 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java index 87ea6a9b..7ba32af9 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java @@ -38,8 +38,6 @@ import org.springframework.core.env.ConfigurableEnvironment; @RequiredArgsConstructor public class WebAdapterAutoConfiguration { - private static final String UNDERTOW_SERVLET_WEB_SERVER_FACTORY = "undertowServletWebServerFactory"; - private final ConfigurableEnvironment environment; @Bean @@ -59,14 +57,6 @@ public class WebAdapterAutoConfiguration { return new ThreadPoolRunStateHandler(hippo4JInetUtils, environment); } - - - @Bean - @ConditionalOnBean(name = UNDERTOW_SERVLET_WEB_SERVER_FACTORY) - public UndertowWebThreadPoolHandler undertowWebThreadPoolHandler() { - return new UndertowWebThreadPoolHandler(); - } - @Bean public WebThreadPoolHandlerChoose webThreadPoolServiceChoose() { return new WebThreadPoolHandlerChoose(); 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 11/15] 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(); + } + } } From 636ba9d8ecf811c140731cc8856e2de6c34f152c Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:18:48 +0800 Subject: [PATCH 12/15] Fix the Web adaptation configuration --- .../starter/adapter/web/WebAdapterAutoConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java index 7ba32af9..e3c878aa 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/WebAdapterAutoConfiguration.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/WebAdapterAutoConfiguration.java @@ -22,7 +22,6 @@ import cn.hippo4j.common.config.ApplicationContextHolder; import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; import cn.hippo4j.core.toolkit.inet.InetUtils; import lombok.RequiredArgsConstructor; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,7 +33,8 @@ import org.springframework.core.env.ConfigurableEnvironment; */ @Configuration @Import({WebThreadPoolHandlerConfiguration.EmbeddedTomcat.class, - WebThreadPoolHandlerConfiguration.EmbeddedJetty.class}) + WebThreadPoolHandlerConfiguration.EmbeddedJetty.class, + WebThreadPoolHandlerConfiguration.EmbeddedUndertow.class}) @RequiredArgsConstructor public class WebAdapterAutoConfiguration { From cc9a7f9844926462bc1956d9c4279112d9b4d776 Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:20:09 +0800 Subject: [PATCH 13/15] Fixed Web thread pool adaptation --- .../starter/adapter/web/WebThreadPoolHandlerConfiguration.java | 1 - 1 file changed, 1 deletion(-) 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 3d245e4a..ae9def2e 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 @@ -8,7 +8,6 @@ import org.apache.catalina.startup.Tomcat; import org.apache.coyote.UpgradeProtocol; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.SearchStrategy; import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.context.annotation.Bean; From dc8c809ed5911c79ad82994f86208625e23f9232 Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:39:10 +0800 Subject: [PATCH 14/15] code formatting --- .../adapter/web/WebThreadPoolHandlerConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ae9def2e..4ddc786c 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 @@ -43,7 +43,7 @@ public class WebThreadPoolHandlerConfiguration { } @Configuration(proxyBeanMethods = false) - @ConditionalOnClass({ Servlet.class, Server.class, Loader.class, WebAppContext.class }) + @ConditionalOnClass({Servlet.class, Server.class, Loader.class, WebAppContext.class}) @ConditionalOnBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT) static class EmbeddedJetty { @@ -59,7 +59,7 @@ public class WebThreadPoolHandlerConfiguration { } @Configuration(proxyBeanMethods = false) - @ConditionalOnClass({ Servlet.class, Undertow.class, SslClientAuthMode.class }) + @ConditionalOnClass({Servlet.class, Undertow.class, SslClientAuthMode.class}) @ConditionalOnBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT) static class EmbeddedUndertow { From 19f992c22dac7517236a94799b80a15f54864ec0 Mon Sep 17 00:00:00 2001 From: shining-stars-lk <1031900093@qq.com> Date: Fri, 22 Jul 2022 16:42:01 +0800 Subject: [PATCH 15/15] code formatting --- .../web/WebThreadPoolHandlerConfiguration.java | 17 +++++++++++++++++ 1 file changed, 17 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 4ddc786c..5f41092d 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 @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package cn.hippo4j.springboot.starter.adapter.web; import cn.hippo4j.adapter.web.JettyWebThreadPoolHandler;