package com.mcbo.common.domain;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;
/**
* Interface to be implemented by types that register additional bean definitions when
* processing @{@link Configuration} classes. Useful when operating at the bean definition
* level (as opposed to {@code @Bean} method/instance level) is desired or necessary.
*
* 当处理配置类时实现类可以注册额外的bean definitions
* 当希望在bean definition级别上进行操作时那么这个接口就很有用。
*
* <p>Along with {@code @Configuration} and {@link org.springframework.context.annotation.ImportSelector}, classes of this type
* may be provided to the @{@link org.springframework.context.annotation.Import} annotation (or may also be returned from an
* {@code ImportSelector}).
*
* 这个接口的子类可用使用@Import注解来导入
* 也可以从ImportSelector中返回
*
* <p>An {@link org.springframework.context.annotation.ImportBeanDefinitionRegistrar} may implement any of the following
* {@link org.springframework.beans.factory.Aware Aware} interfaces, and their respective
* methods will be called prior to {@link #registerBeanDefinitions}:
*
* ImportBeanDefinitionRegistrar可以实现以下任意接口,并且该类中的方法调用会优先于registerBeanDefinitions
* <ul>
* <li>{@link org.springframework.context.EnvironmentAware EnvironmentAware}</li>
* <li>{@link org.springframework.beans.factory.BeanFactoryAware BeanFactoryAware}
* <li>{@link org.springframework.beans.factory.BeanClassLoaderAware BeanClassLoaderAware}
* <li>{@link org.springframework.context.ResourceLoaderAware ResourceLoaderAware}
* </ul>
*
* <p>See implementations and associated unit tests for usage examples.
*
* @author Chris Beams
* @since 3.1
* @see Import
* @see ImportSelector
* @see Configuration
*/
public interface ImportBeanDefinitionRegistrar {
/**
* Register bean definitions as necessary based on the given annotation metadata of
* the importing {@code @Configuration} class.
* <p>Note that {@link BeanDefinitionRegistryPostProcessor} types may <em>not</em> be
* registered here, due to lifecycle constraints related to {@code @Configuration}
* class processing.
*
* 基于导入配置类的注解元数据信息注册bean definitions
* 注意BeanDefinitionRegistryPostProcessor的子类不会在这里进行注册,
* 因生命周期的约束和配置类的处理有关
*
* @param importingClassMetadata annotation metadata of the importing class
* @param registry current bean definition registry
*/
void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry);
}
网友评论