diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/DynamicThreadPool.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/DynamicThreadPool.java index 90f36547..b9a5e58f 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/DynamicThreadPool.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/DynamicThreadPool.java @@ -17,6 +17,7 @@ package cn.hippo4j.core.executor; +import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -25,8 +26,8 @@ import java.lang.annotation.Target; /** * Dynamic thread pool. */ -@Target(ElementType.METHOD) +@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) +@Documented public @interface DynamicThreadPool { - } diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/SpringDynamicThreadPool.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/SpringDynamicThreadPool.java index 4c482897..7e2065fc 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/SpringDynamicThreadPool.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/SpringDynamicThreadPool.java @@ -17,20 +17,24 @@ package cn.hippo4j.core.executor; +import org.springframework.context.annotation.Bean; + +import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.springframework.context.annotation.Bean; - /** - *@author : wh - *@date : 2022/10/2 16:10 - *@description: + * A convenience annotation that is itself annotated with + * {@link Bean @Bean} and {@link DynamicThreadPool @DynamicThreadPool}. + * + * @since 1.4.2 */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) +@Documented @Bean +@DynamicThreadPool public @interface SpringDynamicThreadPool { } diff --git a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/config/DynamicThreadPoolConfig.java b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/config/DynamicThreadPoolConfig.java index 63d5331d..59bdb645 100644 --- a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/config/DynamicThreadPoolConfig.java +++ b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/config/DynamicThreadPoolConfig.java @@ -18,6 +18,7 @@ package cn.hippo4j.example.core.config; import cn.hippo4j.core.executor.DynamicThreadPool; +import cn.hippo4j.core.executor.SpringDynamicThreadPool; import cn.hippo4j.core.executor.support.ThreadPoolBuilder; import cn.hippo4j.example.core.handler.TaskTraceBuilderHandler; import cn.hippo4j.example.core.inittest.TaskDecoratorTest; @@ -59,8 +60,10 @@ public class DynamicThreadPoolConfig { return ttlExecutor; } - @Bean - @DynamicThreadPool + /** + * {@link Bean @Bean} and {@link DynamicThreadPool @DynamicThreadPool}. + */ + @SpringDynamicThreadPool public ThreadPoolExecutor messageProduceDynamicThreadPool() { return ThreadPoolBuilder.builderDynamicPoolById(MESSAGE_PRODUCE); }