From 4e9170ff30fee68363ebd97a297e328eb1634abf Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Fri, 16 Jul 2021 08:47:33 +0800 Subject: [PATCH] =?UTF-8?q?optimize:=20=E5=8F=98=E6=9B=B4=20Spring=20Bean?= =?UTF-8?q?=20=E6=89=A7=E8=A1=8C=E9=A1=BA=E5=BA=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../threadpool/starter/core/ThreadPoolConfigAdapter.java | 3 ++- .../threadpool/starter/listener/ThreadPoolRunListener.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolConfigAdapter.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolConfigAdapter.java index 1c88233c..559dd2fa 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolConfigAdapter.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolConfigAdapter.java @@ -5,6 +5,7 @@ import io.dynamic.threadpool.starter.toolkit.thread.QueueTypeEnum; import io.dynamic.threadpool.starter.toolkit.thread.ThreadPoolBuilder; import io.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import javax.annotation.PostConstruct; @@ -34,8 +35,8 @@ public class ThreadPoolConfigAdapter extends ConfigAdapter { .rejected(new ThreadPoolExecutor.DiscardOldestPolicy()) .build(); - @Order(1025) @PostConstruct + @Order(Ordered.LOWEST_PRECEDENCE - 2048) public void subscribeConfig() { Map executorMap = ApplicationContextHolder.getBeansOfType(DynamicThreadPoolWrap.class); diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/listener/ThreadPoolRunListener.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/listener/ThreadPoolRunListener.java index a9d7a7df..746fc663 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/listener/ThreadPoolRunListener.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/listener/ThreadPoolRunListener.java @@ -16,6 +16,7 @@ import io.dynamic.threadpool.starter.toolkit.thread.RejectedTypeEnum; import io.dynamic.threadpool.starter.toolkit.thread.ThreadPoolBuilder; import io.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap; import lombok.extern.slf4j.Slf4j; +import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import javax.annotation.PostConstruct; @@ -40,8 +41,8 @@ public class ThreadPoolRunListener { this.properties = properties; } - @Order(1024) @PostConstruct + @Order(Ordered.LOWEST_PRECEDENCE - 1024) public void run() { DynamicThreadPoolBanner.printBanner(properties.isBanner());