package xtools.boot.elasticsearch.selector;

import org.jspecify.annotations.NonNull;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * <p>Title : BootElasticsearchImportSelector</p>
 * <p>Description : BootElasticsearchImportSelector</p>
 * <p>DevelopTools : Idea_x64_v2026.1</p>
 * <p>DevelopSystem : macOS Sequoia 15.7.5</p>
 * <p>Company : org.xujun</p>
 *
 * @author : XuJun
 * @version : 5.0.0
 * @date : 2026/01/01 09:30
 */
public class BootElasticsearchImportSelector implements ImportBeanDefinitionRegistrar {

    /**
     * 根据给定的注释元数据,根据需要注册bean
     *
     * @param importingClassMetadata AnnotationMetadata
     * @param registry               BeanDefinitionRegistry
     */
    @Override
    public void registerBeanDefinitions(@NonNull AnnotationMetadata importingClassMetadata, @NonNull BeanDefinitionRegistry registry) {
        // 构建扫描对象
        ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(registry, true);
        // 扫描包下路径
        scanner.scan("xtools.boot.elasticsearch");
    }

}