spring-framework / org.springframework.context.annotation / AnnotatedBeanDefinitionReader

AnnotatedBeanDefinitionReader

open class AnnotatedBeanDefinitionReader

Convenient adapter for programmatic registration of annotated bean classes. This is an alternative to ClassPathBeanDefinitionScanner, applying the same resolution of annotations but for explicitly registered classes only.

Author
Juergen Hoeller

Author
Chris Beams

Author
Sam Brannen

Author
Phillip Webb

Since
3.0

See Also
AnnotationConfigApplicationContext#register

Constructors

<init>

AnnotatedBeanDefinitionReader(registry: BeanDefinitionRegistry)

Create a new AnnotatedBeanDefinitionReader for the given registry. If the registry is EnvironmentCapable, e.g. is an ApplicationContext, the Environment will be inherited, otherwise a new StandardEnvironment will be created and used.

AnnotatedBeanDefinitionReader(registry: BeanDefinitionRegistry, environment: Environment)

Create a new AnnotatedBeanDefinitionReader for the given registry and using the given Environment.

Functions

getRegistry

fun getRegistry(): BeanDefinitionRegistry

Return the BeanDefinitionRegistry that this scanner operates on.

register

open fun register(vararg annotatedClasses: Class<*>): Unit

Register one or more annotated classes to be processed.

Calls to register are idempotent; adding the same annotated class more than once has no additional effect.

registerBean

open fun registerBean(annotatedClass: Class<*>): Unit
open fun registerBean(annotatedClass: Class<*>, vararg qualifiers: Class<out Annotation>): Unit
open fun registerBean(annotatedClass: Class<*>, name: String, vararg qualifiers: Class<out Annotation>): Unit

Register a bean from the given bean class, deriving its metadata from class-declared annotations.

open fun <T : Any> registerBean(annotatedClass: Class<T>, instanceSupplier: Supplier<T>): Unit
open fun <T : Any> registerBean(annotatedClass: Class<T>, name: String, instanceSupplier: Supplier<T>): Unit

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).

setBeanNameGenerator

open fun setBeanNameGenerator(beanNameGenerator: BeanNameGenerator): Unit

Set the BeanNameGenerator to use for detected bean classes.

The default is a AnnotationBeanNameGenerator.

setEnvironment

open fun setEnvironment(environment: Environment): Unit

Set the Environment to use when evaluating whether Conditional-annotated component classes should be registered.

The default is a StandardEnvironment.

setScopeMetadataResolver

open fun setScopeMetadataResolver(scopeMetadataResolver: ScopeMetadataResolver): Unit

Set the ScopeMetadataResolver to use for detected bean classes.

The default is an AnnotationScopeMetadataResolver.