Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: 更新cola拓展点的查找方式 #492

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading