Skip to content

Commit

Permalink
bugfix: #490
Browse files Browse the repository at this point in the history
  • Loading branch information
heihei180 committed May 6, 2024
1 parent 1a8c433 commit 9532cb5
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,6 +19,7 @@
* @author Frank Zhang
* @date 2020-06-18 7:55 PM
*/
@Slf4j
@Component
public class ExtensionBootstrap implements ApplicationContextAware {

Expand All @@ -28,14 +30,16 @@ public class ExtensionBootstrap implements ApplicationContextAware {

@PostConstruct
public void init(){
Map<String, Object> extensionBeans = applicationContext.getBeansWithAnnotation(Extension.class);
extensionBeans.values().forEach(
extension -> extensionRegister.doRegistration((ExtensionPointI) extension)
);

// handle @Extensions annotation
Map<String, Object> extensionsBeans = applicationContext.getBeansWithAnnotation(Extensions.class);
extensionsBeans.values().forEach( extension -> extensionRegister.doRegistrationExtensions((ExtensionPointI) extension));
Map<String, ExtensionPointI> 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
Expand Down

0 comments on commit 9532cb5

Please sign in to comment.