类 AnnotatedBeanDefinitionReader
- java.lang.Object
- org.springframework.context.annotation.AnnotatedBeanDefinitionReader
public class AnnotatedBeanDefinitionReader extends Object
Convenient adapter for programmatic registration of annotated bean classes. This is an alternative toClassPathBeanDefinitionScanner, applying the same resolution of annotations but for explicitly registered classes only.- 从以下版本开始:
- 3.0
- 作者:
- Juergen Hoeller, Chris Beams, Sam Brannen, Phillip Webb
- 另请参阅:
AnnotationConfigApplicationContext.register(java.lang.Class<?>...)
构造器概要
构造器 构造器 说明 AnnotatedBeanDefinitionReader(BeanDefinitionRegistry registry)Create a newAnnotatedBeanDefinitionReaderfor the given registry.AnnotatedBeanDefinitionReader(BeanDefinitionRegistry registry, Environment environment)Create a newAnnotatedBeanDefinitionReaderfor the given registry and using the givenEnvironment.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 BeanDefinitionRegistrygetRegistry()Return the BeanDefinitionRegistry that this scanner operates on.voidregister(Class<?>... annotatedClasses)Register one or more annotated classes to be processed.voidregisterBean(Class<?> annotatedClass)Register a bean from the given bean class, deriving its metadata from class-declared annotations.voidregisterBean(Class<?> annotatedClass, Class<? extends Annotation>... qualifiers)Register a bean from the given bean class, deriving its metadata from class-declared annotations.voidregisterBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers)Register a bean from the given bean class, deriving its metadata from class-declared annotations.voidsetBeanNameGenerator(BeanNameGenerator beanNameGenerator)Set the BeanNameGenerator to use for detected bean classes.voidsetEnvironment(Environment environment)Set the Environment to use when evaluating whether@Conditional-annotated component classes should be registered.voidsetScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver)Set the ScopeMetadataResolver to use for detected bean classes.
构造器详细资料
AnnotatedBeanDefinitionReader
public AnnotatedBeanDefinitionReader(BeanDefinitionRegistry registry)
Create a newAnnotatedBeanDefinitionReaderfor the given registry. If the registry isEnvironmentCapable, e.g. is anApplicationContext, theEnvironmentwill be inherited, otherwise a newStandardEnvironmentwill be created and used.- 参数:
registry- theBeanFactoryto load bean definitions into, in the form of aBeanDefinitionRegistry- 另请参阅:
AnnotatedBeanDefinitionReader(BeanDefinitionRegistry, Environment),setEnvironment(Environment)
AnnotatedBeanDefinitionReader
public AnnotatedBeanDefinitionReader(BeanDefinitionRegistry registry, Environment environment)
Create a newAnnotatedBeanDefinitionReaderfor the given registry and using the givenEnvironment.- 参数:
registry- theBeanFactoryto load bean definitions into, in the form of aBeanDefinitionRegistryenvironment- theEnvironmentto use when evaluating bean definition profiles.- 从以下版本开始:
- 3.1
方法详细资料
getRegistry
public final BeanDefinitionRegistry getRegistry()
Return the BeanDefinitionRegistry that this scanner operates on.
setEnvironment
public void setEnvironment(Environment environment)
Set the Environment to use when evaluating whether@Conditional-annotated component classes should be registered.The default is a
StandardEnvironment.
setBeanNameGenerator
public void setBeanNameGenerator(BeanNameGenerator beanNameGenerator)
Set the BeanNameGenerator to use for detected bean classes.The default is a
AnnotationBeanNameGenerator.
setScopeMetadataResolver
public void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver)
Set the ScopeMetadataResolver to use for detected bean classes.The default is an
AnnotationScopeMetadataResolver.
register
public void register(Class<?>... annotatedClasses)
Register one or more annotated classes to be processed.Calls to
registerare idempotent; adding the same annotated class more than once has no additional effect.- 参数:
annotatedClasses- one or more annotated classes, e.g.@Configurationclasses
registerBean
public void registerBean(Class<?> annotatedClass)
Register a bean from the given bean class, deriving its metadata from class-declared annotations.- 参数:
annotatedClass- the class of the bean
registerBean
public void registerBean(Class<?> annotatedClass, Class<? extends Annotation>... qualifiers)
Register a bean from the given bean class, deriving its metadata from class-declared annotations.- 参数:
annotatedClass- the class of the beanqualifiers- specific qualifier annotations to consider, in addition to qualifiers at the bean class level
registerBean
public void registerBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers)
Register a bean from the given bean class, deriving its metadata from class-declared annotations.- 参数:
annotatedClass- the class of the beanname- an explicit name for the beanqualifiers- specific qualifier annotations to consider, in addition to qualifiers at the bean class level