diff --git a/cola-components/cola-component-extension-starter/src/main/java/com/alibaba/cola/extension/register/ExtensionBootstrap.java b/cola-components/cola-component-extension-starter/src/main/java/com/alibaba/cola/extension/register/ExtensionBootstrap.java index d82083eb2..56735ceae 100644 --- a/cola-components/cola-component-extension-starter/src/main/java/com/alibaba/cola/extension/register/ExtensionBootstrap.java +++ b/cola-components/cola-component-extension-starter/src/main/java/com/alibaba/cola/extension/register/ExtensionBootstrap.java @@ -3,6 +3,7 @@ import com.alibaba.cola.extension.Extension; import com.alibaba.cola.extension.ExtensionPointI; import com.alibaba.cola.extension.Extensions; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -18,6 +19,7 @@ * @author Frank Zhang * @date 2020-06-18 7:55 PM */ +@Slf4j @Component public class ExtensionBootstrap implements ApplicationContextAware { @@ -28,14 +30,16 @@ public class ExtensionBootstrap implements ApplicationContextAware { @PostConstruct public void init(){ - Map extensionBeans = applicationContext.getBeansWithAnnotation(Extension.class); - extensionBeans.values().forEach( - extension -> extensionRegister.doRegistration((ExtensionPointI) extension) - ); - - // handle @Extensions annotation - Map extensionsBeans = applicationContext.getBeansWithAnnotation(Extensions.class); - extensionsBeans.values().forEach( extension -> extensionRegister.doRegistrationExtensions((ExtensionPointI) extension)); + Map extMap = applicationContext.getBeansOfType(ExtensionPointI.class); + for (ExtensionPointI ext : extMap.values()) { + if (ext.getClass().isAnnotationPresent(Extension.class)) { + extensionRegister.doRegistration(ext); + }else if (ext.getClass().isAnnotationPresent(Extensions.class)){ + extensionRegister.doRegistrationExtensions(ext); + }else { + log.error("There is no annotation for @Extension or @Extension on this extension class:{}" , ext.getClass()); + } + } } @Override