From a02a7a0d2a24aa885bdf26cc5654cc452f55f867 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Wed, 13 Oct 2021 22:55:19 +0800 Subject: [PATCH] ApplicationContextHolder add query based on annotation. --- .../common/config/ApplicationContextHolder.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/src/main/java/com/github/dynamic/threadpool/common/config/ApplicationContextHolder.java b/common/src/main/java/com/github/dynamic/threadpool/common/config/ApplicationContextHolder.java index 145e32ab..66ce5bb0 100644 --- a/common/src/main/java/com/github/dynamic/threadpool/common/config/ApplicationContextHolder.java +++ b/common/src/main/java/com/github/dynamic/threadpool/common/config/ApplicationContextHolder.java @@ -4,6 +4,7 @@ import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; +import java.lang.annotation.Annotation; import java.util.Map; /** @@ -55,4 +56,16 @@ public class ApplicationContextHolder implements ApplicationContextAware { return CONTEXT.getBeansOfType(clazz); } + /** + * Find whether the bean has annotations. + * + * @param beanName + * @param annotationType + * @param + * @return + */ + public static A findAnnotationOnBean(String beanName, Class annotationType) { + return CONTEXT.findAnnotationOnBean(beanName, annotationType); + } + }