Java Code Examples for org.springframework.context.annotation.ImportSelector

The following examples show how to use org.springframework.context.annotation.ImportSelector. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    // 复用 {@link ServerImportSelector} 实现,避免重复劳动
    ImportSelector importSelector = new ServerImportSelector();
    // 筛选 Class 名称集合
    String[] selectedClassNames = importSelector.selectImports(importingClassMetadata);
    // 创建 Bean 定义
            .map(BeanDefinitionBuilder::genericBeanDefinition) // 转化为 BeanDefinitionBuilder 对象
            .map(BeanDefinitionBuilder::getBeanDefinition)     // 转化为 BeanDefinition
            .forEach(beanDefinition ->
                    // 注册 BeanDefinition 到 BeanDefinitionRegistry
                    BeanDefinitionReaderUtils.registerWithGeneratedName(beanDefinition, registry)
Example 2
private String[] selected(ImportSelector registrar, Class<?> importer) {
	if (registrar instanceof DeferredImportSelector) {
		return new DeferredConfigurations(Stream.of(registrar.selectImports(getMetaData(importer)))
				.map(name -> ClassUtils.resolveClassName(name, context.getClassLoader()))
	return registrar.selectImports(getMetaData(importer));
Example 3
Source Project: spring-boot-graal-feature   Source File:    License: Apache License 2.0 4 votes vote down vote up
private boolean implementsImportSelector() {
	return implementsInterface(fromLdescriptorToSlashed(ImportSelector));