类 AnnotatedBeanDefinitionReader
java.lang.Object
cn.taketoday.beans.factory.config.BeanDefinitionCustomizers
cn.taketoday.context.annotation.AnnotatedBeanDefinitionReader
Convenient adapter for programmatic registration of bean classes.
This is an alternative to ClassPathBeanDefinitionScanner, applying
the same resolution of annotations but for explicitly registered classes only.
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Chris Beams, Sam Brannen, Phillip Webb, TODAY 2021/10/1 16:46
-
字段概要
从类继承的字段 cn.taketoday.beans.factory.config.BeanDefinitionCustomizers
customizers -
构造器概要
构造器构造器说明Create a newAnnotatedBeanDefinitionReaderfor the given registry.AnnotatedBeanDefinitionReader(BeanDefinitionRegistry registry, cn.taketoday.core.env.Environment environment) Create a newAnnotatedBeanDefinitionReaderfor the given registry, using the givenEnvironment. -
方法概要
修饰符和类型方法说明final BeanDefinitionRegistryGet the BeanDefinitionRegistry that this reader operates on.voidRegister one or more component classes to be processed.voidregisterBean(Class<?> beanClass) Register a bean from the given bean class, deriving its metadata from class-declared annotations.voidregisterBean(Class<?> beanClass, Class<? extends Annotation>... qualifiers) Register a bean from the given bean class, deriving its metadata from class-declared annotations.voidregisterBean(Class<?> beanClass, String name) Register a bean from the given bean class, deriving its metadata from class-declared annotations.voidregisterBean(Class<?> beanClass, String name, Class<? extends Annotation>... qualifiers) Register a bean from the given bean class, deriving its metadata from class-declared annotations.<T> voidregisterBean(Class<T> beanClass, String name, Supplier<T> supplier) Register a bean from the given bean class, deriving its metadata from class-declared annotations, using the given supplier for obtaining a new instance (possibly declared as a lambda expression or method reference).<T> voidregisterBean(Class<T> beanClass, String name, Supplier<T> supplier, BeanDefinitionCustomizer... customizers) Register a bean from the given bean class, deriving its metadata from class-declared annotations.<T> voidregisterBean(Class<T> beanClass, Supplier<T> supplier) Register a bean from the given bean class, deriving its metadata from class-declared annotations, using the given supplier for obtaining a new instance (possibly declared as a lambda expression or method reference).voidsetBeanNameGenerator(BeanNameGenerator beanNameGenerator) Set theBeanNameGeneratorto use for detected bean classes.voidsetEnvironment(cn.taketoday.core.env.Environment environment) Set theEnvironmentto use when evaluating whether@Conditional-annotated component classes should be registered.voidsetScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver) Set theScopeMetadataResolverto use for registered component classes.从类继承的方法 cn.taketoday.beans.factory.config.BeanDefinitionCustomizers
addCustomizers, addCustomizers, getCustomizers, loadDefaultCustomizers, loadDefaultCustomizers, setCustomizers, setCustomizers
-
构造器详细资料
-
AnnotatedBeanDefinitionReader
Create a newAnnotatedBeanDefinitionReaderfor the given registry.If the registry is
EnvironmentCapable, 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
public AnnotatedBeanDefinitionReader(BeanDefinitionRegistry registry, cn.taketoday.core.env.Environment environment) Create a newAnnotatedBeanDefinitionReaderfor the given registry, using the givenEnvironment.- 参数:
registry- theBeanFactoryto load bean definitions into, in the form of aBeanDefinitionRegistryenvironment- theEnvironmentto use when evaluating bean definition profiles.
-
-
方法详细资料
-
getRegistry
Get the BeanDefinitionRegistry that this reader operates on. -
setEnvironment
public void setEnvironment(cn.taketoday.core.env.Environment environment) Set theEnvironmentto use when evaluating whether@Conditional-annotated component classes should be registered.The default is a
StandardEnvironment. -
setBeanNameGenerator
Set theBeanNameGeneratorto use for detected bean classes.The default is a
AnnotationBeanNameGenerator. -
setScopeMetadataResolver
Set theScopeMetadataResolverto use for registered component classes.The default is an
AnnotationScopeMetadataResolver. -
register
Register one or more component classes to be processed.Calls to
registerare idempotent; adding the same component class more than once has no additional effect.- 参数:
componentClasses- one or more component classes, e.g.@Configurationclasses
-
registerBean
Register a bean from the given bean class, deriving its metadata from class-declared annotations.- 参数:
beanClass- the class of the bean
-
registerBean
Register a bean from the given bean class, deriving its metadata from class-declared annotations.- 参数:
beanClass- the class of the beanname- an explicit name for the bean (ornullfor generating a default bean name)
-
registerBean
Register a bean from the given bean class, deriving its metadata from class-declared annotations.- 参数:
beanClass- the class of the beanqualifiers- specific qualifier annotations to consider, in addition to qualifiers at the bean class level
-
registerBean
public void registerBean(Class<?> beanClass, @Nullable String name, Class<? extends Annotation>... qualifiers) Register a bean from the given bean class, deriving its metadata from class-declared annotations.- 参数:
beanClass- the class of the beanname- an explicit name for the bean (ornullfor generating a default bean name)qualifiers- specific qualifier annotations to consider, in addition to qualifiers at the bean class level
-
registerBean
Register a bean from the given bean class, deriving its metadata from class-declared annotations, using the given supplier for obtaining a new instance (possibly declared as a lambda expression or method reference).- 参数:
beanClass- the class of the beansupplier- a callback for creating an instance of the bean (may benull)
-
registerBean
public <T> void registerBean(Class<T> beanClass, @Nullable String name, @Nullable Supplier<T> supplier) Register a bean from the given bean class, deriving its metadata from class-declared annotations, using the given supplier for obtaining a new instance (possibly declared as a lambda expression or method reference).- 参数:
beanClass- the class of the beanname- an explicit name for the bean (ornullfor generating a default bean name)supplier- a callback for creating an instance of the bean (may benull)
-
registerBean
public <T> void registerBean(Class<T> beanClass, @Nullable String name, @Nullable Supplier<T> supplier, BeanDefinitionCustomizer... customizers) Register a bean from the given bean class, deriving its metadata from class-declared annotations.- 参数:
beanClass- the class of the beanname- an explicit name for the bean (ornullfor generating a default bean name)supplier- a callback for creating an instance of the bean (may benull)customizers- one or more callbacks for customizing the factory'sBeanDefinition, e.g. setting a lazy-init or primary flag
-